Support pc init . to scaffold a project in place#95
Merged
Conversation
Add an optional positional TARGET path to 'pc init'. Passing a path (e.g. '.') scaffolds the project contents directly into that directory instead of nesting them under a <project_name> subfolder. The project name defaults to the target directory's basename (--name still overrides). Convert 'init' from a Typer group to a plain command so the positional argument can be followed by options (Click groups stop parsing options at the first positional). The 'quickstart' token is dispatched from the init callback to preserve 'pc init quickstart [-o DIR]'. Omitting the positional argument keeps the existing nesting behavior, so this change is non-breaking.
Cover CLI behavior (in-place writes, name derivation from the directory, CLAUDE.md preservation, conflict abort, target/-o mutual exclusion) and non-breaking regressions (nested layout, quickstart), plus generator-level in_place unit tests.
markbackman
added a commit
to pipecat-ai/pipecat
that referenced
this pull request
Jun 4, 2026
Add an optional positional TARGET to `pipecat init`. Passing a path — e.g. `pipecat init .` — scaffolds the project directly into that directory instead of nesting it under a <project-name>/ subfolder (the vite/django convention). The project name defaults to the target directory's basename; --name still overrides it. Omitting the argument keeps the existing behavior, so this is non-breaking. init is converted from a Typer group to a plain command so the positional can be followed by options; the quickstart token is dispatched from within init_command to preserve `pc init quickstart [-o DIR]`. ProjectGenerator gains an in_place mode that writes straight into the target, guards against clobbering an existing project (server/ present), and omits the `cd <name>` next step. Ported from pipecat-ai/pipecat-cli#95.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional positional
TARGETpath topc init. Passing a path — e.g.pc init .— scaffolds the project contents directly into that directory instead of nesting them under a<project_name>/subfolder (the vite/django convention:npm create vite@latest .,django-admin startproject name .).This is motivated by the upcoming Pipecat agentic coding loop: a user creates a directory containing
CLAUDE.mdguidance, the agent runspc init, and the project should land in that directory rather than nested one level down (which would otherwise force the agent tomv/rmdirfiles around — fragile with hidden files and stray artifacts).Non-breaking: omitting the positional argument keeps the exact current behavior (
<-o or cwd>/<name>/).Behavior
pc init<-o or cwd>/<name>/subfolderpc init .pc init ./foo./foo(created if missing)pc init quickstart [-o DIR]TARGETis the exact destination;-o/--outputkeeps its legacy "parent dir + name subfolder" meaning. Passing both is an error.TARGETis given:--nameif provided, else derived from the target directory's basename. So--nameis optional in this mode.Implementation notes
initconverted from a Typer group to a plain command. A positional argument on a Click group can't be followed by options (parsing stops at the first positional), which would breakpc init . --bot-type web .... As a plain command, interspersed options work. Thequickstarttoken is dispatched from withininit_commandto preservepc init quickstart [-o DIR].ProjectGenerator.generate(..., in_place=True)writes straight into the target, guards against clobbering an existing project (aborts if aserver/dir is already present), andprint_next_stepsomits the now-irrelevantcd <name>step. Shared file-writing logic extracted into_write_project_files.Testing
uv run pytest tests/→ 445 passing.tests/test_init_in_place.py: in-place writes, name derivation,CLAUDE.mdpreservation, conflict abort,target/-omutual exclusion, and non-breaking regressions (nested layout + quickstart). Plus generator-levelin_placeunit tests.pc init .into a dir holdingCLAUDE.md→ flat layout (server/,README.md,.gitignore),CLAUDE.mduntouched, name derived from the folder.🤖 Generated with Claude Code