Metadata-Version: 2.5
Name: oscar-solidcraft
Version: 0.1.1
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's Assistant panel.**

**Current release: 0.1.1**

`oscar-solidcraft` is a small program that SolidCraft runs as an Agent Client Protocol (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://originshape.design); new accounts get trial credits.
- **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. For most users, installing the published package from PyPI is the recommended method. Use the cloned-repository instructions only for development or when you specifically need to work with the source code.

### Step 1 — Check and install `uv`

First, check whether `uv` is already installed:

    uv --version

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

**Windows (PowerShell):**

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

**macOS or Linux:**

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

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

    uv --version

### 1. Install from PyPI (recommended)

Install the published stable release of Oscar with:

    uv tool install oscar-solidcraft

Verify the installation:

    oscar-solidcraft --help
    oscar-solidcraft --version

Update a PyPI installation later with:

    uv tool upgrade oscar-solidcraft

The PyPI project page is [`oscar-solidcraft`](https://pypi.org/project/oscar-solidcraft/).

#### Configure the PyPI installation in SolidCraft (Windows)

After installing Oscar using `uv`, configure SolidCraft to launch the installed executable.

**Step 1 — Find the installed executable**

Open PowerShell and run:

    $uvBin = uv tool dir --bin
    $oscarExe = Join-Path $uvBin "oscar-solidcraft.exe"
    $oscarExe

Verify that the executable exists:

    Test-Path $oscarExe

The command should return `True`.

**Step 2 — Add Oscar to 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** | Full path stored in `$oscarExe` (or `oscar-solidcraft` if `uv`'s bin directory is on your `PATH`) |

5. Click **Add** or **Save**.
6. Find **Oscar** under the **Agents** section.
7. Click **Test** to verify that the agent starts. Before you have signed in, it reports `"Sign-in needed"`; that is expected.
8. Select the required permissions and save the settings.

**Step 3 — Connect Oscar**

1. Open the **Assistant** panel.
2. Select **Oscar** and click **Connect**.
3. Click **Sign in with OriginShape**.
4. Your browser opens on [originshape.design](https://originshape.design).
5. Approve the sign-in request. Once authenticated, the line under the **Connect** button shows `you@example.com · 42.5 credits`.

> **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](https://originshape.design) shows SolidCraft as **Running on this computer**, and the credits under the **Connect** button stay current.

> **Important:** If you upgrade Oscar later with `uv tool upgrade oscar-solidcraft`, restart or reconnect **Oscar** in SolidCraft after upgrading.

### 2. Install from a cloned repository (for development)

If you need to work with the source code instead of installing the published package, clone the GitHub repository.

For a stable source checkout, clone the `main` branch:

    git clone -b main https://github.com/Originshape/Oscar-solidcraft.git
    cd Oscar-solidcraft

Install Oscar:

    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:

    oscar-solidcraft --help
    oscar-solidcraft --version

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

    git pull
    uv tool install . --reinstall

Restart or reconnect Oscar in SolidCraft after updating.

---

## Run from a cloned repository

Developers can 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. The commands below use the stable `main` branch; use `develop` only when you intentionally need unreleased development changes.

### 1. Clone and install

Open PowerShell and run:

    git clone -b main https://github.com/Originshape/Oscar-solidcraft.git
    cd Oscar-solidcraft

Create a Python virtual environment:

    uv venv --python 3.10 .venv

Install Oscar and its development dependencies:

    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:

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

PowerShell displays the full executable path, for example:

    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:

    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:

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

For a tool installation, run:

    oscar-solidcraft --version

To run the automated tests for the editable installation:

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

### Updating an editable development installation

After pulling the latest changes from the repository, run:

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

Restart or reconnect Oscar in SolidCraft after updating.

---

## 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` \vert{} The file used by `file` (and by `auto` without a keychain). \vert{} \vert{} `OSCAR_LOG_LEVEL` \vert{} `info` \vert{} `debug`, `info`, `warning` or `error`. \vert{} \vert{} `BROWSER` \vert{} the system's \vert{} The command that opens the sign-in page (`\%s` is replaced by the address). \vert{} \vert{} `OSCAR_DOCTRINE` \vert{} `on` \vert{} `off` removes Oscar's built-in instructions block from the system prompt (baseline runs); any other value is ignored. \vert{} \vert{} `OSCAR_DOCTRINE_FILE` \vert{} the built-in text \vert{} 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). \vert{} \vert{} `OSCAR_MCP_ALL_TOOLS` \vert{} `on` \vert{} `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. \vert{}  ---  ## 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: 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

    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`:

    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`.
