API Reference¶
The engine strictly isolates state definition from imperative execution. Rather than executing disjointed setup scripts, the Orchestrator evaluates a polymorphic array of BootstrapModule objects interacting exclusively with a centralized state object: the EnvironmentManifest.
Think of the EnvironmentManifest as the nucleus of the scaffolding process. All modules revolve around this state object, mutating its properties and injecting AST payloads during their respective build() phases.
classDiagram
direction LR
class EnvironmentManifest {
+DependencyManifest dependencies
+FilesystemManifest filesystem
+ToolingManifest tooling
+TaskManifest tasks
+ProjectMetadata metadata
+CollisionStrategy collision_strategy
+add_ide_setting(key: IDESettingKey, value: Any)
}
class DependencyManifest {
+list[str] dependencies
+list[str] dev_dependencies
+list[str] docs_dependencies
+add(package: str)
+add_dev(package: str)
+add_docs(package: str)
}
class FilesystemManifest {
+set[str] directories
+dict[str, str] file_injections
+dict[str, list[str]] file_appends
+set[str] vcs_ignores
+add_directory(path: str)
+add_file_injection(path: str, content: str)
+add_file_append(path: str, content: str)
}
class TaskManifest {
+list[SystemTask] system_tasks
+list[SystemTask] post_install_tasks
+add_system_task(command: list[str], timeout: int, description: str)
+add_post_install_task(command: list[str], timeout: int, description: str)
}
class ToolingManifest {
+bool wants_pre_commit
+bool wants_ci
+add_pre_commit_hook(payload: str)
+add_ci_step(step_yaml: str)
}
class BootstrapModule {
<<Abstract>>
+tuple cli_flags
+str config_key
+pre_flight()*
+build(manifest: EnvironmentManifest)*
}
EnvironmentManifest *-- DependencyManifest : contains
EnvironmentManifest *-- FilesystemManifest : contains
EnvironmentManifest *-- TaskManifest : contains
EnvironmentManifest *-- ToolingManifest : contains
BootstrapModule ..> EnvironmentManifest : Mutates state via build()
Class Definitions¶
Telemetry & Error Handling: protostar.errors
Strictly typed operational errors that halt the execution pipeline safely and return POSIX-compliant exit codes.
protostar.errors.ProtostarError ¶
Bases: Exception
Base class for all expected operational errors in Protostar.
Source code in src/protostar/errors.py
protostar.errors.ConfigurationError ¶
Bases: ProtostarError
Raised when a configuration file is malformed, invalid, or missing requirements.
Source code in src/protostar/errors.py
protostar.errors.NetworkFetchError ¶
Bases: ProtostarError
Raised when fetching a remote template or archive fails due to network or protocol issues.
Source code in src/protostar/errors.py
protostar.errors.TemplateResolutionError ¶
Bases: ProtostarError
Raised when a template is found but cannot be parsed, extracted, or resolved.
Source code in src/protostar/errors.py
protostar.errors.MissingDependencyError ¶
Bases: ProtostarError
Raised during pre-flight checks when a system-level executable is absent.
Source code in src/protostar/errors.py
protostar.errors.CommandExecutionError ¶
Bases: ProtostarError
Raised when a managed subprocess exits with a non-zero status code.
Source code in src/protostar/errors.py
output_detail
property
¶
Formats captured stdout/stderr into a display-ready block, or None if empty.
protostar.errors.CommandTimeoutError ¶
Bases: ProtostarError
Raised when a managed subprocess exceeds its allocated runtime window.
Source code in src/protostar/errors.py
protostar.errors.FileSystemError ¶
Bases: ProtostarError
Raised when a local disk mutation (write, read, mkdir) fails via an OSError or serialization fault.
Source code in src/protostar/errors.py
protostar.errors.SecurityViolationError ¶
Bases: ProtostarError
Raised when a template attempts an unauthorized system or filesystem operation.
Source code in src/protostar/errors.py
protostar.errors.ExecutionAbortedError ¶
Bases: ProtostarError
Raised when the user explicitly aborts the execution via an interactive prompt.
Source code in src/protostar/errors.py
protostar.errors.PartialExecutionAbortedError ¶
Bases: ExecutionAbortedError
Raised when execution is interrupted after disk mutations have begun.
Source code in src/protostar/errors.py
__init__ ¶
Initializes the exception with the frozenset of paths modified before the interrupt.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
touched_paths
|
frozenset[str]
|
Immutable set of file and directory paths touched on disk. |
required |
docs_path
|
DocsPage | str | None
|
Optional path to relevant documentation. |
None
|
Source code in src/protostar/errors.py
protostar.errors.WorkspaceCollisionError ¶
Bases: ProtostarError
Raised by plan() when collision markers exist and no force flag was provided.
Carries a structured set of conflicting paths so callers can programmatically present the collision details or decide a resolution strategy without re-scanning the filesystem.
Source code in src/protostar/errors.py
__init__ ¶
Initializes the error with the set of conflicting workspace paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
frozenset[Path]
|
The set of existing collision-marker paths detected on disk. |
required |
Source code in src/protostar/errors.py
Core Interface: BootstrapModule
protostar.modules.base.BootstrapModule ¶
Bases: ABC
Appends module-specific requirements to the environment manifest.
Source code in src/protostar/modules/base.py
cli_flags
class-attribute
¶
The CLI flags to trigger this module (e.g., ('-p', '--python')).
config_key
class-attribute
¶
The global configuration key used to evaluate if this module is active.
required_metadata
class-attribute
¶
The metadata keys that MUST be resolved for this module to function.
optional_metadata
class-attribute
¶
The metadata keys that are nice to have but not strictly required.
collision_markers
property
¶
Returns a list of critical filesystem paths to evaluate for collisions during pre-flight.
Returns:
| Type | Description |
|---|---|
list[Path]
|
A list of Path objects representing critical configuration files or directories |
list[Path]
|
managed by this module. Defaults to an empty list. |
pre_flight ¶
Verifies system prerequisites before manifest building begins.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a critical dependency (e.g., 'uv', 'cargo') is missing. |
build
abstractmethod
¶
Appends module-specific requirements to the environment manifest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
manifest
|
EnvironmentManifest
|
The centralized state object. |
required |