new_agent (Agent scaffold generator)
What it is
- A small helper used by the
naas-abi-cliClick CLI to generate (“scaffold”) a new agent project from a template directory into a target path.
Public API
new_agent(agent_name: str, agent_path: str = ".", extra_values: dict = {})- Normalizes
agent_nameto PascalCase. - Ensures
agent_pathexists (defaults to current working directory when"."). - Copies templates from
naas_abi_cli/cli/new/templates/agentintoagent_pathusingCopier. - Provides template values:
agent_name_pascal: PascalCase agent name.module_name_snake: defaults to"your_module_name"if not provided inextra_values.
- Normalizes
- CLI command:
new agent- Implemented as Click command function
_new_agent(agent_name, agent_path="."). - Delegates to
new_agent(...).
- Implemented as Click command function
Configuration/Dependencies
- Dependencies
click(CLI command registration and argument parsing)naas_abi_cli(used to locate the templates directory)naas_abi_cli.cli.utils.Copier.Copier(performs template copying).utils.to_pascal_case(name normalization)
- Templates location
- Resolved at runtime via:
os.path.join(os.path.dirname(naas_abi_cli.__file__), "cli/new/templates/agent")
- Resolved at runtime via:
Usage
From Python
from naas_abi_cli.cli.new.agent import new_agent
new_agent("my agent", agent_path=".", extra_values={"module_name_snake": "my_module"})
From CLI
naas-abi-cli new agent MyAgent .
Caveats
extra_valueshas a mutable default ({}); repeated calls may share state across invocations if the dict is mutated.- Passing
"."asagent_pathis treated specially and replaced with the current working directory.