Sharing states between prompts and programs.

Nightjar lets you embed natural-language code that executes on the same scope, heap, and control flow as your Python program. No additional glue code—just write your program logic.

import nightjarpy as nj

@nj.fn
def filter_and_process(items):
    valid_emails = []
    for item in items:
        """natural
        Check if <item> is a valid email address.
        If it's not a valid email,
        continue to the next loop iteration.
        If it is valid, add it to <valid_emails>
        and write a short <:explanation>
        """
        print(explanation)
    return valid_emails

emails = ["user@example.com", "invalid-email",
          "admin@company.org", "not-an-email",
          "support@help.com"]
valid = filter_and_process(emails)
print(f"Found {len(valid)} valid emails: {valid}")

Shared variable scope

Natural code sees the same variables as your Python code. Reference existing values by name and create new bindings without extra glue code.

Shared heap

Objects live in one place. When natural code modifies a data structure, your Python code sees those changes automatically. No serialization code, no copying.

Shared control state

Natural code can implement control flow in the Python program. They can break loops, continue iterations, or raise exceptions.