Skip to content
izaakPublic

About

Synchronizes source code in Audulus 4 patches with local files.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Zwirn

Zwirn keeps code and text fragments in Audulus 4 patches synchronized with local files.

One-shot commands are supported on macOS and Linux. macOS also supports a foreground live session.

It is pre-release software intended for trusted, version-controlled workspaces.

Install from source

With a recent stable Rust toolchain:

cargo install --locked --path .

Getting started

In an Audulus code inspector, use edit markers to associate an embedded fragment with a local file:

-- @edit src/consts.lua
local gain = 0.5
-- @end src/consts.lua

By default, the file path is relative to the Audulus document's parent directory.

Synchronize unambiguous saved changes in either direction:

zwirn sync patch.audulus4

Audulus may remain open while running zwirn. Writes are coordinated safely.

If src/consts.lua does not exist, sync creates it and adds a synchronization hash to the end marker:

-- @end src/consts.lua #9238d3dc5eb11d81

The external file contains only the source between the markers. Edit either copy, save it, then run sync again.

Commands

zwirn <COMMAND>

status   inspect without changes
embed    source files → embedded fragments
extract  edit-marked fragments → source files
sync     apply safe changes
live     synchronize saved changes (foreground; macOS only)

One-shot commands accept:

zwirn <status|embed|extract|sync> [OPTIONS] DOCUMENT [PATH]...

Each PATH is an exact marker path relative to the source root. Pass one or more to select an exact subset; omit them to process every marked path.

zwirn embed patch.audulus4 src/filter.lua

The source root defaults to the document's parent directory. Set an explicit root with --source-root:

zwirn sync --source-root sources patch.audulus4

Live synchronization

On macOS, live runs in the foreground and watches one document and its source root, synchronizing saved changes:

zwirn live patch.audulus4

Markers

Marked fragments begin with an @edit PATH or @include PATH marker and end with a matching @end PATH marker.

  • edit associates one fragment with one file. Saved changes may flow in either direction.

  • include binds one file to one or more fragments sharing the same path. The file is authoritative, so changes flow only into the document.

For example:

-- @include src/shared.lua
...source...
-- @end src/shared.lua

Marker comments follow the source language: -- for Lua and // for GLSL or Lyte. Text nodes use bare markers:

@edit notes.txt
These notes stay synchronized with notes.txt.
@end notes.txt

Text nodes support both edit and include bindings with the same synchronization rules as code nodes.

Leave the closing hash token out when creating a fragment; Zwirn records it after synchronization.

A node's source may contain multiple marked fragments.

The design document defines the complete marker and path grammar.

Conflicts

Once synchronized, a closing marker's #-prefixed hash records the last synchronized source. Zwirn leaves ambiguous changes unresolved.

Resolve a conflict manually, or explicitly select which side wins:

zwirn embed --force patch.audulus4 src/filter.lua
zwirn extract --force patch.audulus4 src/filter.lua

With explicitly selected conflicts, forced embed selects the filesystem copy. Forced extract selects the embedded copy and applies only to edit markers.

One-shot output and exit status

Results are ordered by marker path and written one per line as PATH<TAB>RESULT.

0   every selected path is synchronized
1   one or more selected paths require attention
2   validation or operational failure

After validating and preparing all outputs, Zwirn writes external source files in marker-path order and the document last. An operational failure can leave earlier writes in place.

adls-text: Read and write embedded text

The workspace also includes adls-text, a command-line interface to the shared ADLS text crate. It exposes existing text fields in Canvas, DSP, Shader, Lyte DSP, and Text nodes, including present empty strings:

cargo install --locked --path tools/adls-text
adls-text list patch.audulus4
adls-text read patch.audulus4 2 > source.lua
adls-text write patch.audulus4 2 < source.lua

list reports node index, kind, and UTF-8 byte length as tab-separated rows. read emits the exact text. write replaces it from stdin; empty input clears the field and leaves it available for later writes. Writes are silent on success and leave unchanged documents untouched.

For bulk editing, export to a new directory, edit its NODE.KIND.txt files with ordinary tools, and import all or a subset:

adls-text read patch.audulus4 --directory patch-text
# Edit files such as patch-text/2.dsp.txt.
adls-text write patch.audulus4 --directory patch-text

Deleting an exported file omits that field from import; an empty file clears it. Node indexes refer to the saved document and may change when Audulus saves it again. This workflow does not create Zwirn bindings.

The marker migration script at tools/migrate-0.2-to-0.3-markers.sh uses adls-text and Python 3. Set ADLS_TEXT to use a different executable path.

Reference

AI assistance

Portions of Zwirn were developed with assistance from AI coding tools, including OpenAI Codex. Their output was reviewed, tested, and adapted by the maintainers, who remain responsible for the final implementation.

License

Zwirn is available under the MIT License.

Zwirn is an independent project and is not affiliated with or endorsed by Audulus LLC.

About

Synchronizes source code in Audulus 4 patches with local files.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages