npm package: @primeuicom/cli
Description: CLI utility for deploying PrimeUI exported projects to a local workspace.
Latest version: 1.1.11

# @primeuicom/cli

CLI utility for deploying PrimeUI exported projects to a local workspace.

## Requirements

- Node.js `>=18`
- `pnpm` recommended for local development

## Quick Start

```bash
npx @primeuicom/cli <api-key>
```

Skip git initialization and the initial commit:

```bash
npx @primeuicom/cli <api-key> --no-git
```

The command runs a fully autonomous flow:

1. Validates API key format.
2. Authenticates with PrimeUI API v1.
3. Triggers project export.
4. Downloads export ZIP archive.
5. Extracts files into `./<project-name-slug>`.
6. Installs project dependencies with detected package manager.

**Connect an existing project to PrimeUI:**

```bash
npx @primeuicom/cli <api-key> connect
```

For non-interactive usage, pass the AI preset explicitly:

```bash
npx @primeuicom/cli <api-key> connect --ai-preset codex
```

The command runs:

1. Validates API key format.
2. Authenticates with PrimeUI API v1.
3. Detects project/monorepo root
4. Request project info API endpoint
5. Ensures the root `.gitignore` ignores `.primeui/project.json` and `.primeui/temp/`
6. Generates config schema.
7. Applies the project-local AI setup to the connected target project.

```json
{
  "projectId": "project-id-from-primeui",
  "apiKey": "pui_xxxxxxxxxxxxxxxxxxxxxx",
  "targetProjectPath": "./"
}
```

- If `.primeui` already exists in current directory chain, command stops and asks to remove existing config manually before reconnect.
- In an interactive terminal, `connect` prompts for the AI preset when `--ai-preset` is omitted.
- In a non-interactive terminal, `connect` requires `--ai-preset <codex|claude|cursor>`.
- If the follow-up AI setup fails, the project still stays connected and the CLI tells you to rerun `ai-setup` explicitly.

**Pull a fresh export into an already connected local project:**

```bash
npx @primeuicom/cli pull
```

Optional API key override:

```bash
npx @primeuicom/cli <api-key> pull
```

The command runs:

1. Loads `.primeui/project.json` from the connected project.
2. Uses the stored API key unless you pass an explicit one.
3. Refuses to continue when `git status` is not clean.
4. Requires an explicit confirmation before rewriting files.
5. Creates a fresh PrimeUI export and downloads the ZIP archive.
6. Hard rewrites the configured target project path while preserving `.git`, `.primeui`, and `node_modules`.
7. Reinstalls dependencies with the detected package manager.
8. Creates a git commit with the refreshed export state when files changed.

- Passing an explicit API key also refreshes `.primeui/project.json` with the current project binding.
- If `.primeui/project.json` is missing in a clean exported project, `npx @primeuicom/cli <api-key> pull` recreates it before committing the refreshed state.
- If the repository looks like a monorepo and PrimeUI cannot recover the saved target path, run `connect` explicitly first so you can choose the correct project folder before `pull`.
- `pull` is intended for early-stage sync before heavy manual customization.
- `pull` is not a merge tool. Local files outside the preserved directories can be replaced or removed.

## Local development and testing

Configure these environment variables for local development:

- `PRIMEUI_API_BASE_URL`: PrimeUI API base URL (for example `http://localhost:3020` when testing against local Studio API).

### Publish

Publish flow includes:

1. Update the package version (usually a patch bump).
2. Publish with the `latest` tag:

```bash
npm publish --tag latest
```

## Credits

PrimeUI 2026