mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-02 02:29:16 -05:00
The VS Code extension no longer implements any business logic — every
capability (module discovery, path resolution, system info, builds,
tests, clean) lives in Tito CLI commands. The extension is a pure UI
shell that delegates via `python3 -m tito.main`.
Tito CLI additions:
- `module list --json` for machine-readable module discovery
- `module path <num> --notebook|--source|--about` for file resolution
- `system info --json` for environment info
- `dev build html|serve|pdf|paper` wrapping make targets
- `dev clean [all|site]` wrapping make clean
- Banner suppression for --json and module path output
Extension hardening:
- Centralized CLI integration in utils/tito.ts (single TITO_CMD constant,
callTito, callTitoJson, titoTerminalCommand, isTitoAvailable, log/logError)
- Replaced all silent catch{} blocks with logged errors and user feedback
- Module tree shows error/empty states with actionable Setup/Health buttons
- Info tree shows "Tito CLI unavailable" when CLI is unreachable
- Removed all setTimeout refresh hacks — file watcher on .tito/progress.json
is the sole refresh mechanism
- Exit code tracking via onDidEndTerminalShellExecution
- Tito availability pre-flight check on activation
- BUILD_OUTPUTS constants for build artifact paths
- Zero execSync calls outside tito.ts, zero hardcoded command strings
55 lines
1.6 KiB
Python
55 lines
1.6 KiB
Python
"""
|
|
Developer clean command for TinyTorch CLI.
|
|
|
|
Wraps clean targets so the VS Code extension and other tools
|
|
can call Tito instead of raw make commands.
|
|
|
|
Usage:
|
|
tito dev clean Clean all generated files (project root)
|
|
tito dev clean site Clean site build artifacts
|
|
"""
|
|
|
|
import subprocess
|
|
from argparse import ArgumentParser, Namespace
|
|
|
|
from ..base import BaseCommand
|
|
|
|
|
|
class DevCleanCommand(BaseCommand):
|
|
"""Developer clean command — removes build artifacts."""
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return "clean"
|
|
|
|
@property
|
|
def description(self) -> str:
|
|
return "Clean build artifacts"
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
parser.add_argument(
|
|
'target',
|
|
nargs='?',
|
|
default='all',
|
|
choices=['all', 'site'],
|
|
help='What to clean: all (default), site'
|
|
)
|
|
|
|
def run(self, args: Namespace) -> int:
|
|
target = args.target or 'all'
|
|
console = self.console
|
|
|
|
if target == 'site':
|
|
cwd = self.config.project_root / 'site'
|
|
if not cwd.exists():
|
|
console.print(f"[red]❌ Directory not found: {cwd}[/red]")
|
|
return 1
|
|
console.print("[cyan]🧹 Cleaning site build artifacts...[/cyan]")
|
|
result = subprocess.run(['make', 'clean'], cwd=str(cwd))
|
|
else:
|
|
cwd = self.config.project_root
|
|
console.print("[cyan]🧹 Cleaning all generated files...[/cyan]")
|
|
result = subprocess.run(['make', 'clean'], cwd=str(cwd))
|
|
|
|
return result.returncode
|