# uip solution project

> `uip solution project` manages the **projects** listed inside a `.uipx` solution manifest — workflows, test cases, libraries, agents, Maestro flows, and apps. Three subcommands are available:

`uip solution project` manages the **projects** listed inside a `.uipx` solution manifest — workflows, test cases, libraries, agents, Maestro flows, and apps. Three subcommands are available:

| Subcommand | Purpose |
|---|---|
| [`add`](#uip-solution-project-add) | Register a project folder that already lives inside the solution directory. |
| [`import`](#uip-solution-project-import) | Copy an external project folder into the solution directory, then register it. |
| [`remove`](#uip-solution-project-remove) | Unregister a project from the `.uipx` (does not delete files on disk). |

All three subcommands operate on local files only; no authentication is required.

## Synopsis

```
uip solution project add <projectPath> [solutionFile]
uip solution project import --source <path> [--solutionFile <path>]
uip solution project remove <projectPath> [solutionFile]
```

Each subcommand honours the [global options](./global-options.md) and returns the [standard exit codes](./exit-codes.md).

## Common behaviour

- The target project folder must contain either a **`project.uiproj`** or a legacy **`project.json`** descriptor. The command auto-detects which one.
- When `<solutionFile>` is omitted, the command searches **upward** from the project path (or the current directory, for `import`) for the nearest `.uipx`. If none is found, or if multiple `.uipx` files live in the same folder, the command fails with a descriptive error and exits with `1`.
- A unique `Id` (UUID) is generated for each project entry added to the manifest.

---

## uip solution project add

Register a project folder that **already resides inside** the solution directory. The project folder's relative path is recorded in `.uipx`, and a matching entry is provisioned in the solution's internal resource builder.

### Arguments

- `<projectPath>` *(required)* — Path to the project folder. Must contain `project.uiproj` or `project.json`.
- `[solutionFile]` *(optional)* — Path to the `.uipx` solution manifest. If omitted, the nearest `.uipx` is located by walking up from `<projectPath>`.

### Options

None beyond the [global options](./global-options.md).

### Examples

#### Minimal

```bash
uip solution project add ./my-solution/my-project ./my-solution/my-solution.uipx
```

#### Auto-detect the `.uipx`

```bash
uip solution project add ./my-solution/my-project
```

#### Scripting — add, then pack in one pipeline

```bash
uip solution project add ./my-solution/my-project
uip solution pack ./my-solution ./dist --version 1.0.0
```

### Data shape (--output json)

```json
{
  "Code": "ProjectAdd",
  "Data": {
    "Status": "Added successfully",
    "Project": "my-project/project.uiproj",
    "Solution": "/workspace/my-solution/my-solution.uipx"
  }
}
```

### Failure modes

- **Project is outside the solution folder.** The command refuses the add with a pointer to `project import`, which copies external projects in.
- **Project is already registered.** Exits with `1` and a message naming the existing `ProjectRelativePath`.

---

## uip solution project import

Copy an **external** project folder into the solution directory (preserving its folder name), then register it in the `.uipx`. Use this when the project you want to include is not already under the solution root.

### Options

- `--source <path>` *(required)* — Path to the external project folder to import. Must be a directory containing `project.uiproj` or `project.json`.
- `--solutionFile <path>` *(optional)* — Path to the `.uipx` solution manifest. Defaults to the nearest `.uipx` found by walking up from the current working directory.

### Examples

#### Common

```bash
uip solution project import \
  --source ./external-project \
  --solutionFile ./my-solution/my-solution.uipx
```

#### From inside the solution directory (auto-detect `.uipx`)

```bash
cd ./my-solution
uip solution project import --source ../shared-library
```

### Data shape (--output json)

```json
{
  "Code": "ProjectImport",
  "Data": {
    "Status": "Imported successfully",
    "Project": "external-project/project.uiproj",
    "Solution": "/workspace/my-solution/my-solution.uipx"
  }
}
```

### Failure modes and rollback

- **Destination folder already exists.** The command refuses to overwrite; rename the source folder or remove the existing destination first.
- **Project already in the `.uipx` manifest.** Refused before any files are copied.
- **Copy, write, or builder step fails.** The command rolls back — the copied directory is removed and the `.uipx` is restored to its original content.

---

## uip solution project remove

Unregister a project from the `.uipx` solution manifest and drop its entry from the internal resource builder. **Files on disk are not deleted.**

### Arguments

- `<projectPath>` *(required)* — Path to the project folder to remove. Must currently be registered in the `.uipx`.
- `[solutionFile]` *(optional)* — Path to the `.uipx` solution manifest. Defaults to the nearest `.uipx` found by walking up from `<projectPath>`.

### Examples

#### Minimal

```bash
uip solution project remove ./my-solution/my-project ./my-solution/my-solution.uipx
```

#### Scripting — remove multiple projects

```bash
for p in project-a project-b project-c; do
  uip solution project remove "./my-solution/$p" || true
done
```

### Data shape (--output json)

```json
{
  "Code": "ProjectRemove",
  "Data": {
    "Status": "Removed successfully",
    "Project": "my-project",
    "Solution": "/workspace/my-solution/my-solution.uipx"
  }
}
```

### Failure modes

- **Project is outside the solution folder.** The relative path must not start with `..`.
- **Project is not in the manifest.** Exits with `1` and the relative path used to search.

---

## Related commands

- [`uip solution new`](./uip-solution-new.md) — scaffold the solution before adding projects.
- [`uip solution resource refresh`](./uip-solution-resource.md) — re-sync resources after editing project bindings.
- [`uip solution pack`](./uip-solution-pack.md) — package the solution once its project list is finalized.

## See also

- [Your first pipeline](./first-pipeline.md) — end-to-end example.
- [`uip solution` overview](./uip-solution.md).
