Python parser for scry-spec v1.0 markers
Project description
scry-parse
Python parser for the scry-spec marker format. Conformant with scry-spec v1.0.3.
Install
uv pip install scry-parse
# or:
pip install scry-parse
Usage
from scry_parse import (
parse_markers,
validate_marker,
check_cycles,
mint_id,
BASELINE_KINDS,
BASELINE_STATUSES,
)
# Parse markers from file content
with open("my_file.md") as f:
content = f.read()
result = parse_markers(content)
# Access by type
for entry in result.entries:
print(entry.id, entry.kind, entry.summary)
for anchor in result.anchors:
print(anchor.name, anchor.description)
for binding in result.bindings:
print(binding.local_id, binding.ref)
# Or iterate all markers together
for marker in result.markers:
print(type(marker).__name__, marker)
# Validate a parsed marker
vr = validate_marker(result.entries[0])
if not vr.valid:
print(vr.errors)
if vr.warnings:
print(vr.warnings)
# Detect cycles in depends_on relationships (FR12)
cycle_errors = check_cycles(result.entries)
if cycle_errors:
for err in cycle_errors:
print(err) # "cycle detected: design.a~... → design.b~... → design.a~..."
# Generate a new marker ID
entry_id = mint_id("design", "auth-flow") # random hash
entry_id = mint_id("design", "auth-flow", content) # deterministic hash from content
Supported comment styles
Comment-prefix detection is automatic via YAML-key inference — no language hint required.
Line comments
| Style | Example |
|---|---|
| HTML/Markdown | <!-- @scry.entry ... @scry.entry.end --> |
| Python/Shell | # @scry.entry ... # @scry.entry.end |
| TypeScript/JS | // @scry.entry ... // @scry.entry.end |
| SQL | -- @scry.entry ... -- @scry.entry.end |
| Lisp | ;; @scry.entry ... ;; @scry.entry.end |
Block comments (v1.0.1+)
| Style | Example |
|---|---|
| JSDoc / Java | /** @scry.entry ... * @scry.entry.end */ with * continuation |
| C / C++ | /* @scry.entry ... @scry.entry.end */ |
| OCaml | (* @scry.entry ... @scry.entry.end *) |
| Haskell | {- @scry.entry ... @scry.entry.end -} |
| PowerShell | <# @scry.entry ... @scry.entry.end #> |
Example JSDoc marker:
/**
* @scry.entry
* id: design.auth-flow~a1b2c3d4
* kind: design
* summary: JWT auth middleware
* status: active
* @scry.entry.end
*/
Public API
| Symbol | Description |
|---|---|
parse_markers(content, language=None, file="") |
Parse all scry markers from text. Returns ParseResult. |
validate_marker(marker) |
Validate a marker against spec rules. Returns ValidationResult. |
check_cycles(markers) |
Detect cycles in depends_on graph. Returns list[str] of error messages. |
mint_id(kind, name, content=None) |
Generate a spec-conformant marker ID. |
BASELINE_KINDS |
Tuple of standard kind values from scry-spec v1.0. |
BASELINE_STATUSES |
Tuple of standard status values (draft, active, deprecated). |
Dataclasses
ParseResult—entries: list[EntryMarker],anchors: list[AnchorMarker],bindings: list[BindingMarker],markersproperty (all three combined)EntryMarker—id,kind,summary,status,weight,tags,rationale,applies,seeded_questions,depends_on,implements,supersedes,file,spanAnchorMarker—name,description,seeded_questions,file,spanBindingMarker—local_id,ref,comment,file,offset,spanValidationResult—valid,errors,warnings
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
scry_parse-1.0.7.tar.gz
(35.7 kB
view details)
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 scry_parse-1.0.7.tar.gz.
File metadata
- Download URL: scry_parse-1.0.7.tar.gz
- Upload date:
- Size: 35.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.10","id":"oracular","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c0b015c9c7c54afd032694b966ee5ad0573684642f6e89388cce81fad4199aa
|
|
| MD5 |
fb04299e17415b441e3dd12bcc2e6564
|
|
| BLAKE2b-256 |
42a662ca1faf002922efbce59ddc7e758374b9ed52de2f7b75082a992808ed7e
|
File details
Details for the file scry_parse-1.0.7-py3-none-any.whl.
File metadata
- Download URL: scry_parse-1.0.7-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.10","id":"oracular","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
072fa46d0836b86a19cb42512baa3eeb6ad0b1b2664473049187fb5836dfe1fd
|
|
| MD5 |
3cf9acda30c9f70a84ada4fce7ca4f48
|
|
| BLAKE2b-256 |
2763059785fdc2848fa0c2fb3805330338d3a18c2c247ef72bb3c87268963b7f
|