Custom URI scheme utilities (polyglot).
Project description
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. 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, andname=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.
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hop_top_cite-0.1.0.tar.gz.
File metadata
- Download URL: hop_top_cite-0.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f849df4d9b6577be865ed3933f763df53f5a4d8c54840d6f0e1a8c9186f3b43
|
|
| MD5 |
4b76be4ceaf2e1b5fd64f1e8fe82b7c5
|
|
| BLAKE2b-256 |
88f4a89510ae04cfd082f9438e9d6e35a2118beadd2121dac9e6af0a6c58ee64
|
File details
Details for the file hop_top_cite-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hop_top_cite-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
443efc9118d200e64cd2bc28642411663c62f5a46b89800134e53f9125a13afe
|
|
| MD5 |
8d2859d3d8119094c0e8efb7b9f10d59
|
|
| BLAKE2b-256 |
3c7b94125d6cbf74514c9f78d128a132bfcf90eea2a90a3a3c46223282b3272e
|