Skip to content

capy project create, delete and restore, with agent questions - #404

Merged
cvince merged 27 commits into
mainfrom
vince/cap-748-project-elicitations
Nov 10, 2026
Merged

cvince merged 27 commits into
mainfrom
vince/cap-748-project-elicitations

Conversation

@cvince

@cvince cvince commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Adds capy project create|delete|restore. Each one asks the human before it acts: in a terminal with a prompt, and for an agent with an elicitation the agent puts to the human.

What changes

New capy project command group. capy project create, capy project delete and capy project restore replace capy org delete-project and capy org restore-project, which never shipped in a release. capy projects still lists projects, and capy org projects --deleted still lists deleted ones. capy org now only switches organization.

capy project create [name] --branch <name> --protected yes|no (new).

  • It creates the project and its first branch. In a terminal it asks for the name, the first branch ("What should its first branch be called?", with what a Capy branch is) and whether the branch is protected (yes/no, default no). Anything passed as a flag is not asked again.
  • In agent mode it creates nothing until it has all three. It exits 3 with a form elicitation holding only the missing fields (PROJECT_NAME_REQUIRED, BRANCH_NAME_REQUIRED or BRANCH_PROTECTION_REQUIRED), and the rerun command to run with the answers.
  • It refuses a name a live project already has, and it never suggests one. If the project is created but its branch is not, it exits with BRANCH_CREATE_FAILED and still returns the project.
  • Owners and admins only. It does not link the current folder. --dry-run checks the values and creates nothing.

capy project delete <name-or-id>.

  • Without --yes, an agent gets CONFIRMATION_REQUIRED (exit 3) with a confirm elicitation and changes nothing.
  • The elicitation shows the org, the project, its branches, every variable name with its branches, and live deploy tokens. It carries names and ids only, never a value.
  • --force deletes despite live deploy tokens.

capy project restore <name-or-id>. Asks the same way: a yes/no prompt in a terminal, or a confirm elicitation for an agent. --dry-run names the project that would come back and restores nothing.

A name shared by several projects. Delete and restore ask which one. A terminal shows an arrow list. An agent gets PROJECT_AMBIGUOUS (exit 3) with a pick-one elicitation, whose options are each project's name, variable count and creation time ("created 3 days ago", once the service returns created_at). A name that matches nothing is refused with PROJECT_NOT_FOUND, and nothing is sent.

Agent mode is --json, --non-tty, or no terminal. It applies to all three commands. The elicitation and code come back as JSON with --json; without it, the refusal is a message on stderr with the same exit code. In agent mode they never open a prompt, including the organization picker. With no organization in the folder and several to choose from, they exit 3 with ORG_SELECTION_REQUIRED.

Agent instructions (the AGENTS.md block and capy help --json):

  • When a result carries an elicitation, put its display table in the reply, then ask with the agent's question tool, one question per field. Ask in chat only when there is no question tool.
  • Never pass --yes on its own.
  • To create or delete a project, run the command and let its elicitation ask.
  • PROJECT_DELETED means stop and point the human at capy project restore <id>. This concerns the folder's own project only, never a delete or restore asked for by name.
  • Before writing, check capy info --json. Stop on a browser sign-in. Look up a secret with capy secrets --json --name NAME.

capy agents writes both AGENTS.md and CLAUDE.md.

capy info --json reports project.state: live, deleted or unknown.

New codes:

  • Create: PROJECT_NAME_REQUIRED, PROJECT_NAME_INVALID, PROJECT_NAME_EXISTS, BRANCH_NAME_REQUIRED, BRANCH_NAME_INVALID, BRANCH_PROTECTION_REQUIRED, BRANCH_PROTECTION_INVALID, BRANCH_CREATE_FAILED
  • All three commands: ORG_SELECTION_REQUIRED

Checks

  • Typecheck is clean, and the full suite passes (3,194 tests).
  • In a test VM signed in to prod, fresh agent sessions had only the folder's AGENTS.md and CLAUDE.md, with no memory. In each run the agent ran the new command itself and let its elicitation ask, and it never tried --yes:
    • create: capy project create --json, and capy project create billing-api --branch staging --json, which then asked only the protected question
    • delete, with both the confirm and the pick-one elicitations
    • create again with the name of a deleted project
  • In the same VM the delete and restore round trip ran against prod. A delete went through only after a human yes. capy info --json then reported state: "deleted", and bare capy refused with the restore command.

All new user-facing wording is marked COPY-FLAG for review.

cvince added 24 commits November 8, 2026 17:24
…wser sign-in, and find secrets with capy secrets
…ng what a branch is

Agent mode: no name -> PROJECT_NAME_REQUIRED, name but no --branch -> BRANCH_NAME_REQUIRED; both exit 3 with one form asking for name and branch (branch default development, with a description). The branch name is checked against the service's rule first (BRANCH_NAME_INVALID). A project made without its branch is reported as BRANCH_CREATE_FAILED with the project.
…at matches nothing

delete-project / restore-project: a name several projects share now asks which one (terminal: arrow-key list; agent: PROJECT_AMBIGUOUS exit 3 with a pick-one elicitation, options labelled name, variable count and how long ago it was created). --yes never chooses. A name that matches no project is refused with PROJECT_NOT_FOUND before anything is read or asked; an id still goes to the service. The agent line for deleting by name now holds even when this folder's own project is deleted.
…ents writes both AGENTS.md and CLAUDE.md

The display table goes in the reply; the short question is asked as an elicitation with the agent's question tool (in chat only when there is none). capy agents now always writes the block to both AGENTS.md and CLAUDE.md, creating whichever is missing, since Claude Code reads CLAUDE.md.
… approved branch wording

Same yes/no as capy checkout -b, in the terminal and as an elicitation field (options yes/no, default no); --protected yes|no; BRANCH_PROTECTION_REQUIRED / BRANCH_PROTECTION_INVALID. Each elicitation field can carry its own question. Branch question and description use Vince's approved wording.
…eate-project|delete-project|restore-project

Never released (npm latest is 0.9.14), so no aliases. capy projects stays the listing command. org is back to switching organization only.
…ent mode for delete and restore; approved first-branch question in the terminal
@cvince cvince changed the title Project delete and create confirmations for agents capy project create, delete and restore, with agent questions Nov 10, 2026
@cvince
cvince merged commit 6a9a677 into main Nov 10, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant