Script
Script data models for spec-kit
Overview
These models define the structure for generated Python scripts with SpecifyX utility access, supporting state transitions and validation.
Classes
GeneratedScript
Python scripts generated from templates with SpecifyX utility access
Dataclass
Purpose: Represents Python scripts created from script templates that can import and use SpecifyX utilities. Supports state transitions from generation through validation with proper permission management.
Methods
create_from_template
create_from_template(name: str, source_template: str, target_path: pathlib.Path, imports: List[str], json_output: bool = False) -> 'GeneratedScript'
Create a new GeneratedScript from template processing
Parameters:
name(str, required) - Script namesource_template(str, required) - Name of the source templatetarget_path(Path, required) - Absolute path where script will be createdimports(List, required) - List of SpecifyX utility importsjson_output(bool, optional) - Whether script supports --json flag - Default:False
Returns: GeneratedScript
from_dict
from_dict(data: Dict[str, Any]) -> 'GeneratedScript'
Create instance from dictionary
Parameters:
data(Dict, required)
Returns: GeneratedScript
get_relative_path_from_project
get_relative_path_from_project(self, project_root: pathlib.Path) -> pathlib.Path
Get script path relative to project root
Parameters:
project_root(Path, required)
Returns: Path
get_script_directory
get_script_directory(self) -> pathlib.Path
Get the directory containing the script
Returns: Path
is_ready_for_use
is_ready_for_use(self) -> bool
Check if script is fully processed and ready for use
Returns: bool
make_executable
make_executable(self) -> None
Transition to MADE_EXECUTABLE state after setting permissions
mark_validated
mark_validated(self) -> None
Transition to VALIDATED state after syntax and imports check
mark_validation_error
mark_validation_error(self, error_message: str) -> None
Mark script as having validation error, preserving current state
Parameters:
error_message(str, required)
reset_to_generated
reset_to_generated(self) -> None
Reset script to GENERATED state (for reprocessing)
to_dict
to_dict(self) -> Dict[str, Any]
Convert to dictionary for serialization
Returns: Dict