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.0.tar.gz (30.4 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.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cotype-0.2.0.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for cotype-0.2.0.tar.gz
Algorithm Hash digest
SHA256 594261669413cf0cdac0c7f3bcec7a3883857fa7cbcd329e25ebdeb7f52f0703
MD5 a526a490b99ba9a5e827d96d4f035fc7
BLAKE2b-256 56184f48184d022e4e9381826d79831072a7756b4e3929993f8206df1666457f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cotype-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for cotype-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1f8999012dc6be52048afdc7f5d3c94dc162c9b942e52727000d1727e166cdb
MD5 05db9ee75b8490d47a43556c521d4cd8
BLAKE2b-256 2b81983b204dcab9f241b1add48af662a452a3af874a65954428e62d6be466e6

See more details on using hashes here.

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