Scaffolding
scaffolding
Public scaffold primitives and optional domain-provider discovery.
Entry points in axm.scaffold_providers are named after the scaffold kind
and load a zero-argument provider factory. Domain packages own their templates.
CheckResult
Bases: BaseModel
Result of a single audit check.
Note: type: ignore[explicit-any] flags pydantic BaseModel
internals (third-party).
Source code in packages/axm-init/src/axm_init/models/check.py
earned
property
Points earned: weight if passed, 0 otherwise.
CopierAdapter
Adapter for Copier template operations.
Wraps Copier's run_copy function with a Pydantic-based interface and returns structured ScaffoldResult.
Source code in packages/axm-init/src/axm_init/adapters/copier.py
| Python | |
|---|---|
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 | |
apply_chain(layers, destination, data, *, record_answers=True)
Apply ordered template layers to one destination.
Each layer receives caller data overlaid with its own data and keeps a dedicated answers file so Copier can reapply its ownership rules independently from the other layers.
With record_answers=False, exclude the engine's answer destinations
before rendering and omit fallback answer creation. Existing answers
stay untouched, including answers belonging to the same layer.
Source code in packages/axm-init/src/axm_init/adapters/copier.py
copy(config)
Execute Copier copy operation.
Suppresses stdout/stderr via the scoped :func:_suppress_output
context manager so that post-copy tasks (git init, uv sync,
pre-commit install) don't pollute the parent process stdio —
critical when running inside an MCP server. Suppression is scoped
to the interpreter-level streams and never mutates the process-global
file descriptors 1/2, so concurrent writers on those fds are
unaffected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
CopierConfig
|
Copier configuration with template path, destination, and data. |
required |
Returns:
| Type | Description |
|---|---|
ScaffoldResult
|
ScaffoldResult with success status and path. |
Source code in packages/axm-init/src/axm_init/adapters/copier.py
CopierConfig
Bases: BaseModel
Configuration for Copier execution.
Note: type: ignore[explicit-any] flags pydantic BaseModel
internals (third-party).
Source code in packages/axm-init/src/axm_init/adapters/copier.py
answers_file = None
class-attribute
instance-attribute
Render the template without running its _tasks.
The bundled templates declare post-copy tasks that shell out to git init
and two uv add invocations, so a single render resolves 72 packages and
installs 72 of them — measured at 2.23s and 239 MB against 0.60s and 0.1 MB
with tasks skipped. The rendered tree is identical either way: only the
tasks' side-effects are absent, and the deterministic ones (LICENSE,
.python-version, uv.lock, the pre-commit hook) are cheap to
synthesize. Production scaffolding leaves this False; a caller that only
needs the rendered tree — a test asserting template structure, say — sets it
to True rather than paying for a package installation it never inspects.
exclude = ()
class-attribute
instance-attribute
Destination-relative patterns omitted by Copier during rendering.
Framework
Bases: StrEnum
Ecosystem a project is scaffolded/checked against.
Source code in packages/axm-init/src/axm_init/core/framework.py
ProviderError
ProviderHook
Bases: Protocol
A provider capability; hooks are always invoked positionally.
Source code in packages/axm-init/src/axm_init/scaffolding.py
ScaffoldProvider
Bases: Protocol
Provider factory result; paths must remain available during rendering.
Providers may additionally define finalize(request, destination, data).
It runs after successful rendering under the destination lock and may merge
domain metadata. Raising an exception reports failure with partial output.
Source code in packages/axm-init/src/axm_init/scaffolding.py
layers(request)
ScaffoldRequest
dataclass
Context used to select domain-owned layers (answers remain separate).
Source code in packages/axm-init/src/axm_init/scaffolding.py
ScaffoldResult
Bases: BaseModel
Result of a scaffolding operation.
Note: type: ignore[explicit-any] flags pydantic BaseModel
internals (third-party).
Source code in packages/axm-init/src/axm_init/models/results.py
TemplateLayer
Bases: BaseModel
One ordered Copier template application.
Source code in packages/axm-init/src/axm_init/core/templates.py
TemplateType
Bases: StrEnum
Available scaffold template types.
Source code in packages/axm-init/src/axm_init/core/templates.py
load_provider(kind)
Load only the requested kind; absence is distinct from broken installs.
Source code in packages/axm-init/src/axm_init/scaffolding.py
provider_hook(kind, name)
Resolve a required domain capability with an actionable version error.
Source code in packages/axm-init/src/axm_init/scaffolding.py
render_scaffold(kind, destination, data, *, framework=Framework.PYTHON, member=False, record_answers=True)
Create a scaffold in a missing/empty directory; never update user files.
Installed providers take precedence. Built-in kinds retain their historical
template-chain fallback. Templates are trusted as with init itself, and may
execute Copier tasks. This is not transactional: task/render failures may
leave partial output. Existing learning overlays use their dedicated route.
Set record_answers=False to omit engine-generated Copier answer files.
Source code in packages/axm-init/src/axm_init/scaffolding.py
require_provider(kind)
Require installed domain ownership before executing a domain operation.
Source code in packages/axm-init/src/axm_init/scaffolding.py
requires_toml(check_name, category, weight, fix)
Decorator that loads pyproject.toml and passes data to the check.
If pyproject.toml is missing or unparsable, returns a failure
CheckResult immediately — eliminating the repeated null-guard
preamble from every check function.
The decorated function receives (project, data) instead of just
(project) — where data is the parsed TOML dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
check_name
|
str
|
Check result name (e.g. |
required |
category
|
str
|
Category key (e.g. |
required |
weight
|
int
|
Points weight for this check. |
required |
fix
|
str
|
Fix message for the "not found" failure. |
required |
Source code in packages/axm-init/src/axm_init/checks/_utils.py
run_rules(path, rules)
Run explicit rules in order, preserving findings and propagating errors.
No discovery, score aggregation, exclusions, or domain interpretation is performed. Callers own their finding types and presentation policy.
Source code in packages/axm-init/src/axm_init/rules.py
section(data, key)
Return data[key] if it is a mapping, otherwise an empty mapping.
Helper for safely walking nested TOML structures without leaking
object typing through .get() chains.
Source code in packages/axm-init/src/axm_init/checks/_utils.py
table_at(container, key)
Return the table at key, creating an empty one when absent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
TomlContainer
|
The document or table to read the branch from. |
required |
key
|
str
|
The key holding the nested table. |
required |
Returns:
| Type | Description |
|---|---|
Table
|
The existing table, or the freshly created and attached one. |
Raises:
| Type | Description |
|---|---|
ValueError
|
When key already holds a non-table value. |
Source code in packages/axm-init/src/axm_init/core/toml_edit.py
target_root_lock(root)
Hold the process-wide lock guarding writes on the canonical root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Path
|
The target root, resolved before lookup so that distinct spellings of one directory share a single lock. |
required |
Yields:
| Type | Description |
|---|---|
None
|
|
Source code in packages/axm-init/src/axm_init/core/root_lock.py
template_chain(template_type, framework, *, member, existing=False)
Resolve the ordered Copier layers for a scaffold request.