Skip to content

tonk-labs/tonk

Repository files navigation

Tonk

                                    .-            ::.
                                    -##.   ..     +@@@+
                              -:    ###-  *##
                              +##+  ###* *##%
                              ########%*###*   +*%
                        *###*:+##=*..:=####*++*#@
                          ######*==-.----%#**##%..:                        :=
                          .:=##-=:*#===*-##%@@*#@-                      ::.:=.
                      =#%%%#%%***##+#-*-##@@@@@              -..      .---++
                      =@%####@@@%%=*#@#*@@@@                -:      :--++
                        -+****#*#%@@@@%@@@-                  :.:   =::     .....
                      ++*#%*-+++*#@@@@@@@.                .:::-+:.#+   ..  .::::.
                      -%     =+#@   . %@@@*                     =##@        .
      ..                   *#%        .%@@+                       =###
    ##@%#*%                             +@%+                           #=
    :*#%%-:@                              @#=                            +-
      +@@@##@                               %+-                             *
                                        ::: :+=-     ...:-==.
                                    ......:-++:  ::.::::=+
                                    ++=-::+%@@#:--:...:-=+
                            .--           @@%%#*+-:::-=+-
                        .=++=--=+-     -==#%%####****#-
                    .%@@@      +%+ ..-*%#
              -=    =@@@@#       --:+%-     .    +@@%  :+#%*-:.
          :+-==+=   =@@@       ==+%  *#     +@+%@@@@ #=    %#****@:
          ###*=*  ..       .- .*=*. *        -@@#.-=#+      .**#*@+
          :=-:=@.+=*   ::= :..===+= #-:.     .#-...++ .=....   =@+
                %%%.   . -+    @*---%=*@@*:  ......-=  ==...-+  +%
          -++    .+%=*::+.*-    ##*@+--#@@@+.....=:.==. *-*+%  +%+-

Tonk is a data substrate: a software environment as easy to change as it is to use. Where stacks are rigid and vertically integrated, substrates are malleable and horizontally connected. You modify software in the context of its use, not through a separate process. In a substrate, software truly becomes yours.

Substrates are essential when LLMs make code generation abundant and personal software becomes practical. We won't get there by speeding up the same engineering-heavy processes of traditional software practice. We need a new surface; one interoperable and owned by the person running it. Tonk is that surface.

Dialog DB: The Foundation

At the core of Tonk is Dialog DB, an embeddable, local-first database. Dialog stores everything as claims — semantic triples of (entity, attribute, value). Claims are never deleted, only superseded or retracted. This append-only, content-addressed design makes it straightforward to sync data across devices and collaborators without conflicts.

The primary interface is claims themselves — assert data, query it, retract it. On top of that, you can optionally define:

  • Concepts to group related claims into queryable structures. Define a Person with a name, location, and photo. Then create a ClubMember concept that reuses name and photo but leaves out location — multiple views over the same data.
  • Rules to derive new concepts from existing claims. "A FamilyMember is any Person whose last name matches another and who shares the same home location."

Add new rules, concepts, or extend existing ones as your needs evolve. No migrations required.

Check out the Dialog DB repository to learn more about how it works under the hood.

The tonk CLI

tonk is a local-first command-line companion for reading and writing Tonk data without a browser. It operates on a .tonk/ site (a Dialog repository in the current directory) and speaks the same asserted-notation as the rest of the substrate: you assert claims, query them, and define concepts and rules with tonk eval, plus read-only introspection (tonk schema, tonk concepts, tonk views) and a built-in notation reference (tonk guide).

Install

curl -fsSL https://github.com/tonk-labs/tonk/releases/latest/download/install.sh | sh

This detects your platform, verifies the download against the release checksums, and installs the tonk binary to /usr/local/bin (or ~/.local/bin if that is not writable). Apple Silicon macOS and x86_64 Linux are published. If tonk isn't found afterward, the install location isn't on your PATH — add it, e.g. export PATH="$HOME/.local/bin:$PATH". Set TONK_INSTALL_DIR to install elsewhere.

To install the pre-release channel instead, set TONK_CHANNEL=staging:

curl -fsSL https://github.com/tonk-labs/tonk/releases/latest/download/install.sh | TONK_CHANNEL=staging sh

You can also download a tonk-<platform>.tar.gz directly from the releases page and extract the tonk binary onto your PATH. The macOS binary is not yet Apple-signed, so a hand-downloaded copy needs xattr -c tonk && codesign --force --sign - tonk before it will run (the install script does this for you).

Update

There is no self-update command yet. To upgrade, re-run the install command — it downloads the newest release and overwrites the binary in place:

curl -fsSL https://github.com/tonk-labs/tonk/releases/latest/download/install.sh | sh

Check what you have with tonk --version. Add TONK_CHANNEL=staging to track the pre-release channel instead.

The installer overwrites the existing binary in place and re-runs the macOS de-quarantine and ad-hoc re-sign, so an upgrade through it needs nothing extra. If you instead replace the binary from a manually downloaded tarball, re-run xattr -c tonk && codesign --force --sign - tonk on the new copy, since the replacement is unsigned just like a fresh download.

Quick start

tonk init                  # create a .tonk/ repo in the current directory
tonk eval -c 'person:'     # run a notation document (inline, file, or piped)
tonk schema                # every named attribute + concept on the branch
tonk guide                 # built-in asserted-notation reference

What's in This Repo

This is a Rust workspace where we are implementing our early experimentations on the Tonk substrate.

⚠️ This repo is heavily in flux, and not meant to be friendly for public access or contributions. If you would like to try it, the tonk CLI is the easiest entry point.

Rust Crates

Crate Purpose
tonk-space Core space primitives: operators, delegation, ownership, storage
tonk-common Cross-platform utilities (logging, etc.)
tonk-blobs Content-addressed blob storage (filesystem + IndexedDB)
tonk-access-service Cloudflare Worker that authorizes S3/R2 access via UCAN
tonk-ui Leptos-based web frontend
tonk-worker Browser service worker (WASM) for offline web support
tonk-core Core library (in progress)

Adjacent Projects

Tonk is pluralist by design and built to work alongside other protocols building on open technology. We think that is the best way to accomplish our mission. Here are some projects that are adjacent to us and think you should check out.

If you are a friend or adjacent project and would like to be listed here, please reach out!

Resources

License

MIT © Tonk Labs

About

A portable data substrate for humans and their tools to think together.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors