new_project
What it is
A click command (new project) that scaffolds a new Naas ABI project directory from templates, generates an initial module, optionally adds local deployment scaffolding, and installs/validates dependencies using uv.
Public API
new_project(project_name: str | None, project_path: str | None, with_local_deploy: bool, with_headscale: bool)- CLI command registered as
new projectunder thenewcommand group. - Responsibilities:
- Normalize
project_nameto kebab-case. - Determine/normalize the target
project_pathand ensure it ends with the project name. - Create the target directory (fails if it exists and is non-empty).
- Copy project templates into the destination using
Copier. - Create a module under
<project_path>/srcvianew_module(..., quiet=True). - Optionally generate local deploy scaffolding via
setup_local_deploy(..., include_headscale=...). - Run:
uv add naas-abi-core[all] naas-abi-marketplace[ai-chatgpt] naas-abi naas-abi-cliuv run abi config validate
- Normalize
- CLI command registered as
CLI parameters/options
- Arguments:
project-name(optional; defaults to current directory name)project-path(optional; defaults to current working directory)
- Options:
--with-local-deploy / --without-local-deploy(default: enabled)--with-headscale / --without-headscale(default: disabled)
Configuration/Dependencies
- Uses template files located at:
<naas_abi_cli package>/cli/new/templates/project
- Relies on:
uvexecutable available onPATH(used viasubprocess.run)- Internal helpers:
Copierfor template copyingnew_modulefor module creationsetup_local_deployfor docker-compose/deploy scaffoldingto_kebab_case,to_snake_case,to_pascal_casefor naming
Usage
Minimal CLI usage (from a shell):
# Create a project in ./my-project (folder created if missing)
abi new project my-project .
# Create a project at /tmp/my-project without local deploy scaffolding
abi new project my-project /tmp --without-local-deploy
# Include headscale in local deploy scaffolding
abi new project my-project . --with-headscale
Caveats
- The destination folder must be empty; if it exists and contains files, the command prints a message and exits with code
1. - The command runs
uv add ...anduv run abi config validatewithcheck=True; failures raise an exception and stop execution. project_pathis forced to end with the resolvedproject_name(it appends the name if the last path component doesn’t match).