mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-01 01:59:10 -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
82 lines
2.0 KiB
Python
82 lines
2.0 KiB
Python
"""
|
|
Developer build command for TinyTorch CLI.
|
|
|
|
Wraps site/paper build targets so the VS Code extension and other tools
|
|
can call Tito instead of raw make commands.
|
|
|
|
Usage:
|
|
tito dev build html Build HTML site
|
|
tito dev build serve Build and serve locally
|
|
tito dev build pdf Build PDF course guide
|
|
tito dev build paper Build research paper
|
|
"""
|
|
|
|
import subprocess
|
|
import sys
|
|
from argparse import ArgumentParser, Namespace
|
|
from pathlib import Path
|
|
|
|
from ..base import BaseCommand
|
|
|
|
|
|
BUILD_TARGETS = {
|
|
'html': {
|
|
'command': ['make', 'html'],
|
|
'cwd': 'site',
|
|
'label': 'Build HTML Site',
|
|
},
|
|
'serve': {
|
|
'command': ['make', 'serve'],
|
|
'cwd': 'site',
|
|
'label': 'Build & Serve Site',
|
|
},
|
|
'pdf': {
|
|
'command': ['make', 'pdf'],
|
|
'cwd': 'site',
|
|
'label': 'Build PDF Course Guide',
|
|
},
|
|
'paper': {
|
|
'command': ['make', 'paper'],
|
|
'cwd': 'site',
|
|
'label': 'Build Research Paper',
|
|
},
|
|
}
|
|
|
|
|
|
class DevBuildCommand(BaseCommand):
|
|
"""Developer build command — wraps make targets for site/paper builds."""
|
|
|
|
@property
|
|
def name(self) -> str:
|
|
return "build"
|
|
|
|
@property
|
|
def description(self) -> str:
|
|
return "Build site, PDF, or paper"
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
parser.add_argument(
|
|
'target',
|
|
choices=list(BUILD_TARGETS.keys()),
|
|
help='Build target: html, serve, pdf, paper'
|
|
)
|
|
|
|
def run(self, args: Namespace) -> int:
|
|
target = args.target
|
|
config = BUILD_TARGETS[target]
|
|
console = self.console
|
|
|
|
cwd = self.config.project_root / config['cwd']
|
|
if not cwd.exists():
|
|
console.print(f"[red]❌ Directory not found: {cwd}[/red]")
|
|
return 1
|
|
|
|
console.print(f"[cyan]🔨 {config['label']}...[/cyan]")
|
|
|
|
result = subprocess.run(
|
|
config['command'],
|
|
cwd=str(cwd),
|
|
)
|
|
|
|
return result.returncode
|