Library and CLI for the Sightmap spec — parse, validate, merge, match, explain, lint.
Project description
sightmap
Official Python SDK and CLI for the Sightmap spec — a YAML format that teaches agents how to see and use a web app's views, components, and API requests.
- Spec & docs: sightmap.org · github.com/sightmap/spec
- Package:
sightmapon PyPI - JavaScript/TypeScript SDK:
@sightmap/sightmap
pip install sightmap
CLI
sightmap validate [path] # default path: .sightmap
sightmap lint [path] [--strict] [--rules <list>]
sightmap match <url> [path] [--method <m>] [--require-view]
sightmap explain <query> [path] [--by name|path] [--type view|component|request] [--require-hit]
Every command supports --json for machine-readable output and --cwd <dir> for invocation from outside the project.
Examples
# Validate the schema of every YAML file under .sightmap/
$ sightmap validate
ok .sightmap/views.yaml
ok .sightmap/components.yaml
2 file(s) checked.
# Resolve everything an agent needs to drive the URL /list/abc123
$ sightmap match /list/abc123
view ListDetailScreen (route /list/*)
source app/list/[id].py
comp BottomTabBar global selector=[role="tablist"]
...
# Find every entry tied to a particular source file
$ sightmap explain 'app/views/home.py'
4 hit(s) for "app/views/home.py":
view Home matched_as=path src=app/views/home.py
component HomeHeader matched_as=path src=app/views/home.py
...
Exit codes
0— success1— logical failure (validation error,--strictwarning,--require-view/--require-hitmiss)2— usage error
--json envelope
Every command emits the same top-level shape so agents can dispatch on command:
{
"ok": true,
"command": "match",
"diagnostics": [],
"result": { "...": "command-specific" }
}
Inside result, fields use snake_case keys (Pythonic; the JS SDK uses camelCase).
Library
from sightmap import (
parse, validate, merge, load_directory,
match, explain, lint,
)
sightmap = load_directory(".sightmap")
r = match(sightmap, url="/search")
print(r.view.name if r.view else None, len(r.components))
hits = explain(sightmap, "src/components/foo.py")
issues = lint(sightmap, root=".")
parse() raises on invalid input; validate() returns a non-throwing Result. Downstream code should consume validate(), not parse(). parse() is sugar for end-user code that knows the input is valid.
For canonical spec semantics — schema fields, route glob syntax, scope rules, and the design rationale — see sightmap.org and spec/v1/schema.md in the spec repo.
Diagnostics
Lint and validate share a Diagnostic shape:
from sightmap import Diagnostic, Severity
# Diagnostic(severity, code, message, file=None, path=None, loc=None, source=None)
Codes are stable, kebab-case, and exported as constants:
| Code | Severity | Source |
|---|---|---|
parse-error |
error | parse / load_directory |
schema-validation-failed |
error | validate |
unknown-version |
error | validate |
merge-collision-view |
warning | merge / load_directory |
merge-collision-component |
warning | merge / load_directory |
duplicate-view-name |
warning | lint |
duplicate-route |
warning | lint |
route-shadowing |
warning | lint |
unknown-source |
warning | lint |
selector-syntax |
warning | lint |
Codes are stable across SDK versions and match the JS SDK's vocabulary so cross-SDK tooling that dispatches on code stays portable. The JSON shape inside result and the surface attribute names are translated to each language's idiom (snake_case here, camelCase in JS).
Project resources
Org-wide policy lives in adjacent repos:
sightmap/spec— spec source, governance, conformance fixturessightmap/.github— Code of Conduct, Security policy, Supportsightmap/sightmap-js— JavaScript/TypeScript SDK
Spec pin
This package vendors sightmap.schema.json from the spec repo at a specific SHA. See src/sightmap/vendored/SPEC-PIN.md for the current pin and bump procedure.
License
MIT — see 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 sightmap-0.2.0.tar.gz.
File metadata
- Download URL: sightmap-0.2.0.tar.gz
- Upload date:
- Size: 141.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d90f697a75ddbc7c30eb2c98029fdd6e31303ab427e5ee58b5ce52386a7e481
|
|
| MD5 |
6eee18b8966d76662e3375673bae5d5e
|
|
| BLAKE2b-256 |
f33cad5a6687aa235ddab1f210a7e6368c31e28c98834088a8f75acfa352ec43
|
File details
Details for the file sightmap-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sightmap-0.2.0-py3-none-any.whl
- Upload date:
- Size: 36.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0826817654b3543049232697aa359171d514a876ab6acea7bb27d864dde8496
|
|
| MD5 |
0dfb830407d1056ead72cdde4fd81fca
|
|
| BLAKE2b-256 |
a3cc2cd6ee02810c3d1d81cd503b362141db3ea054311677ccd6121798d1fc81
|