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.0a1.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.0a1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hop_top_uri-0.2.0a1.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.0a1.tar.gz
Algorithm Hash digest
SHA256 d3c84e4cd5bb12afa92bd10dc4581f1c67ed33fe52388bee478d0e111a45726f
MD5 19d736e6488bb6c783cbcfd04e85a1f3
BLAKE2b-256 c0db81bf64e02fd68fba66481d72f51a67406f3118d7b5633e6e002b834e9c49

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hop_top_uri-0.2.0a1-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.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 91cfbb907fcad23d9b68365270409333e1a20bd943afdb534655aab28443fae2
MD5 94d06d71eba619b32465f303ba7521df
BLAKE2b-256 45a51c74326b0777dae505b6a5c9df56e4cf5a951f7e37bc94f0438d54962123

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