Skip to main content

Universal safe-save for concurrent text files — let a user and one or more AI agents edit the same file together without lost updates.

Project description

cotype (CLI)

The Python implementation of the cotype CLI — universal safe-save for concurrent text files.

This is the package that gets installed by editor integrations and agent drivers. The full product story (use case, KB, ADRs) lives at the monorepo root.

Install

Requires Python ≥ 3.11 and POSIX diff3 (from diffutils).

# from the monorepo root
pip install -e cli/

# verify
cotype --help

Test

cd cli
pip install pytest
pytest -q

Layout

cli/
├── pyproject.toml
├── cotype/                  the package
│   ├── __main__.py         python -m cotype
│   ├── cli.py              argparse + dispatch + JSON envelope
│   ├── errors.py           stable error names + exit codes
│   ├── hash.py             SHA-256 of raw bytes (P5 byte-exact)
│   ├── paths.py            sidecar resolution; conflict-id validation
│   ├── lock.py             advisory flock on <sidecar>/lock
│   ├── atomic_write.py     tmp -> fsync -> rename -> fsync(parent)
│   ├── store.py            state.json read/write, base storage
│   ├── merge.py            POSIX diff3 -m wrapper
│   └── commands/
│       ├── init.py
│       ├── open_.py
│       ├── save.py
│       ├── status.py
│       ├── resolve.py
│       └── catbase.py
└── tests/                  84 pytest tests

Commands

cotype init    FILE [--json]
cotype open    FILE [--json]
cotype save    FILE --base-sha HASH [--actor ACTOR] [--json] < proposed
cotype status  FILE [--json]
cotype resolve FILE [--conflict-id ID | --use-merged] [--actor ACTOR] [--json]
cotype cat-base FILE [--base-sha HASH]

Full surface, exit codes, and stable error names: see ../README.md and ../kb/spec/.

Architecture in one paragraph

A small layered package: pure leaves (hash, paths, errors), I/O primitives (lock, atomic_write), persistence (store), the merge wrapper (merge), command implementations under commands/, and a single cli.py that wires argparse and the JSON envelope. Every mutating command holds an exclusive flock on <sidecar>/lock; every file replacement goes through the canonical tmp → fsync → rename → fsync(parent) sequence. 3-way merge invokes POSIX diff3 -m in subprocess (list form, never shell). All public functions are typed; files are under 200 lines; the test suite covers SPEC §14 conformance (T1–T10), every named property (P1–P15), security edges, and a threaded atomic-visibility smoke test.

For the "why" behind these choices: ../kb/architecture/decisions/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cotype-0.2.1.tar.gz (32.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cotype-0.2.1-py3-none-any.whl (23.5 kB view details)

Uploaded Python 3

File details

Details for the file cotype-0.2.1.tar.gz.

File metadata

  • Download URL: cotype-0.2.1.tar.gz
  • Upload date:
  • Size: 32.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cotype-0.2.1.tar.gz
Algorithm Hash digest
SHA256 d992305f82dd5d146e292cf645fd035000baa95a4603a6bd38ce384ea17a54d9
MD5 0559f7263259662552a9e70d83fef68d
BLAKE2b-256 fdf548063a88f4b5999138244c1bc6babd8b0958769d0d9dc629b737e22e6198

See more details on using hashes here.

Provenance

The following attestation bundles were made for cotype-0.2.1.tar.gz:

Publisher: publish.yml on yurug/cotype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cotype-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cotype-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cotype-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b78ef35c1c43e0acd1efddeb4e5bd6086afb7605994b300b5d8845dce2fbb039
MD5 85222ccb13af34c5331a3800db6299bd
BLAKE2b-256 1f9749f3da3f60a2179cfe821a88d1324af925fb4743ed3eefa6cc5cddc02856

See more details on using hashes here.

Provenance

The following attestation bundles were made for cotype-0.2.1-py3-none-any.whl:

Publisher: publish.yml on yurug/cotype

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page