Skip to main content

cite (py)

Python implementation of cite, the polyglot custom URI parsing and handler-generation contract for app frameworks, CLIs, and agent-assisted tools.

This repository is a read-only language mirror, republished from the hop-top/poly-cite monorepo on each release. Open issues and pull requests in hop-top/poly-cite.

Features

  • Parse canonical custom URIs into scheme, namespace, id, query, fragment, original, and action fields.
  • Apply configurable namespace policies per scheme.
  • Resolve vanity aliases, fuzzy vanity matches, and completion candidates.
  • Normalize action queries such as action=task.claim, cmd=task&verb=claim, and name=task&action=claim.
  • Resolve action routes to command plans without executing them.
  • Register URI types with parsers and completers.
  • Generate language-scoped handler artifacts for Linux, macOS/iOS, and Windows. (guide)
  • Validate behavior against shared polyglot contract fixtures.

Usage

Agent instructions:
Install this Python package as `hop-top-cite` from PyPI when published, or use
the local py/ package while working inside poly-cite. Import from cite.
For usage docs and contract details, read
https://github.com/hop-top/poly-cite/tree/main/docs and
https://github.com/hop-top/poly-cite/tree/main/spec.

App Authors

Use this package when your app needs stable custom URI identity, vanity links, completion candidates, or handler artifacts.

Basic parsing:

from cite import parse

parsed = parse("task://hop-top/cite/T-0001")
print(parsed.namespace)  # hop-top/cite
print(parsed.id)  # T-0001

Action routing:

from cite import ActionRoute, Policy, parse, resolve_action

policy = Policy(
    default_namespace_segments=1,
    scheme_namespace_segments={"tlc": 2},
    action_routes={
        "task.claim": ActionRoute(
            command="tlc",
            args=["-C", "{namespace}", "task", "claim", "{id}"],
        )
    },
)

parsed = parse("tlc://org/repo/T-0001?name=task&action=claim", policy)
plan = resolve_action(parsed, policy)
print(plan.args)  # ["-C", "org/repo", "task", "claim", "T-0001"]

Advanced vanity alias:

from cite import Policy, VanityAlias, parse

parsed = parse(
    "task://shortcut/child",
    Policy(
        default_namespace_segments=1,
        scheme_namespace_segments={"task": 2},
        vanity_aliases=[
            VanityAlias(
                from_="task://shortcut",
                to="task://hop-top/cite/T-0001",
                prefix=True,
                preserve_suffix=True,
            )
        ],
    ),
)

print(parsed.canonical())  # task://hop-top/cite/T-0001/child

API docs: docs/specs and spec/fixtures.

License

MIT. See the hop-top/poly-cite LICENSE.

Metadata

Release files for hop-top-cite 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hop-top-cite 0.1.1
File Size Uploaded
hop_top_cite-0.1.1.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hop-top-cite 0.1.1
File Interpreter ABI Platform
hop_top_cite-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.7 kB

Release files / hop_top_cite-0.1.1.tar.gz

Download URL hop_top_cite-0.1.1.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4e28e37adb6ba35a4db8c024d7dfacba144c59a3c4bfe3da91dc9bb50d9f96b8
BLAKE2b-256 checksum
How to use checksums
b7021fc3b7af741b0335825e1f74447a5876c27e396a993a3926e2946c93ce54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / hop_top_cite-0.1.1-py3-none-any.whl

Download URL hop_top_cite-0.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f6df1699501221e02d0e300e2361b63851a83072459ca67f695f044719b86a8
BLAKE2b-256 checksum
How to use checksums
b10f338460c1054482a9272eceac19573061f848516f3bf8408dc6d0f14d39f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page