Skip to content

API Reference parrot.setup.scaffolding

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.setup.scaffolding

View source

Scaffolding utilities for the parrot setup wizard.

Provides all file I/O operations used by the wizard pipeline:

  • slugify / class_name_from_slug — name transformations
  • render_template — string.Template-based rendering from parrot/templates/
  • write_env_vars — safe append to .env files
  • scaffold_agent — generate an Agent Python file in AGENTS_DIR
  • bootstrap_app — generate app.py and run.py in the project root

Function bootstrap_app

Generate app.py and run.py in the project root.

Skips generation (and emits a warning) if either file already exists and force is False.

bootstrap_app(agent_config: object, cwd: Path, force: bool = False) -> bool

Parameter Type Default Description
agent_config object AgentConfig instance used to populate template variables for app.py.
cwd Path Project root directory where app.py and run.py are written.
force bool False When True, overwrite existing files without prompting.

Returns: bool — True if both files were written; False if skipped due to pre-existing files.

Function class_name_from_slug

Convert a hyphenated slug to a PascalCase class name.

class_name_from_slug(slug: str) -> str

Parameter Type Default Description
slug str Hyphenated slug (e.g. "my-research-agent").

Returns: str — PascalCase class name (e.g. "MyResearchAgent").

Function module_name_from_slug

Convert a hyphenated slug to a valid Python module name.

module_name_from_slug(slug: str) -> str

Parameter Type Default Description
slug str Hyphenated slug (e.g. "my-research-agent").

Returns: str — Underscored module name (e.g. "my_research_agent").

Function render_template

Render a string.Template file from parrot/templates/.

Uses safe_substitute so unrecognised $variables are left intact rather than raising KeyError.

render_template(template_name: str, context: Dict[str, str]) -> str

Parameter Type Default Description
template_name str Filename inside parrot/templates/ (e.g. "agent.py.tpl").
context Dict[str, str] Mapping of variable name → replacement string.

Returns: str — Rendered content with all $variables substituted.

Raises:

  • FileNotFoundError — If the requested template file does not exist.

Function scaffold_agent

Scaffold a new Agent Python file from the agent.py.tpl template.

Writes the rendered file to AGENTS_DIR/<module_name>.py, creating the directory if necessary.

scaffold_agent(agent_config: object, cwd: Path) -> Path

Parameter Type Default Description
agent_config object AgentConfig instance with name, agent_id, and provider_config.llm_string set.
cwd Path Project root (unused directly; AGENTS_DIR is resolved from parrot.conf).

Returns: Path — Absolute Path of the created agent .py file.

Function slugify

Convert a human-readable name to a URL-safe hyphenated slug.

Strips special characters, collapses whitespace to hyphens, and lower-cases the result.

slugify(name: str) -> str

Parameter Type Default Description
name str Human-readable string (e.g. "My Research Agent #1").

Returns: str — Lowercase hyphenated slug (e.g. "my-research-agent-1").

Function write_env_vars

Write environment variables to a .env file.

If the file doesn't exist, it is first seeded from navconfig's base template (with ENV, CONFIG_FILE, DEBUG, etc.) so that the application can boot correctly. Credentials are then appended.

write_env_vars(env_vars: Dict[str, str], env_path: Path, environment: str = 'default') -> None

Parameter Type Default Description
env_vars Dict[str, str] Mapping of VAR_NAME → value to write.
env_path Path Absolute (or relative) path to the target .env file.
environment str 'default' Environment name (used when seeding a new file).

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally