How tienld-0801/tilokit works
Project type and purpose
• TiLoKit is a Go-based CLI tool for bootstrapping multi-language, multi-framework projects.
• It exposes commands (via cmd/root.go and internal/cli) that invoke a central engine to discover plugins (builders, frameworks, tools, templates) and generate project scaffolds.
File structure
• Top-level:
• cmd/ + main.go → entrypoint, Cobra-style command definitions
• internal/cli → CLI parsing, handlers, “manager” coordinating commands
• internal/core → context (app state), engine (orchestrator), registry (plugin lookup)
• internal/plugins → plugin subpackages by category (builders, frameworks, templates, tools)
• internal/utils → filesystem helpers, common utilities
• config → YAML defaults
• templates → static template files per language/framework
• Dockerfile, Makefile, scripts → build/release pipeline
• Patterns: plugin architecture using a Registry, separation of concerns between CLI, core, plugins, and I/O layers.
Key README insights
• Plugin-based, extensible design
• Interactive mode and direct CLI commands
• Planned config and plugin ecosystems
• Multi-framework support via discrete plugin packages
Core components
a. CLI Layer
• cmd package (root.go, subcommands)
• internal/cli (handlers, manager)
b. Core Engine Layer
• Context (application state, options)
• Engine (invokes generation flow)
• Registry (discovers and returns plugin instances)
c. Plugin Subsystem
• Builders (rollup, vite, webpack)
• Frameworks (react, vue, go, python, etc.)
• Templates (generic template logic)
• Tools (git, package managers)
d. Resources & I/O
• Templates directory (language/framework templates)
• File system (writes generated code)
• External tools (Git init, package installs)
e. Configuration
• YAML config loader (config/tilokit.yaml)
• Environment variables (.env)
Relationships and interactions
1. User invokes “tilokit” CLI → cmd.Root executes
2. CLI Layer parses flags/args → builds Context
3. CLI Manager calls Engine.Generate(context)
4. Engine queries Registry for selected plugins (framework + builder + tools)
5. Plugins apply templates, emit files via utils.FileWrite
6. If requested, Tool plugins invoke external binaries (git, npm, pip)
7. Generation complete → output summary to user
Architectural patterns & design principles
• Plugin Architecture / Inversion of Control (Registry injects plugins at runtime)
• Layered separation: Presentation (CLI) → Application (Engine) → Plugins → I/O
• Single binary deployment (Go static compile)
• Use of a Context object to carry options and state
Technologies, frameworks, libraries
• Go modules, Cobra (or similar CLI framework)
• YAML config parsing (e.g., go-yaml)
• Standard library for file I/O