# Install and update op-sys

Use the installer supplied by your installation operator on supported macOS
arm64 systems, or install from the supplied runtime source package.
Local use requires no Cloud account; shared work uses your service address.

The installation commands below run in the runtime source directory.
Package installation and ledger data are separate: updating or removing the
package must not remove the records you keep.

The macOS arm64 installer includes its Python runtime. It requires no source
checkout, existing Python, or virtual environment. It uses the ordinary
`install.sh` entry point; users do not choose a separate bundled-install mode.



## One-command installation (macOS arm64)

Use the trusted installer address supplied by your installation operator. For
example, replacing the illustrative host below with that address:

```sh
curl -fsSL https://your-installation.example/install.sh | sh
```

The installer downloads and checks its pinned runtime, verifies the signed
application, and installs under your account without administrator privileges.
It does not require cloud setup or upload records. Optional search models are
not needed for the first local record.

Use the absolute `op-sys` executable path printed at completion immediately,
including from an already-running agent. The installer also configures supported
shells for future terminals. From your project, run the executable to start
locally; ask your agent to discover the public capabilities and inspect the
ledger's rules before acting. No agent registration, provider change, or skill
installation is required.

Rerun the same installation command to update while preserving records and
configuration. This path currently targets macOS arm64; other runtime bundles
need their own native verification before being offered.

## Install from source

You need Git and Python 3.11 or newer with `venv` and `pip`. Building the package
fetches the pinned build dependencies from the configured Python package index;
op-sys has no external runtime dependencies. A source install trusts the selected
checkout; it does not carry managed-release signature verification.

macOS / Linux:

```bash
cd /path/to/op-sys
python3 -m venv .venv
. .venv/bin/activate
python -m pip install .
op-sys self version
```

Use the source package provided for your installation. If Python reports that
`venv` or `ensurepip` is missing, install your operating system's Python venv
package, then repeat environment creation.

Windows PowerShell:

```powershell
cd /path/to/op-sys
py -3 -m venv .venv
.\.venv\Scripts\python.exe -m pip install .
.\.venv\Scripts\op-sys.exe self version
```

Activation is optional. On PowerShell, `.\.venv\Scripts\Activate.ps1` makes
`python` and `op-sys` available for that session if the shell permits it.
Otherwise keep using their full paths. Do not change your execution policy just
to install op-sys.

In a new terminal, activate the same environment again, or use its executable's
absolute path. POSIX activation is `. /absolute/path/to/op-sys/.venv/bin/activate`.
Do not move the virtual environment after creating it; recreate it at its new
location instead. No shell startup file is edited automatically.

## Start locally

Change to the project you want to work in, then run:

```bash
op-sys
op-sys records append --operation-id first-record --payload '{"message":"My first record"}'
op-sys records list
```

Bare `op-sys` prepares local use without prompts or an account. Inside a Git
repository, state defaults to that repository's `.op-sys` directory; outside one,
it uses user-scoped state. `op-sys where` reports the resolved location.
`op-sys start` explicitly opens the optional service chooser in a terminal.
Automated clients use `op-sys --output json start` without prompts.
Installation itself creates no ledger and connects to no op-sys server.

Your existing local agent can use the installed CLI directly. Tell it:

> Use op-sys to record this project's decisions and work. Inspect the existing
> ledgers and their rules first. Keep everything local for now.

No agent registration, MCP configuration or skill package is required. Ensure
the executable is available in the agent's shell, or give it the full executable
path printed during installation. The [agent getting-started guide](/docs/raw/manuals/agent-getting-started.md)
covers capability discovery, ledger contracts, retries and later shared access.

When ready for shared work, run `op-sys ledgers publish --endpoint <service-url>`.
Interactive use guides sign-in and organization selection, then publishes the
ledger, remembers its remote and retains the local copy. Later run `op-sys ledgers
sync` to exchange contributions and history. Another authorized participant can
run `op-sys ledgers clone "<ledger-url>"` using the URL returned by publishing.
See the [local-to-shared quickstart](/docs/raw/manuals/ledger-quickstart.md) for progress, permissions
and the advanced option to retain local authority. Use your workspace operator's service address.

## Optional SDK and MCP integration

The same installed package supplies all three surfaces. In the environment:

```python
from op_sys import OpSys

client = OpSys(state_root="/absolute/path/to/my-ledger")
client.start()
client.records.append(payload={"message": "Recorded from the SDK"})
```

For an MCP client, run
`op-sys mcp config --command /absolute/path/to/op-sys/.venv/bin/op-sys`
from the desired project and use the returned configuration. On Windows, use
the absolute `.venv\Scripts\op-sys.exe` path instead. `op-sys mcp serve` provides the stdio server. Ensure the
MCP client can execute the installed op-sys path even when it does not inherit
your terminal's activated environment. See [public capabilities](/docs/raw/manuals/public-capabilities.md).

## Shell completion

Completion is optional and performs no network or ledger lookup. For Bash or Zsh,
locate the generated file with the Python interpreter from the same installation:

```sh
python -c 'from importlib.resources import files; print(files("op_sys.contracts").joinpath("ledger-core.completion.sh"))'
source /printed/path/ledger-core.completion.sh
```

Use that exact path in your shell startup file if you want completion each session.
No setup command silently edits your shell configuration to enable completion.
The generated file covers enabled ledger-core command groups and flags; it does
not enumerate private ledger names or replace command help.

## Update a source installation

Stop long-running op-sys/MCP processes before updating. In the same source
checkout and activated environment, obtain the intended newer revision and run:

```bash
python -m pip install --upgrade .
op-sys self version
```

For Windows without activation, use `.\.venv\Scripts\python.exe -m pip`
and `.\.venv\Scripts\op-sys.exe` instead. Restart MCP clients after updating.
The package command installs the source directory on disk, including any local edits.

The virtual environment is separate from ledger state. Reinstalling the package
does not remove records. Database migrations are forward-only; before updating
valuable state, use the [backup and migration procedures](/docs/raw/manuals/self-hosting.md).
Do not downgrade a database by reinstalling an older application version.

`op-sys self update` applies only to managed signed releases. A Python package
installation is updated with the package manager above; its version information
currently reports `execution_mode: source` and `installed: false`, where
`installed` specifically means managed-runtime installation.

## Remove a source installation

In the environment, run `python -m pip uninstall op-sys` (or use its full Python
path). This removes the package and command, leaving ledger state in place.
Inspect `op-sys where` before uninstalling if you need to locate that state.
`op-sys self uninstall` is reserved for managed releases.

## Managed runtime operations

Managed installs carry a locally generated identity in private installation
metadata. The launcher-provided `OP_SYS_INSTALL_ROOT` value is only a
compatibility hint; update and uninstall derive the runtime root from the
executing managed layout and reject a different hint.

Inspect uninstall eligibility without changing files:

```bash
op-sys self uninstall --dry-run
```

`op-sys self uninstall --yes` schedules removal only after the marker,
installation ID, current version, launcher, Python, install scripts, shims,
path containment, and resolved state-root separation all validate. Ledger
state is outside the managed runtime and is never part of uninstall. The
scheduled response includes a private `removal_receipt` path; that value-free
file is created only if detached removal fails and normally disappears with
the helper directory after success. Legacy
installs without a valid managed marker are not eligible for automated
uninstall; install into a fresh prefix and review any old prefix manually.
Managed update/uninstall also require an authoritative external Python and
native-loader closure; the trusted-account/platform-admin boundary is defined
in [SECURITY.md](/docs/raw/manuals/self-hosting.md). Windows managed-runtime
operations currently require unpackaged Python and NTFS for every
identity-bearing runtime, helper, interpreter, source, and protected-root path;
this does not globally restrict ordinary state storage.
