Skip to main content

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.

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]
sightmap fmt [path] [--check | --write]
sightmap check [path] [--strict]

sightmap fmt [PATH] [--check | --write]

Canonical YAML formatter for .sightmap/*.yaml. Idempotent. Validates against schema before formatting; refuses to rewrite parse-invalid or schema-invalid input. See authoring-conventions.md for the rules.

  • --check (default): exit non-zero if any file is not canonical; print unified diff. Suitable for CI.
  • --write: rewrite files in place, atomically.

sightmap check [PATH] [--strict]

Composite CI gate: runs validate and fmt --check in one pass.

  • Default: errors fail; warnings reported but exit 0.
  • --strict: warnings also fail. Recommended for CI on protected branches.

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 — success
  • 1 — logical failure (validation error, --strict warning, --require-view/--require-hit miss)
  • 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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sightmap-0.3.0.tar.gz (150.5 kB view details)

Uploaded Source

Built Distribution

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

sightmap-0.3.0-py3-none-any.whl (48.8 kB view details)

Uploaded Python 3

File details

Details for the file sightmap-0.3.0.tar.gz.

File metadata

  • Download URL: sightmap-0.3.0.tar.gz
  • Upload date:
  • Size: 150.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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

Hashes for sightmap-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f2927202f8b3f1cda04657357df7c91c4164209f02bd502be4d84ea232d1fbbb
MD5 386790af5e2eac827ed4dc8bab23f19e
BLAKE2b-256 b4b5bd3f7d47716483d12a22ecb4b87d2d1dc270b2d717ee82dc0662102fd2a0

See more details on using hashes here.

File details

Details for the file sightmap-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: sightmap-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 48.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","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

Hashes for sightmap-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 98fcb2f75ed077a86ddc050531ee438b4b1df392c6cc24a920892d0380ea3860
MD5 e4b99aa1370537d0f28c4c32300ff8eb
BLAKE2b-256 48888226043d3e52c2f076016c7a6e9c8820de281d86279c78c98ef01eda5231

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