Skip to main content

Python parser for scry-spec v1.0 markers

Project description

scry-parse

Python parser for the scry-spec v1.0 marker format.

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

  • ParseResultentries: list[EntryMarker], anchors: list[AnchorMarker], bindings: list[BindingMarker], markers property (all three combined)
  • EntryMarkerid, kind, summary, status, weight, tags, rationale, applies, seeded_questions, depends_on, implements, supersedes, file, span
  • AnchorMarkername, description, seeded_questions, file, span
  • BindingMarkerlocal_id, ref, comment, file, offset, span
  • ValidationResultvalid, errors, warnings

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

scry_parse-1.0.4.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

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

scry_parse-1.0.4-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file scry_parse-1.0.4.tar.gz.

File metadata

  • Download URL: scry_parse-1.0.4.tar.gz
  • Upload date:
  • Size: 31.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for scry_parse-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f92fc5471af126043d444bdc739c21061b668d09750737acec5f782f1f0f7032
MD5 63aaf96730daae35c85b0709687f13bd
BLAKE2b-256 7019f3113e2a1fb6ab5df9bea78e787833ad93a6a1dbcda95136d93a927a55be

See more details on using hashes here.

File details

Details for the file scry_parse-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: scry_parse-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for scry_parse-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a9b41241dacc8b2081570e25d54abf350e986c9cd67976338490e72efe5586a0
MD5 3a98f18d8aa1de82226d23dd7e2d9628
BLAKE2b-256 9c7f0fb02a1e633bb83348d16cbdd6b3fc62430a55bb3049b2167ce5551427a9

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