Rename project from SmartTools to CmdForge
Major rename operation: - Rename Python package: smarttools -> cmdforge - Update CLI entry point: smarttools -> cmdforge - Update all imports and module references - Update pyproject.toml with new name, URLs, entry point - Update all HTML templates with new branding - Update documentation (CLAUDE.md, README.md, docs/*, wiki/*) - Update environment variables: - SMARTTOOLS_ENV -> CMDFORGE_ENV - SMARTTOOLS_REGISTRY_DB -> CMDFORGE_REGISTRY_DB - SMARTTOOLS_TOKEN -> CMDFORGE_TOKEN - SMARTTOOLS_REGISTRY_* -> CMDFORGE_REGISTRY_* - Update Dockerfile and docker-compose.yml - Update tests to use new package name - Update scripts and examples - Update package.json and tailwind.config.js All 158 unit tests pass. The CLI is working correctly with the new cmdforge command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
"""Project management commands."""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from ..manifest import (
|
||||
load_manifest, save_manifest, create_manifest, find_manifest,
|
||||
MANIFEST_FILENAME
|
||||
)
|
||||
from ..resolver import (
|
||||
find_tool, install_from_registry, ToolSpec
|
||||
)
|
||||
|
||||
|
||||
def cmd_deps(args):
|
||||
"""Show project dependencies from cmdforge.yaml."""
|
||||
manifest = load_manifest()
|
||||
|
||||
if manifest is None:
|
||||
print("No cmdforge.yaml found in current project.")
|
||||
print("Create one with: cmdforge init")
|
||||
return 1
|
||||
|
||||
print(f"Project: {manifest.name} v{manifest.version}")
|
||||
print()
|
||||
|
||||
if not manifest.dependencies:
|
||||
print("No dependencies defined.")
|
||||
print("Add one with: cmdforge add <owner/name>")
|
||||
return 0
|
||||
|
||||
print(f"Dependencies ({len(manifest.dependencies)}):")
|
||||
print()
|
||||
|
||||
for dep in manifest.dependencies:
|
||||
# Check if installed
|
||||
installed = find_tool(dep.name)
|
||||
status = "[installed]" if installed else "[not installed]"
|
||||
|
||||
print(f" {dep.name}")
|
||||
print(f" Version: {dep.version}")
|
||||
print(f" Status: {status}")
|
||||
print()
|
||||
|
||||
if manifest.overrides:
|
||||
print("Overrides:")
|
||||
for name, override in manifest.overrides.items():
|
||||
if override.provider:
|
||||
print(f" {name}: provider={override.provider}")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_install_deps(args):
|
||||
"""Install dependencies from cmdforge.yaml."""
|
||||
from ..registry_client import RegistryError
|
||||
|
||||
manifest = load_manifest()
|
||||
|
||||
if manifest is None:
|
||||
print("No cmdforge.yaml found in current project.")
|
||||
print("Create one with: cmdforge init")
|
||||
return 1
|
||||
|
||||
if not manifest.dependencies:
|
||||
print("No dependencies to install.")
|
||||
return 0
|
||||
|
||||
print(f"Installing dependencies for {manifest.name}...")
|
||||
print()
|
||||
|
||||
failed = []
|
||||
installed = []
|
||||
|
||||
for i, dep in enumerate(manifest.dependencies, 1):
|
||||
print(f"[{i}/{len(manifest.dependencies)}] {dep.name}@{dep.version}")
|
||||
|
||||
# Check if already installed
|
||||
existing = find_tool(dep.name)
|
||||
if existing:
|
||||
print(f" Already installed: {existing.full_name}")
|
||||
installed.append(dep.name)
|
||||
continue
|
||||
|
||||
try:
|
||||
print(f" Downloading...")
|
||||
resolved = install_from_registry(dep.name, dep.version)
|
||||
print(f" Installed: {resolved.full_name}@{resolved.version}")
|
||||
installed.append(dep.name)
|
||||
except RegistryError as e:
|
||||
if e.code == "TOOL_NOT_FOUND":
|
||||
print(f" Not found in registry")
|
||||
elif e.code == "VERSION_NOT_FOUND" or e.code == "CONSTRAINT_UNSATISFIABLE":
|
||||
print(f" Version {dep.version} not available")
|
||||
elif e.code == "CONNECTION_ERROR":
|
||||
print(f" Connection failed (check network)")
|
||||
else:
|
||||
print(f" Failed: {e.message}")
|
||||
failed.append(dep.name)
|
||||
except Exception as e:
|
||||
print(f" Failed: {e}")
|
||||
failed.append(dep.name)
|
||||
|
||||
print()
|
||||
print(f"Installed {len(installed)} tools")
|
||||
|
||||
if failed:
|
||||
print(f"Failed: {', '.join(failed)}")
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_add(args):
|
||||
"""Add a tool to project dependencies."""
|
||||
from ..registry_client import RegistryError
|
||||
|
||||
tool_spec = args.tool
|
||||
version = args.version or "*"
|
||||
|
||||
# Find or create manifest
|
||||
manifest_path = find_manifest()
|
||||
if manifest_path:
|
||||
manifest = load_manifest(manifest_path)
|
||||
else:
|
||||
# Create in current directory
|
||||
manifest = create_manifest(name=Path.cwd().name)
|
||||
manifest_path = Path.cwd() / MANIFEST_FILENAME
|
||||
|
||||
# Parse tool spec
|
||||
parsed = ToolSpec.parse(tool_spec)
|
||||
full_name = parsed.full_name
|
||||
|
||||
# Add dependency
|
||||
manifest.add_dependency(full_name, version)
|
||||
|
||||
# Save
|
||||
save_manifest(manifest, manifest_path)
|
||||
print(f"Added {full_name}@{version} to {manifest_path.name}")
|
||||
|
||||
# Install if requested
|
||||
if not args.no_install:
|
||||
print(f"Installing {full_name}...")
|
||||
try:
|
||||
resolved = install_from_registry(tool_spec, version if version != "*" else None)
|
||||
print(f"Installed: {resolved.full_name}@{resolved.version}")
|
||||
except RegistryError as e:
|
||||
if e.code == "TOOL_NOT_FOUND":
|
||||
print(f"Tool not found in registry.", file=sys.stderr)
|
||||
print(f"It's been added to your dependencies - you can install it manually later.", file=sys.stderr)
|
||||
elif e.code == "CONNECTION_ERROR":
|
||||
print(f"Could not connect to registry.", file=sys.stderr)
|
||||
print("Run 'cmdforge install' to try again later.", file=sys.stderr)
|
||||
else:
|
||||
print(f"Install failed: {e.message}", file=sys.stderr)
|
||||
print("Run 'cmdforge install' to try again.", file=sys.stderr)
|
||||
except Exception as e:
|
||||
print(f"Install failed: {e}", file=sys.stderr)
|
||||
print("Run 'cmdforge install' to try again.", file=sys.stderr)
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
def cmd_init(args):
|
||||
"""Initialize a new cmdforge.yaml."""
|
||||
manifest_path = Path.cwd() / MANIFEST_FILENAME
|
||||
|
||||
if manifest_path.exists() and not args.force:
|
||||
print(f"{MANIFEST_FILENAME} already exists. Use --force to overwrite.")
|
||||
return 1
|
||||
|
||||
# Get project name
|
||||
default_name = Path.cwd().name
|
||||
if args.name:
|
||||
name = args.name
|
||||
else:
|
||||
try:
|
||||
name = input(f"Project name [{default_name}]: ").strip() or default_name
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
print()
|
||||
name = default_name
|
||||
|
||||
# Get version
|
||||
if args.version:
|
||||
version = args.version
|
||||
else:
|
||||
try:
|
||||
version = input("Version [1.0.0]: ").strip() or "1.0.0"
|
||||
except (EOFError, KeyboardInterrupt):
|
||||
print()
|
||||
version = "1.0.0"
|
||||
|
||||
# Create manifest
|
||||
manifest = create_manifest(name=name, version=version)
|
||||
save_manifest(manifest, manifest_path)
|
||||
|
||||
print(f"Created {MANIFEST_FILENAME}")
|
||||
print()
|
||||
print("Add dependencies with: cmdforge add <owner/name>")
|
||||
print("Install them with: cmdforge install")
|
||||
|
||||
return 0
|
||||
Reference in New Issue
Block a user