Skip to main content

A Python implementation of Winding Markdown, illuminate tooling, parser and EBNF.

Project description

Winding Python Module

Wind for Kids | Wind for Developers | Winding Markdown Spec (plain text) | GitHub

Winding Markdown Specification (plain text) | GitHub

A Python implementation of Winding Markdown - a lightweight CommonMark extension for creating artifacts via concise prompts.

Introduction to Evaluating Winding Expressions

Winding lets you write concise programs that can be "illuminated" into full implementations. Instead of verbose templates or complex configurations, you prompt (send messages) to agents:

---
hello_world: file, py
---
Make it shine.

@style: pythonic, minimal

If you run this Winding Markdown, it will produce a Python file that prints "Hello, World!" in a minimalistic style. Like this:

#!/usr/bin/env python3

def main():
    # Print a shining Hello, World! with ANSI sparkle
    print("\033[1;33m✨ Hello, World! ✨\033[0m")

if __name__ == "__main__":
    main()

You have just evaluated your first Winding expression! You sent a message to the 'hello_world' agent with arguments message ['file', 'py'], followed by a message containing a list of Windings:

  • The Markdown text "Make it shine."
  • A Winding that sends a message to the 'style' agent (in the space of 'hello_world') with arguments ['pythonic', 'minimal']

The hello_world agent, as a receiver, was newly invoked and decided what to do with these messages. It looked up its methods for handling file and py messages and responded appropriately.

If you talk to Smalltalkers for a while, you will quickly notice that they generally do not use expressions like “call an operation” or “invoke a method”, but instead they will say “send a message”. This reflects the idea that objects are responsible for their own actions. You never tell an object what to do — instead, you politely ask it to do something by sending it a message. The object, not you, selects the appropriate method for responding to your message ... Getting Started: Squeak by Example

With Winding, it is the same: you send messages to agents within the context of a space, and they decide how to produce artifacts.

Features

  • Provides illuminate that executes Winding Markdown files and produces artifacts.
  • Defines EBNF grammar for the Winding Markdown, for use with vLLM, Lark etc.
  • Defines a pure Python parser, based on the Lark standalone parser.
  • Defines AST and WindingTransformer, to facilitate the parsing.

Installation

You can install the Winding module from PyPI using pip:

pip install winding

Usage

---
winding: cli, tools
---
Winding Markdown CLI suite

@messages.vm:  
illuminate, wind, unwind, deluminate

@arguments:  
files, intent, pipes, include, exclude, context

@messages:  
fresh, freshen, draft, dry, wet, kiss, brush, lift, cool, heat, safe

@messages.dev:  
aloha, whisper, whine, lull, towel, wing, kite, kid, boy, girl, Wind, Sophie, please, help

@messages.experimental:  
venturi, whirl, whirling, whirlwind, reilluminate, rewind

@kid:  
I’m a kid, ELI5.

--
examples
--
aloha | illuminate "Hello World!"

Development

You can find runnable examples in the samples/ directory.

Here is a simple example of printing the grammar:

>>> from winding import grammar
>>> print(grammar)

start: (winding | markdown)+

winding: meta_winding | space_winding | inline_winding
meta_winding: "---\n" receivers ":" arguments header_winding* "\n---\n" windings? 
space_winding: "--\n" receivers ":" arguments header_winding* "\n--\n" windings?
header_winding: "\n" receivers ":" arguments
inline_winding: "@" receivers ":" arguments "\n" markdown

windings: (inline_winding | markdown)+
markdown: (image | TEXT)+
image: "![" CAPTION? "]" "(" URI? ")"

receivers: IDENTIFIER ("," IDENTIFIER)*
arguments: (IDENTIFIER ("," IDENTIFIER)*)?


IDENTIFIER: /!?[A-Za-z0-9][ A-Za-z0-9_.-]*/
URI: /[^\)\n]+/
TEXT: /(?:(?!@\w+[A-Za-z0-9_.,-]*:|--|!\[).)*\n+/ 
CAPTION: /[^\]]+/
    
%ignore /[ \t]+/
%ignore "\r"  

Example of parsing a Winding Markdown file

See samples/dragon.py for a complete example.

from winding.parser import Lark_StandAlone
from winding.transformer import WindingTransformer
from winding.ast import Winding
from pprint import pprint

parser = Lark_StandAlone()
sample = """---
dragons: portrait-oriented
---
A book about dragons

--
front-cover: portrait-oriented
--
Dragons

@center: large, landscape-oriented
![Flying Wind Dragon](dragon.png)
"""

tree = parser.parse(sample)
ast = WindingTransformer().transform(tree)
pprint(ast, indent=2)

This will output the following AST:

Winding(receivers=['this'],
        arguments=[],
        windings=[ Winding(receivers=['dragons'],
                           arguments=['portrait-oriented'],
                           windings=[ Markdown(content='A book about dragons\n'
                                                       '\n')]),
                   Winding(receivers=['front-cover'],
                           arguments=['portrait-oriented'],
                           windings=[ Markdown(content='Dragons\n\n'),
                                      Winding(receivers=['center'],
                                              arguments=[ 'large',
                                                          'landscape-oriented'],
                                              windings=[ Markdown(content=Image(caption='Flying '
                                                                                        'Wind '
                                                                                        'Dragon',
                                                                                url='dragon.png')),
                                                         Markdown(content='\n')])])])

Contributing

We welcome contributions to the Winding project! If you have suggestions, bug reports, or would like to contribute code, please open an issue or a pull request on our GitHub repository winding.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

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

winding-0.4.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

winding-0.4.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file winding-0.4.1.tar.gz.

File metadata

  • Download URL: winding-0.4.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for winding-0.4.1.tar.gz
Algorithm Hash digest
SHA256 5f1a4a9b815171f1b9915feed57533385307895b1cf718cbf074c7395dfc8018
MD5 ecf6a929f2d17332fba446219f7bbada
BLAKE2b-256 2e18f755ca63a6eab8bcceb252efb8336ba075c20cbb6766b7981880d336d325

See more details on using hashes here.

Provenance

The following attestation bundles were made for winding-0.4.1.tar.gz:

Publisher: workflow.yaml on Wind-WindKids/winding

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file winding-0.4.1-py3-none-any.whl.

File metadata

  • Download URL: winding-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for winding-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fefd3ed18d4d364d08ab8b019b4fed1029848aff489b7b2a7272a6944333f5f0
MD5 dc7e05b5dfa691a89ba26093c74166de
BLAKE2b-256 3f5a918c9fad5d6a1b2fe290bb4ad49a2b87f7dacc137ffc1cafc0b8077abb75

See more details on using hashes here.

Provenance

The following attestation bundles were made for winding-0.4.1-py3-none-any.whl:

Publisher: workflow.yaml on Wind-WindKids/winding

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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