Skip to main content

Custom URI scheme utilities (polyglot).

Project description

uri

Python implementation of uri, 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/uri-poly.

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.
  • Validate behavior against shared polyglot contract fixtures.

Usage

Agent instructions:
Install this Python package as `hop-top-uri` from PyPI when published, or use
the local py/ package while working inside uri-poly. Import from uri.
For usage docs and contract details, read
https://github.com/hop-top/uri-poly/tree/main/docs and
https://github.com/hop-top/uri-poly/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 uri import parse

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

Action routing:

from uri 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 uri 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/uri/T-0001",
                prefix=True,
                preserve_suffix=True,
            )
        ],
    ),
)

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

API docs: docs/specs and spec/fixtures.

License

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

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

hop_top_uri-0.2.0a2.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

hop_top_uri-0.2.0a2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file hop_top_uri-0.2.0a2.tar.gz.

File metadata

  • Download URL: hop_top_uri-0.2.0a2.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for hop_top_uri-0.2.0a2.tar.gz
Algorithm Hash digest
SHA256 fce5b0392f65b3b1bb54e423a5c2da707f55ffb3d2eb3f936ccd5eaae0e740ba
MD5 4c34d12a8e543752e31443db85092ac3
BLAKE2b-256 107b51a388fc15d31df105d620bbc39c11f5d5e140ef7a2cba1a4429ca31c9fa

See more details on using hashes here.

File details

Details for the file hop_top_uri-0.2.0a2-py3-none-any.whl.

File metadata

  • Download URL: hop_top_uri-0.2.0a2-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

Hashes for hop_top_uri-0.2.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 b2c06f692d57a8f4db33ab6455913c264632cf04f51e80d95e0c74f3d81aa669
MD5 384500fd310bfce2fe7729c13821bc98
BLAKE2b-256 589ec5ccf28ce32fdce7ffdf4a17168fe560d4f2da67f0d2c41cdf9c8fcc151d

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