Metadata-Version: 2.5
Name: oscar-solidcraft
Version: 0.1.0
Summary: Oscar for SolidCraft: OriginShape's CAD assistant as an Agent Client Protocol agent for SolidCraft
Project-URL: Homepage, https://originshape.design
Project-URL: Source, https://github.com/Originshape/oscar-solidcraft
Author-email: OriginShape <hello@originshape.design>
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: acp,agent-client-protocol,cad,mcp,originshape,solidcraft
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Manufacturing
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: requests<3,>=2.32.4
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == 'dev'
Description-Content-Type: text/markdown


# Oscar for SolidCraft

Oscar from OriginShape, in [SolidCraft](https://solidcraft.io)'s Assistant panel.

`oscar-solidcraft` is a small program that SolidCraft runs as an [Agent Client Protocol](https://agentclientprotocol.com) (ACP) agent. It signs you in to your OriginShape account in the browser, sends your messages to OriginShape's model service (which bills your OriginShape credits), and builds the design with SolidCraft's own tools (`batch`, `execute`, `measure`, `screenshot` …). Oscar's CAD know-how lives on OriginShape's server, so Oscar gets better with a server update; this program only connects the pieces.

## Requirements

- SolidCraft **0.53.0 or newer**.
- An OriginShape account. Sign-in happens on [originshape.design](https://app.originshape.design); new accounts get trial credits.
- [uv](https://docs.astral.sh/uv/) to install it (uv brings its own Python; otherwise Python 3.10 or newer).
- Git, if you are installing from the cloned repository.

## Install

Before installing Oscar, make sure `uv` is available. The PyPI installation is listed first for users who want the simplest installation. **The package is not yet published on PyPI**, so use the cloned-repository method until publication.

### Step 1 — Check and install uv

First, check whether uv is already installed:

```sh
uv --version
```

If the command is not found, install uv using the instructions for your operating system.

**Windows (PowerShell):**

```powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
```

**macOS or Linux:**

```sh
curl -LsSf https://astral.sh/uv/install.sh | sh
```

After installation, open a new terminal and verify that uv is available:

```sh
uv --version
```

### 1. Install from PyPI (available after publication)

Once the package is published to PyPI, install Oscar with:

```sh
uv tool install oscar-solidcraft
```

Verify the installation:

```sh
oscar-solidcraft --help
oscar-solidcraft --version
```

Update a PyPI installation later with:

```sh
uv tool upgrade oscar-solidcraft
```

The project page will be `https://pypi.org/project/oscar-solidcraft/`.

### 2. Install from a cloned repository (works today)

Until the package is published on PyPI, install Oscar from its GitHub repository.

Clone the `develop` branch, which contains the current installation and compatibility updates:

```sh
git clone -b develop https://github.com/Originshape/Oscar-solidcraft.git
cd Oscar-solidcraft
```

Install Oscar:

```sh
uv tool install .
```

uv builds the package and installs it as an isolated tool with its own Python environment — no virtual environment to create or activate.

Verify the installation:

```sh
oscar-solidcraft --help
oscar-solidcraft --version
```

To update this installation later, run these commands from the cloned repository:

```sh
git pull
uv tool install . --reinstall
```

Restart or reconnect Oscar in SolidCraft after updating.

### Run from a cloned repository

Developers can also run Oscar directly from a local clone of the repository without installing it as an isolated tool. This editable installation is intended for development and testing.

#### 1. Clone and install

Open PowerShell and run:

```powershell
git clone -b develop https://github.com/Originshape/Oscar-solidcraft.git
cd Oscar-solidcraft
```

Create a Python virtual environment:

```powershell
uv venv --python 3.10 .venv
```

Install Oscar and its development dependencies:

```powershell
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"
```

The `-e` option installs the project in editable mode. Changes to the local source code are available without reinstalling the package.

#### 2. Configure Oscar in SolidCraft

1. Open **SolidCraft → Preferences → Assistant**.
2. Select **Add agent**.
3. Choose **Custom command**.
4. Enter the following details:

| Field         | Value |
| ------------- | ----- |
| Kind          | Custom command |
| Name          | Oscar |
| Agent command | `oscar-solidcraft` for a tool installation; full path to `oscar-solidcraft.exe` for an editable installation |

#### 3. Find the Agent command

For an editable installation, SolidCraft requires the full absolute path to Oscar's executable. For a tool installation, enter `oscar-solidcraft`.

**Method 1: Using PowerShell (recommended)**

Open PowerShell in your cloned repository directory and run:

```powershell
Resolve-Path .\.venv\Scripts\oscar-solidcraft.exe
```

PowerShell displays the full executable path, for example:

```text
C:\Users\YourName\Oscar-solidcraft\.venv\Scripts\oscar-solidcraft.exe
```

Copy the resulting path and paste it into SolidCraft's **Agent command** field.

**Method 2: Using File Explorer**

1. Open your cloned `Oscar-solidcraft` repository.
2. Open the `.venv` folder.
3. Open the `Scripts` folder.
4. Find `oscar-solidcraft.exe`.
5. Right-click the executable and select **Copy as path**.
6. Paste the copied path into SolidCraft's **Agent command** field.

**Verify that the executable exists:**

```powershell
Test-Path .\.venv\Scripts\oscar-solidcraft.exe
```

The command should return `True`.

If it returns `False`, check that the installation completed successfully.

#### 4. Add and connect Oscar

1. Click **Add** or **Save** in the Add Agent dialog.
2. Find Oscar under the **Agents** section.
3. Click **Test** to verify that the agent starts successfully.
4. Select the required permissions.
5. Click **OK** to save your settings.
6. Open the **Assistant** panel.
7. Select Oscar and press **Connect**.
8. Press **Sign in with OriginShape**.
9. Your browser opens on originshape.design. Approve the sign-in request.

Once authenticated, Oscar is ready to use.

The line under the Connect button shows your signed-in account and available credits, like `you@example.com · 42.5 credits`.

**Important:** For an editable installation, use the full absolute path to `oscar-solidcraft.exe`. Do not enter just the repository directory or the Python interpreter path. For a tool installation, enter `oscar-solidcraft`.

#### 5. Verify the installation

For an editable installation, run the following command from the repository directory:

```powershell
.\.venv\Scripts\oscar-solidcraft.exe --version
```

For a tool installation, run:

```powershell
oscar-solidcraft --version
```

To run the automated tests for the editable installation:

```powershell
.\.venv\Scripts\python.exe -m pytest
```

#### Updating a local installation

After pulling the latest changes from the repository, run:

```powershell
git pull
uv pip install --python .venv\Scripts\python.exe -e ".[dev]"
```

Restart or reconnect Oscar in SolidCraft after updating.

## Add it to SolidCraft

For users who installed Oscar using `uv tool install .`:

1. Open **Preferences → AI → Add agent → Custom command**, and enter `oscar-solidcraft`.
2. Press **Test**. Before you have signed in it reports "Sign-in needed"; that is expected.
3. Open the **Assistant** panel, pick Oscar and press **Connect**.
4. Press **Sign in with OriginShape**. Your browser opens on originshape.design; approve there, and the panel is ready. The line under the Connect button then shows `you@example.com · 42.5 credits`.

For an editable installation, use the full path to `.venv\Scripts\oscar-solidcraft.exe` as the Custom command instead.

No browser on this computer? Choose **OriginShape with a code** instead: SolidCraft shows a command to copy. Run it (`oscar-solidcraft login --device`) in a terminal, enter the code it prints on any device, then press **I've signed in: connect again**.

Pick **Origin1** or **Origin1 Super** in the panel's model menu. Each design tab runs its own Oscar; they share one sign-in.

While Oscar is connected, the **Integrations** page on originshape.design shows SolidCraft as **Running** on this computer, and the credits under the Connect button stay current.

## Commands

| Command | What it does |
| ------- | ------------ |
| `oscar-solidcraft` | Runs the agent on stdin/stdout. SolidCraft starts it; you don't run it yourself. |
| `oscar-solidcraft login` | Signs in with your browser. |
| `oscar-solidcraft login --device` | Signs in with a code, for a computer without a browser. |
| `oscar-solidcraft login --api-url URL` | Signs in to another OriginShape server and keeps using it (saved). It warns you first: that server receives your messages and design pictures. |
| `oscar-solidcraft logout` | Signs out on this computer and revokes the sign-in. |
| `oscar-solidcraft status` | Who is signed in, credits, the server, where the sign-in is kept, and the log folder. Exits with code 1 when you are not signed in (0 otherwise), so scripts can check the state. |
| `oscar-solidcraft --version` | Prints the version. |

You can also sign Oscar out from the website: **Settings → Devices**, then revoke the app.

## Environment variables

| Variable | Default | Meaning |
| -------- | ------- | ------- |
| `OSCAR_API_URL` | `https://app.originshape.design` | The OriginShape server (wins over `login --api-url`). Any other server is named in the line under SolidCraft's Connect button. |
| `ORIGINSHAPE_HOME` | `~/.originshape` | Oscar keeps its files in `$ORIGINSHAPE_HOME/oscar-solidcraft/`. |
| `OSCAR_CREDENTIAL_STORE` | `auto` | Where the sign-in is kept: `auto` (the system keychain, else a file), `keychain`, `file` or `memory`. |
| `OSCAR_CREDENTIAL_FILE` | `$ORIGINSHAPE_HOME/oscar-solidcraft/credentials.json` | The file used by `file` (and by `auto` without a keychain). |
| `OSCAR_LOG_LEVEL` | `info` | `debug`, `info`, `warning` or `error`. |
| `BROWSER` | the system's | The command that opens the sign-in page (`%s` is replaced by the address). |
| `OSCAR_DOCTRINE` | `on` | `off` removes Oscar's built-in instructions block from the system prompt (baseline runs); any other value is ignored. |
| `OSCAR_DOCTRINE_FILE` | the built-in text | A path to a file that replaces the built-in instructions block. Read once per run; a missing or unreadable file leaves Oscar without the block (a warning is logged). |
| `OSCAR_MCP_ALL_TOOLS` | `on` | `off`, `0`, `false` or `no` stops Oscar from turning SolidCraft's all-tools switch on for the tool server it starts, leaving that server's default (the eight core tools). A `SOLIDCRAFT_MCP_ALL_TOOLS` value set by SolidCraft or by you always wins over Oscar's default. |

## Files

Everything lives in `$ORIGINSHAPE_HOME/oscar-solidcraft/`, a folder only you can read:

- `signed-in.json`: the server and the time you signed in (never a secret, no email), so SolidCraft can show "login found".
- `credentials.json`: the sign-in, only when no system keychain could be used (readable by you only).
- `settings.json`: the server chosen with `login --api-url`.
- `logs/oscar.log`: what Oscar did (events, sizes and outcomes; never your messages or keys, and tokens, email addresses and your home folder are scrubbed from every line). It rotates at 5 MB. `logs/mcp-*.log` holds what SolidCraft's tool server printed.

On macOS the sign-in is in your login keychain as **Oscar for SolidCraft**; on Windows in Credential Manager; on Linux in the Secret Service keyring when one runs.

## Troubleshooting

- **"Sign-in needed" in Test.** Normal before the first sign-in. Connect in the Assistant panel and sign in.
- **The browser didn't open.** Use **OriginShape with a code**, or run `oscar-solidcraft login` in a terminal (it prints the link), then press **I've signed in: connect again**.
- **"You're out of OriginShape credits."** Add credits on the billing page the message links to.
- **"Your OriginShape account is waiting for approval."** You'll get an email once it's approved.
- **"This version of Oscar for SolidCraft is too old."** From a cloned-repository installation: run `git pull` and reinstall (see [Install](#install)), then Connect again. From a PyPI installation (after publication): run `uv tool upgrade oscar-solidcraft`, then Connect again.
- **"Oscar stopped here: …"** Oscar ends a message that asks SolidCraft the same thing a third time without the design changing, or that has used 200,000 output tokens, so a runaway message cannot spend your credits. Send another message to go on.
- **"This message is too large to send."** A message may carry 100 parts, pictures up to 10 MB and PDFs up to 16 MB, 24 MB in all. Attach fewer or smaller files.
- **"SolidCraft's tools could not be started."** Press Connect again. If it persists, check SolidCraft's AI settings (its tool bridge must be on) and `logs/mcp-*.log`.
- **"SolidCraft can't find the command."** For a tool installation, run `uv tool update-shell`, or enter the full path that `where oscar-solidcraft` (Windows) or `which oscar-solidcraft` (macOS/Linux) prints. For an editable clone, enter the full path to `.venv\Scripts\oscar-solidcraft.exe`.
- **Anything else.** `oscar-solidcraft status` shows the state and `logs/oscar.log` what happened. SolidCraft shows the last lines Oscar wrote to stderr when it stops.

## What data goes where

- **Your messages, the pictures and PDFs you attach, the view picture SolidCraft attaches, and the results of SolidCraft's tools** (including screenshots of your design) are sent to OriginShape's model service, which adds Oscar's instructions and forwards them to the model provider (Anthropic) to produce the answer. Credentials found in that text are replaced with `[redacted credential]` before anything is sent.
- **Your OriginShape sign-in** goes only to OriginShape's server. SolidCraft never sees it, and it is never written to the log or to stderr.
- **Your design** stays in SolidCraft. Oscar sees only what SolidCraft's tools return during a message you sent.
- **Oscar's reasoning:** the panel shows short summaries of it (dimmed), not the model's full reasoning.
- OriginShape records usage (model, token counts, credits) per request, as on the website. See OriginShape's privacy policy for how long data is kept.

`SECURITY.md` says what Oscar stores and sends in more detail, and how to report a security problem.

## Development

```sh
uv venv --python 3.10 .venv
uv pip install --python .venv/bin/python -e '.[dev]'
.venv/bin/python -m pytest
```

The tests never touch your keychain, your `~/.originshape` or a real OriginShape server: they run against a fake OriginShape (OAuth, account, model list, and a gateway that behaves like the real one, Oscar's prompt included) and a fake SolidCraft tool server, and they drive `python -m oscar_solidcraft` over stdio the way SolidCraft does.

One test uses the real SolidCraft engine. It builds and measures a box with `solidcraft-cli mcp --headless`:

```sh
SOLIDCRAFT_CLI=/path/to/solidcraft-cli .venv/bin/python -m pytest tests/test_solidcraft_real.py
```

`docs/architecture.md` explains how the program is put together, what it expects from SolidCraft and from the OriginShape server, and the limits it puts on everything it receives.

## License

Apache-2.0. See `LICENSE` and `NOTICE`.
