toolbase 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.
- {toolbase-0.3.0 → toolbase-0.5.0}/PKG-INFO +1 -1
- {toolbase-0.3.0 → toolbase-0.5.0}/pyproject.toml +1 -1
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/cli.py +352 -11
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/__init__.py +2 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/manifest.py +25 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/orchestrator.py +36 -3
- {toolbase-0.3.0 → toolbase-0.5.0}/CHANGELOG.md +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/LICENSE +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/MANIFEST.in +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/README.md +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/setup.cfg +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/__init__.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/_setup_host.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/_toolkit_host.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/astro.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/auth.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/config.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/connect/__init__.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/connect/base.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/connect/claude_code.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/connect/codex.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/connect/orchestral.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/bundle_deps.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/cache.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/config.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/discovery.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/paths.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/envs/schema.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/hep.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/ingest.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/logging/__init__.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/logging/logger.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/neutrino.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/quantum.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/__init__.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/bundles.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/config.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/profile_scaffold.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/profiles.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/serve/proxy_tool.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/__init__.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/_rpc.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/context.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/declarative.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/downloads.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/prompts.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/runner.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/schema.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/storage.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/setup/validate_cache.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/skills.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/Dockerfile.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/README.md.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/__init__.py.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/mcp/__init__.py.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/mcp/server_stdio.py.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/requirements.txt.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/setup.py.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/skills/example_skill.md +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/tool_example.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/templates/toolkit.yaml.template +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/toolkit.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/validation.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase/versioning.py +0 -0
- {toolbase-0.3.0 → toolbase-0.5.0}/toolbase.egg-info/SOURCES.txt +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "toolbase"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.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"
|
|
@@ -3480,6 +3480,49 @@ def _pin_after_install(
|
|
|
3480
3480
|
)
|
|
3481
3481
|
|
|
3482
3482
|
|
|
3483
|
+
def _pin_editable_local(name: str, *, local_scope: bool) -> None:
|
|
3484
|
+
"""Pin (name, "editable") into the machine-local manifest layer.
|
|
3485
|
+
|
|
3486
|
+
Writes ``manifest.local.yaml`` next to the scoped project's
|
|
3487
|
+
committed manifest and drops a ``.gitignore`` into ``.toolbase/``
|
|
3488
|
+
(created only if absent) so the local layer never reaches git.
|
|
3489
|
+
Best-effort like _pin_after_install: a failure warns, the install
|
|
3490
|
+
stands.
|
|
3491
|
+
"""
|
|
3492
|
+
try:
|
|
3493
|
+
from .envs import (
|
|
3494
|
+
project_manifest_path as _project_manifest_path,
|
|
3495
|
+
local_manifest_path as _local_manifest_path,
|
|
3496
|
+
add_pin as _add_pin,
|
|
3497
|
+
default_project_root as _default_project_root,
|
|
3498
|
+
)
|
|
3499
|
+
if local_scope:
|
|
3500
|
+
from .envs import find_project_root as _find_project_root
|
|
3501
|
+
found = _find_project_root(cwd=Path.cwd())
|
|
3502
|
+
if found is None:
|
|
3503
|
+
project_root = Path.cwd().resolve()
|
|
3504
|
+
_materialize_project_dir(project_root)
|
|
3505
|
+
else:
|
|
3506
|
+
project_root = found
|
|
3507
|
+
else:
|
|
3508
|
+
project_root = _default_project_root()
|
|
3509
|
+
local_path = _local_manifest_path(_project_manifest_path(project_root))
|
|
3510
|
+
_add_pin(local_path, name, "editable")
|
|
3511
|
+
gitignore = local_path.parent / ".gitignore"
|
|
3512
|
+
if not gitignore.exists():
|
|
3513
|
+
gitignore.write_text("manifest.local.yaml\n")
|
|
3514
|
+
console.print(
|
|
3515
|
+
f"[dim]Pinned editable in {local_path.name} "
|
|
3516
|
+
f"(machine-local, gitignored).[/dim]"
|
|
3517
|
+
)
|
|
3518
|
+
except Exception as e:
|
|
3519
|
+
console.print(
|
|
3520
|
+
f"[dim]Note: could not write the local editable pin: {e} — "
|
|
3521
|
+
f"without it, numbered slots outrank this checkout.[/dim]"
|
|
3522
|
+
)
|
|
3523
|
+
|
|
3524
|
+
|
|
3525
|
+
|
|
3483
3526
|
def _install_from_path(
|
|
3484
3527
|
source_path: Path,
|
|
3485
3528
|
*,
|
|
@@ -3861,10 +3904,12 @@ def _install_from_path(
|
|
|
3861
3904
|
),
|
|
3862
3905
|
)
|
|
3863
3906
|
else:
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3907
|
+
# Editable pins are machine state (they point at THIS machine's
|
|
3908
|
+
# source checkout), so they go to the gitignored local layer —
|
|
3909
|
+
# never the committed manifest. Without a pin the editable slot
|
|
3910
|
+
# would lose version resolution to any numbered slot and the
|
|
3911
|
+
# checkout would silently not serve.
|
|
3912
|
+
_pin_editable_local(name, local_scope=local_scope)
|
|
3868
3913
|
|
|
3869
3914
|
console.print(f"\n[bold]Ready to use! Try:[/bold]")
|
|
3870
3915
|
console.print(f" [cyan]tb activate {name}[/cyan] # expose it to the agent")
|
|
@@ -4084,6 +4129,220 @@ def _post_install_activate(
|
|
|
4084
4129
|
console.print(f"[dim]{result.message}[/dim]")
|
|
4085
4130
|
|
|
4086
4131
|
|
|
4132
|
+
@main.command()
|
|
4133
|
+
@click.argument('path', default='.',
|
|
4134
|
+
type=click.Path(exists=True, file_okay=False))
|
|
4135
|
+
@click.option('--output', '-o', 'output_dir', default='.',
|
|
4136
|
+
type=click.Path(file_okay=False),
|
|
4137
|
+
help='Directory to write the tarball into (default: cwd).')
|
|
4138
|
+
def export(path, output_dir):
|
|
4139
|
+
"""
|
|
4140
|
+
Package a toolkit directory as an installable tarball.
|
|
4141
|
+
|
|
4142
|
+
\b
|
|
4143
|
+
The registry-free distribution path: export on one machine,
|
|
4144
|
+
move the file however you like (scp, artifact store), install
|
|
4145
|
+
elsewhere with `tb install <name>-<version>.tar.gz`. Useful for
|
|
4146
|
+
private toolkits that aren't published to the registry.
|
|
4147
|
+
|
|
4148
|
+
Uses the same packaging as `tb publish`: VCS/build cruft and
|
|
4149
|
+
consumer-side state (.toolbase/, .mcp.json, .claude/, ...) are
|
|
4150
|
+
excluded, so local machine paths never leak into the package.
|
|
4151
|
+
"""
|
|
4152
|
+
import yaml as _yaml
|
|
4153
|
+
|
|
4154
|
+
source = Path(path).resolve()
|
|
4155
|
+
tk_yaml = source / "toolkit.yaml"
|
|
4156
|
+
if not tk_yaml.is_file():
|
|
4157
|
+
raise click.UsageError(f"{source}: no toolkit.yaml — not a toolkit directory.")
|
|
4158
|
+
try:
|
|
4159
|
+
meta = _yaml.safe_load(tk_yaml.read_text()) or {}
|
|
4160
|
+
except Exception as e:
|
|
4161
|
+
raise click.UsageError(f"{tk_yaml}: unreadable ({e})")
|
|
4162
|
+
name = meta.get("name")
|
|
4163
|
+
version = meta.get("version")
|
|
4164
|
+
if not name or not version:
|
|
4165
|
+
raise click.UsageError(
|
|
4166
|
+
f"{tk_yaml}: needs `name:` and `version:` to name the package."
|
|
4167
|
+
)
|
|
4168
|
+
|
|
4169
|
+
out_dir = Path(output_dir).resolve()
|
|
4170
|
+
out_dir.mkdir(parents=True, exist_ok=True)
|
|
4171
|
+
out = out_dir / f"{name}-{version}.tar.gz"
|
|
4172
|
+
create_tarball(source, out, name)
|
|
4173
|
+
size = out.stat().st_size
|
|
4174
|
+
click.echo(f"✓ exported {name} {version} → {out} ({_format_bytes(size)})")
|
|
4175
|
+
click.echo(f" install elsewhere with: tb install {out.name}")
|
|
4176
|
+
|
|
4177
|
+
|
|
4178
|
+
# ── import files (`tb install <file>.yaml`) ─────────────────────────────
|
|
4179
|
+
|
|
4180
|
+
# Recognized keys, kept strict: an unknown key in a committed import
|
|
4181
|
+
# file is a typo'd intention, and silently ignoring it would install
|
|
4182
|
+
# something other than what the author wrote down.
|
|
4183
|
+
_IMPORT_ENTRY_KEYS = {"name", "source", "version", "editable", "bundles"}
|
|
4184
|
+
|
|
4185
|
+
|
|
4186
|
+
def _parse_import_file(path: Path) -> list:
|
|
4187
|
+
"""Parse a toolkit import file into normalized install entries.
|
|
4188
|
+
|
|
4189
|
+
Shape::
|
|
4190
|
+
|
|
4191
|
+
toolkits:
|
|
4192
|
+
- name: calculator # registry install
|
|
4193
|
+
version: 0.2.0 # optional
|
|
4194
|
+
bundles: [scientific] # optional
|
|
4195
|
+
- source: ../heptapod # path install
|
|
4196
|
+
editable: true # live symlink (-e)
|
|
4197
|
+
|
|
4198
|
+
Each entry needs ``name`` (registry) or ``source`` (path); relative
|
|
4199
|
+
sources resolve against the import file's directory so the file
|
|
4200
|
+
travels with a repo, and ``${VAR}`` in sources expands from the
|
|
4201
|
+
environment.
|
|
4202
|
+
"""
|
|
4203
|
+
import yaml as _yaml
|
|
4204
|
+
|
|
4205
|
+
try:
|
|
4206
|
+
data = _yaml.safe_load(path.read_text()) or {}
|
|
4207
|
+
except Exception as e:
|
|
4208
|
+
raise click.UsageError(f"{path}: unreadable YAML ({e})")
|
|
4209
|
+
if not isinstance(data, dict) or not isinstance(data.get("toolkits"), list):
|
|
4210
|
+
raise click.UsageError(
|
|
4211
|
+
f"{path}: an import file is a mapping with a `toolkits:` list."
|
|
4212
|
+
)
|
|
4213
|
+
|
|
4214
|
+
entries = []
|
|
4215
|
+
for i, raw in enumerate(data["toolkits"]):
|
|
4216
|
+
where = f"{path} toolkits[{i}]"
|
|
4217
|
+
if not isinstance(raw, dict):
|
|
4218
|
+
raise click.UsageError(f"{where}: entry must be a mapping, got {raw!r}")
|
|
4219
|
+
unknown = set(raw) - _IMPORT_ENTRY_KEYS
|
|
4220
|
+
if unknown:
|
|
4221
|
+
raise click.UsageError(
|
|
4222
|
+
f"{where}: unknown key(s) {sorted(unknown)}; "
|
|
4223
|
+
f"expected {sorted(_IMPORT_ENTRY_KEYS)}"
|
|
4224
|
+
)
|
|
4225
|
+
name = raw.get("name")
|
|
4226
|
+
source = raw.get("source")
|
|
4227
|
+
editable = bool(raw.get("editable", False))
|
|
4228
|
+
if not name and not source:
|
|
4229
|
+
raise click.UsageError(f"{where}: needs `name:` (registry) or `source:` (path)")
|
|
4230
|
+
if editable and not source:
|
|
4231
|
+
raise click.UsageError(f"{where}: `editable: true` requires `source:`")
|
|
4232
|
+
if source:
|
|
4233
|
+
expanded = os.path.expandvars(os.path.expanduser(str(source)))
|
|
4234
|
+
src = Path(expanded)
|
|
4235
|
+
if not src.is_absolute():
|
|
4236
|
+
src = (path.parent / src).resolve()
|
|
4237
|
+
target = str(src)
|
|
4238
|
+
else:
|
|
4239
|
+
target = str(name)
|
|
4240
|
+
bundles = raw.get("bundles")
|
|
4241
|
+
if bundles is not None and not (
|
|
4242
|
+
isinstance(bundles, list) and all(isinstance(b, str) for b in bundles)
|
|
4243
|
+
):
|
|
4244
|
+
raise click.UsageError(f"{where}: `bundles:` must be a list of strings")
|
|
4245
|
+
entries.append({
|
|
4246
|
+
"target": target,
|
|
4247
|
+
"label": str(name or source),
|
|
4248
|
+
"version": raw.get("version"),
|
|
4249
|
+
"editable": editable,
|
|
4250
|
+
"bundles": tuple(bundles) if bundles else (),
|
|
4251
|
+
})
|
|
4252
|
+
if not entries:
|
|
4253
|
+
raise click.UsageError(f"{path}: `toolkits:` list is empty.")
|
|
4254
|
+
return entries
|
|
4255
|
+
|
|
4256
|
+
|
|
4257
|
+
def _install_from_import_file(ctx, path: Path, *, global_scope, local_scope,
|
|
4258
|
+
no_skills, activate_after, rebuild,
|
|
4259
|
+
yes, no_, no_input, invoke=None) -> None:
|
|
4260
|
+
"""Install every toolkit an import file lists, via the normal
|
|
4261
|
+
per-toolkit install path (``ctx.invoke``), with the file-level
|
|
4262
|
+
scope/prompt flags applied to each entry.
|
|
4263
|
+
|
|
4264
|
+
Per-entry failures do not abort the run — the remaining entries
|
|
4265
|
+
still install — but the command exits nonzero with a summary, so a
|
|
4266
|
+
broken entry cannot pass silently in provisioning scripts.
|
|
4267
|
+
|
|
4268
|
+
``invoke`` is a test seam; production uses ``ctx.invoke(install, ...)``.
|
|
4269
|
+
"""
|
|
4270
|
+
entries = _parse_import_file(path)
|
|
4271
|
+
if invoke is None:
|
|
4272
|
+
def invoke(**kw):
|
|
4273
|
+
return ctx.invoke(install, **kw)
|
|
4274
|
+
|
|
4275
|
+
failures = []
|
|
4276
|
+
for e in entries:
|
|
4277
|
+
click.echo("→ installing " + e["label"]
|
|
4278
|
+
+ (" @" + e["version"] if e["version"] else "")
|
|
4279
|
+
+ (" (editable)" if e["editable"] else ""))
|
|
4280
|
+
try:
|
|
4281
|
+
invoke(
|
|
4282
|
+
name=e["target"], version=e["version"],
|
|
4283
|
+
global_scope=global_scope, local_scope=local_scope,
|
|
4284
|
+
editable=e["editable"], no_skills=no_skills,
|
|
4285
|
+
activate_after=activate_after, bundle_flags=e["bundles"],
|
|
4286
|
+
rebuild=rebuild, yes=yes, no_=no_, no_input=no_input,
|
|
4287
|
+
)
|
|
4288
|
+
except click.ClickException as exc:
|
|
4289
|
+
failures.append((e["label"], exc.format_message()))
|
|
4290
|
+
except Exception as exc:
|
|
4291
|
+
failures.append((e["label"], type(exc).__name__ + ": " + str(exc)))
|
|
4292
|
+
|
|
4293
|
+
if failures:
|
|
4294
|
+
for label, msg in failures:
|
|
4295
|
+
click.echo("✗ " + label + ": " + msg, err=True)
|
|
4296
|
+
raise click.ClickException(
|
|
4297
|
+
f"{len(failures)}/{len(entries)} import entries failed."
|
|
4298
|
+
)
|
|
4299
|
+
click.echo(f"✓ {len(entries)} toolkit(s) installed from {path.name}")
|
|
4300
|
+
|
|
4301
|
+
|
|
4302
|
+
def _install_from_tarball(ctx, path: Path, *, version, global_scope,
|
|
4303
|
+
local_scope, no_skills, activate_after,
|
|
4304
|
+
bundle_flags, rebuild, yes, no_, no_input,
|
|
4305
|
+
invoke=None) -> None:
|
|
4306
|
+
"""Install an exported toolkit tarball (``tb export``'s output).
|
|
4307
|
+
|
|
4308
|
+
Extracts to a temp dir, validates a root toolkit.yaml, and
|
|
4309
|
+
re-dispatches through the normal path-install flow — the tarball is
|
|
4310
|
+
just a portable wrapper around a source directory. ``invoke`` is a
|
|
4311
|
+
test seam; production uses ``ctx.invoke(install, ...)``.
|
|
4312
|
+
"""
|
|
4313
|
+
import tarfile
|
|
4314
|
+
import tempfile
|
|
4315
|
+
|
|
4316
|
+
if invoke is None:
|
|
4317
|
+
def invoke(**kw):
|
|
4318
|
+
return ctx.invoke(install, **kw)
|
|
4319
|
+
|
|
4320
|
+
with tempfile.TemporaryDirectory(prefix="tb-install-") as tmp:
|
|
4321
|
+
try:
|
|
4322
|
+
with tarfile.open(path, "r:gz") as tar:
|
|
4323
|
+
tar.extractall(path=tmp, filter="data")
|
|
4324
|
+
except Exception as e:
|
|
4325
|
+
raise click.UsageError(f"{path}: not a readable .tar.gz ({e})")
|
|
4326
|
+
root = Path(tmp)
|
|
4327
|
+
if not (root / "toolkit.yaml").is_file():
|
|
4328
|
+
# Tolerate a single top-level directory wrapping the toolkit.
|
|
4329
|
+
subdirs = [d for d in root.iterdir() if d.is_dir()]
|
|
4330
|
+
if len(subdirs) == 1 and (subdirs[0] / "toolkit.yaml").is_file():
|
|
4331
|
+
root = subdirs[0]
|
|
4332
|
+
else:
|
|
4333
|
+
raise click.UsageError(
|
|
4334
|
+
f"{path}: no toolkit.yaml at the archive root — is this "
|
|
4335
|
+
"a `tb export` package?"
|
|
4336
|
+
)
|
|
4337
|
+
invoke(
|
|
4338
|
+
name=str(root), version=version,
|
|
4339
|
+
global_scope=global_scope, local_scope=local_scope,
|
|
4340
|
+
editable=False, no_skills=no_skills,
|
|
4341
|
+
activate_after=activate_after, bundle_flags=bundle_flags,
|
|
4342
|
+
rebuild=rebuild, yes=yes, no_=no_, no_input=no_input,
|
|
4343
|
+
)
|
|
4344
|
+
|
|
4345
|
+
|
|
4087
4346
|
@main.command()
|
|
4088
4347
|
@click.argument('name')
|
|
4089
4348
|
@click.option('--version', '-v', help='Specific version to install (default: latest)')
|
|
@@ -4146,7 +4405,8 @@ def _post_install_activate(
|
|
|
4146
4405
|
),
|
|
4147
4406
|
)
|
|
4148
4407
|
@_interactive_options
|
|
4149
|
-
|
|
4408
|
+
@click.pass_context
|
|
4409
|
+
def install(ctx, name, version, global_scope, local_scope, editable, no_skills, activate_after, bundle_flags, rebuild, yes, no_, no_input):
|
|
4150
4410
|
"""
|
|
4151
4411
|
Install a toolkit — from the registry or a local source directory.
|
|
4152
4412
|
|
|
@@ -4194,6 +4454,42 @@ def install(name, version, global_scope, local_scope, editable, no_skills, activ
|
|
|
4194
4454
|
|
|
4195
4455
|
mode = _resolve_prompt_mode(yes, no_, no_input)
|
|
4196
4456
|
|
|
4457
|
+
# Import-file mode: ``tb install <file>.yaml`` installs every
|
|
4458
|
+
# toolkit the file lists — the shareable counterpart to
|
|
4459
|
+
# per-toolkit installs, so a project can commit e.g. toolkits.yaml
|
|
4460
|
+
# and a fresh machine is one command. Detected before name/path
|
|
4461
|
+
# disambiguation: directories (toolkit sources) keep their
|
|
4462
|
+
# meaning; only an existing YAML *file* triggers import.
|
|
4463
|
+
if name and name.lower().endswith((".yaml", ".yml")) and Path(name).is_file():
|
|
4464
|
+
if editable or version or bundle_flags:
|
|
4465
|
+
raise click.UsageError(
|
|
4466
|
+
"-e/--version/--bundle apply per toolkit — set them on "
|
|
4467
|
+
"the entries inside the import file instead."
|
|
4468
|
+
)
|
|
4469
|
+
return _install_from_import_file(
|
|
4470
|
+
ctx, Path(name),
|
|
4471
|
+
global_scope=global_scope, local_scope=local_scope,
|
|
4472
|
+
no_skills=no_skills, activate_after=activate_after,
|
|
4473
|
+
rebuild=rebuild, yes=yes, no_=no_, no_input=no_input,
|
|
4474
|
+
)
|
|
4475
|
+
|
|
4476
|
+
# Tarball mode: ``tb install <toolkit>.tar.gz`` installs an exported
|
|
4477
|
+
# package (see ``tb export``) — distribution without the registry,
|
|
4478
|
+
# e.g. moving a private toolkit to a server by scp.
|
|
4479
|
+
if name and name.lower().endswith((".tar.gz", ".tgz")) and Path(name).is_file():
|
|
4480
|
+
if editable:
|
|
4481
|
+
raise click.UsageError(
|
|
4482
|
+
"-e is meaningless for a tarball (nothing to live-link). "
|
|
4483
|
+
"Install the source directory editable instead."
|
|
4484
|
+
)
|
|
4485
|
+
return _install_from_tarball(
|
|
4486
|
+
ctx, Path(name), version=version,
|
|
4487
|
+
global_scope=global_scope, local_scope=local_scope,
|
|
4488
|
+
no_skills=no_skills, activate_after=activate_after,
|
|
4489
|
+
bundle_flags=bundle_flags, rebuild=rebuild,
|
|
4490
|
+
yes=yes, no_=no_, no_input=no_input,
|
|
4491
|
+
)
|
|
4492
|
+
|
|
4197
4493
|
# Flag exclusivity. -e/-l/-g pick one scope/source; -g is the
|
|
4198
4494
|
# default when none is given.
|
|
4199
4495
|
if sum(int(b) for b in (editable, local_scope, global_scope)) > 1:
|
|
@@ -4993,6 +5289,21 @@ def list_cmd(as_json, verbose):
|
|
|
4993
5289
|
f"[dim](used {last_used}, {size})[/dim]"
|
|
4994
5290
|
f"{subset_tag}"
|
|
4995
5291
|
)
|
|
5292
|
+
# Editable-shadow warning: a live-linked checkout exists but
|
|
5293
|
+
# resolution picks a numbered slot — the developer's code is
|
|
5294
|
+
# not what serves. Same condition as discovery's shadow_note.
|
|
5295
|
+
selected = pin_map.get(name) or (
|
|
5296
|
+
max((e.version for e in grouped[name]),
|
|
5297
|
+
key=lambda v: parse_version(v) or (0, 0, 0))
|
|
5298
|
+
if len(grouped[name]) > 1 else grouped[name][0].version
|
|
5299
|
+
)
|
|
5300
|
+
has_editable = any(e.version == "editable" for e in grouped[name])
|
|
5301
|
+
if has_editable and selected != "editable":
|
|
5302
|
+
console.print(
|
|
5303
|
+
" [yellow]⚠ editable slot shadowed by "
|
|
5304
|
+
f"{selected} — pin 'editable' in "
|
|
5305
|
+
".toolbase/manifest.local.yaml to serve your checkout[/yellow]"
|
|
5306
|
+
)
|
|
4996
5307
|
if verbose:
|
|
4997
5308
|
_list_print_tools_verbose(name, resolved_profile)
|
|
4998
5309
|
|
|
@@ -5177,14 +5488,19 @@ def _list_resolve_pin_map(entries):
|
|
|
5177
5488
|
load_manifest as _load_manifest,
|
|
5178
5489
|
)
|
|
5179
5490
|
project_root, _source = _resolve_active_project_root()
|
|
5491
|
+
from .envs import (
|
|
5492
|
+
load_merged_pins as _load_merged_pins,
|
|
5493
|
+
local_manifest_path as _local_manifest_path,
|
|
5494
|
+
)
|
|
5180
5495
|
manifest_path = _project_manifest_path(project_root)
|
|
5181
|
-
if not manifest_path.exists()
|
|
5496
|
+
if (not manifest_path.exists()
|
|
5497
|
+
and not _local_manifest_path(manifest_path).exists()):
|
|
5182
5498
|
return {}, None
|
|
5183
|
-
manifest
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
)
|
|
5499
|
+
# Merged view: committed manifest + machine-local layer
|
|
5500
|
+
# (manifest.local.yaml), local wins — the same resolution
|
|
5501
|
+
# discover_toolkits uses, so the * markers never disagree
|
|
5502
|
+
# with what actually serves.
|
|
5503
|
+
return _load_merged_pins(manifest_path), manifest_path
|
|
5188
5504
|
except Exception:
|
|
5189
5505
|
# Manifest read errors (schema-too-new, malformed) shouldn't
|
|
5190
5506
|
# break list. Skip the pin indicator and proceed.
|
|
@@ -5382,11 +5698,36 @@ def uninstall(name, yes, no_, no_input):
|
|
|
5382
5698
|
# we silently fall back to default-project (which is where ``install``
|
|
5383
5699
|
# would have pinned in the no-project case anyway).
|
|
5384
5700
|
try:
|
|
5701
|
+
from .envs import (
|
|
5702
|
+
local_manifest_path as _local_manifest_path,
|
|
5703
|
+
load_manifest as _load_manifest_for_pins,
|
|
5704
|
+
)
|
|
5385
5705
|
project_root, _source = _resolve_active_project_root()
|
|
5386
5706
|
manifest_path = _project_manifest_path(project_root)
|
|
5707
|
+
local_path = _local_manifest_path(manifest_path)
|
|
5387
5708
|
remaining = _list_versions(name)
|
|
5388
5709
|
if not remaining:
|
|
5389
5710
|
_remove_pin(manifest_path, name)
|
|
5711
|
+
_remove_pin(local_path, name)
|
|
5712
|
+
else:
|
|
5713
|
+
# Some versions remain. If a pin (committed or local layer)
|
|
5714
|
+
# still names a version we just removed, it now dangles —
|
|
5715
|
+
# serving would SKIP the toolkit entirely ("pinned version
|
|
5716
|
+
# not in cache") even though usable slots exist. Remove the
|
|
5717
|
+
# stale pin loudly; unpinned resolution falls back to the
|
|
5718
|
+
# highest remaining slot.
|
|
5719
|
+
for layer in (manifest_path, local_path):
|
|
5720
|
+
pins = {e.name: e.version
|
|
5721
|
+
for e in _load_manifest_for_pins(layer).toolkits}
|
|
5722
|
+
pinned = pins.get(name)
|
|
5723
|
+
if pinned is not None and pinned not in remaining:
|
|
5724
|
+
_remove_pin(layer, name)
|
|
5725
|
+
console.print(
|
|
5726
|
+
f"[yellow]⚠ Removed stale pin {name}@{pinned} from "
|
|
5727
|
+
f"{layer.name} (slot uninstalled; remaining: "
|
|
5728
|
+
f"{', '.join(remaining)}). Re-pin with "
|
|
5729
|
+
f"`tb install {name}@<version> -l` if needed.[/yellow]"
|
|
5730
|
+
)
|
|
5390
5731
|
except Exception as e:
|
|
5391
5732
|
console.print(
|
|
5392
5733
|
f"[dim]Note: could not update project manifest: {e}[/dim]"
|
|
@@ -146,6 +146,31 @@ _MANIFEST_HEADER_COMMENT = (
|
|
|
146
146
|
)
|
|
147
147
|
|
|
148
148
|
|
|
149
|
+
def local_manifest_path(manifest_path: Path) -> Path:
|
|
150
|
+
"""The machine-local pin layer sitting next to a committed manifest.
|
|
151
|
+
|
|
152
|
+
``manifest.yaml`` is committed (shareable: what the project depends
|
|
153
|
+
on, optionally pinned to registry versions). ``manifest.local.yaml``
|
|
154
|
+
is gitignored machine state — the place for pins that are only true
|
|
155
|
+
on this machine, above all ``version: editable`` (an editable slot
|
|
156
|
+
points into a local source checkout that no other machine has).
|
|
157
|
+
Local pins override committed pins name-by-name, mirroring the
|
|
158
|
+
user->project two-layer merge used for config values.
|
|
159
|
+
"""
|
|
160
|
+
return manifest_path.with_name("manifest.local.yaml")
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def load_merged_pins(manifest_path: Path) -> dict:
|
|
164
|
+
"""``{name: version}`` from the committed manifest with the local
|
|
165
|
+
layer merged over it (local wins per name). Either file may be
|
|
166
|
+
absent; absent layers contribute nothing."""
|
|
167
|
+
pins = {e.name: e.version for e in load_manifest(manifest_path).toolkits}
|
|
168
|
+
local = load_manifest(local_manifest_path(manifest_path))
|
|
169
|
+
for e in local.toolkits:
|
|
170
|
+
pins[e.name] = e.version
|
|
171
|
+
return pins
|
|
172
|
+
|
|
173
|
+
|
|
149
174
|
def load_manifest(path: Path) -> Manifest:
|
|
150
175
|
"""Read a manifest from disk, returning an empty ``Manifest`` if absent.
|
|
151
176
|
|
|
@@ -187,11 +187,14 @@ def discover_toolkits(toolkits_dir: Optional[Path] = None) -> List[ToolkitDiscov
|
|
|
187
187
|
pin_by_name: Dict[str, str] = {}
|
|
188
188
|
try:
|
|
189
189
|
from ..cli import _resolve_active_project_root
|
|
190
|
+
from ..envs import load_merged_pins
|
|
190
191
|
project_root, _source = _resolve_active_project_root()
|
|
191
192
|
manifest_path = project_manifest_path(project_root)
|
|
192
|
-
manifest
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
# Committed manifest merged with the machine-local layer
|
|
194
|
+
# (manifest.local.yaml) — local pins win per name. Editable
|
|
195
|
+
# pins belong in the local layer; they describe THIS machine's
|
|
196
|
+
# source checkout, not the project.
|
|
197
|
+
pin_by_name = load_merged_pins(manifest_path)
|
|
195
198
|
except Exception:
|
|
196
199
|
pin_by_name = {}
|
|
197
200
|
|
|
@@ -232,9 +235,29 @@ def discover_toolkits(toolkits_dir: Optional[Path] = None) -> List[ToolkitDiscov
|
|
|
232
235
|
reverse=True,
|
|
233
236
|
)[0]
|
|
234
237
|
|
|
238
|
+
# An editable slot that lost selection is a likely surprise:
|
|
239
|
+
# the developer linked a source checkout, but a numbered slot
|
|
240
|
+
# (or a committed pin) outranks it, so their live code is NOT
|
|
241
|
+
# what serves. Selection stays deterministic; we just refuse
|
|
242
|
+
# to be quiet about it. Carried in meta so both the serve
|
|
243
|
+
# banner and `tb list` can surface it.
|
|
244
|
+
shadow_note = None
|
|
245
|
+
if chosen is not None and chosen.version != "editable" and skip_extra is None:
|
|
246
|
+
editable_slot = next(
|
|
247
|
+
(c for c in candidates if c.version == "editable"), None)
|
|
248
|
+
if editable_slot is not None:
|
|
249
|
+
src = (editable_slot.install_meta or {}).get("source_path", "?")
|
|
250
|
+
shadow_note = (
|
|
251
|
+
f"editable slot (-> {src}) is shadowed by "
|
|
252
|
+
f"{chosen.version} — pin 'editable' in "
|
|
253
|
+
f".toolbase/manifest.local.yaml to serve your checkout"
|
|
254
|
+
)
|
|
255
|
+
|
|
235
256
|
# Build the legacy-shaped meta dict that the rest of the
|
|
236
257
|
# orchestrator expects.
|
|
237
258
|
meta = dict(chosen.legacy_meta)
|
|
259
|
+
if shadow_note:
|
|
260
|
+
meta["shadow_note"] = shadow_note
|
|
238
261
|
if not meta.get("environment") and chosen.install_meta.get("install_method"):
|
|
239
262
|
meta["environment"] = chosen.install_meta["install_method"]
|
|
240
263
|
meta.setdefault(
|
|
@@ -1056,6 +1079,16 @@ class Orchestrator:
|
|
|
1056
1079
|
# config. Tools whose ``bundle:`` field names an unavailable
|
|
1057
1080
|
# bundle are dropped from the served set. One stderr line per
|
|
1058
1081
|
# dropped bundle, fired once at startup (NOT per call).
|
|
1082
|
+
# Editable-shadow warning (set at discovery): the developer's
|
|
1083
|
+
# source checkout exists but a numbered slot is what serves.
|
|
1084
|
+
note = (disc.meta or {}).get("shadow_note")
|
|
1085
|
+
if note:
|
|
1086
|
+
self.console.print(f" [yellow]⚠[/yellow] [dim]{disc.name}: {note}[/dim]")
|
|
1087
|
+
self.logger.log_event(
|
|
1088
|
+
"editable_shadowed", toolkit=disc.name,
|
|
1089
|
+
message=note, level="warn",
|
|
1090
|
+
)
|
|
1091
|
+
|
|
1059
1092
|
availability, name_to_bundles = _resolve_bundle_availability(disc)
|
|
1060
1093
|
if availability.dropped_bundles:
|
|
1061
1094
|
for bname, missing in availability.dropped_bundles.items():
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|