Skip to content
This repository was archived by the owner on Jun 30, 2026. It is now read-only.

Repository files navigation

bit

The .bit language toolkit — parse, validate, render, store, and convert structured documents.

CIcrates.ionpmPyPIMIT License


What is .bit?

.bit is a structured document language for defining entities, tasks, flows, and schemas. Think of it as a middle ground between Markdown (human-readable) and JSON (machine-processable) — with first-class support for state machines, typed schemas, and ternary validation.

# Project Setup
define:@User
name: ""!
email: ""!
role: :admin/:editor/:viewer!
mutate:@User:alice
name: "Alice Chen"
email: "alice@example.com"
role: :admin
## Tasks
[x] Define user schema
[!] Add authentication flow
[!] Write API endpoints :@alice
flow:onboarding
draft --> review --> approved

Why .bit?

FeatureJSONYAMLTOMLMarkdown.bit
Human-readableNoYesYesYesYes
Typed schemasNoNoNoNoYes
Entity definitionsNoNoNoNoYes
Task trackingNoNoNoPartialYes
State machinesNoNoNoNoYes
Ternary validationNoNoNoNoYes
File-native editingYesYesYesYesYes
Round-trips cleanlyYesMostlyYesNoYes

Install

CLI

# Cargo
cargo install bit-lang-cli
# Homebrew (coming soon)
brew install zaius-labs/tap/bit-lang

Rust Library

[dependencies]
bit-lang-core = "0.1"

JavaScript / TypeScript (WASM)

npm install bit-lang

Python

pip install bit-lang

Quick Start

1. Create a .bit file

bit init my-project
cd my-project

This creates a starter project with schema.bit (the language reference, embedded in every bitstore as @_system:schema).

2. Define entities and tasks

Create users.bit:

# Users
define:@User
name: ""!
email: ""!
role: :admin/:editor/:viewer!
active: true?
mutate:@User:alice
name: "Alice Chen"
email: "alice@example.com"
role: :admin
mutate:@User:bob
name: "Bob Smith"
email: "bob@example.com"
role: :editor
## Onboarding
[x] Set up user schema
[!] Add authentication flow
[!] Write API endpoints

3. Parse and explore

# Parse to JSON AST
$ bit parse users.bit | jq '.nodes | length'
4
# Format with consistent style
$ bit fmt users.bit --write
# Validate against schema
$ bit validate users.bit
# Convert JSON to .bit
$ echo'{"Product": {"name": "Widget", "price": 9.99}}'| bit convert - --from json
define:@Product
name: "Widget"
price: 9.99

4. Store and expand

# Pack .bit files into a compressed store
$ bit collapse ./my-project
Collapsed 3 files into my-project.bitstore
# Expand back to editable files
$ bit expand my-project.bitstore --output ./working
Expanded 3 files to ./working
# Check for drift
$ bit status my-project.bitstore ./working
No changes

Architecture

┌─────────────────────────────────────────────────────┐
│ bit-lang ecosystem │
├─────────────┬───────────┬───────────┬───────────────┤
│ bit-lang │ bit-lang │ bit-lang │ your app │
│ cli (bit) │ (PyO3) │ (WASM) │ (Rust lib) │
├─────────────┴───────────┴───────────┴───────────────┤
│ bit-lang-core (Rust) │
│ ┌────────┐ ┌────────┐ ┌──────────┐ ┌────────────┐ │
│ │ Parser │ │ IR │ │Interpret │ │ Validate │ │
│ │ 5.7K │ │ 1.4K │ │ 0.7K │ │ 1.0K │ │
│ └────┬───┘ └────┬───┘ └────┬─────┘ └─────┬──────┘ │
│ ┌────┴───┐ ┌────┴───┐ ┌────┴─────┐ ┌─────┴──────┐ │
│ │ Lexer │ │ Schema │ │ Gates │ │ Checks │ │
│ │ 0.6K │ │ 0.4K │ │ 0.7K │ │ 1.1K │ │
│ └────────┘ └────────┘ └──────────┘ └────────────┘ │
│ ┌────────┐ ┌────────┐ ┌──────────┐ ┌────────────┐ │
│ │ Render │ │ Format │ │ Query │ │ Convert │ │
│ │ 1.3K │ │ 1.1K │ │ 0.5K │ │ (J/M/T) │ │
│ └────────┘ └────────┘ └──────────┘ └────────────┘ │
├─────────────────────────────────────────────────────┤
│ bit-lang-store │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Page-Based Database Engine │ │
│ │ │ │
│ │ ┌───────┐ ┌────────┐ ┌──────┐ ┌────────┐ │ │
│ │ │ Pager │ │ B-Tree │ │Tables│ │ Query │ │ │
│ │ │ cache │ │ search │ │entity│ │ engine │ │ │
│ │ │ flush │ │ insert │ │task │ │ filter │ │ │
│ │ │ free │ │ delete │ │flow │ │ sort │ │ │
│ │ │ list │ │ scan │ │blob │ │ limit │ │ │
│ │ └───────┘ └────────┘ └──────┘ └────────┘ │ │
│ │ │ │
│ │ 4KB pages · B-tree indexes · blake3 hashes │ │
│ │ Single file · Zero config · Instant queries│ │
│ └─────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────┐ │
│ │ Store Intelligence (zero-dep) │ │
│ │ │ │
│ │ schema inference · predictive autocomplete │ │
│ │ drift detection · NL queries · BM25 search │ │
│ │ entity linking · pattern detection │ │
│ │ schema evolution · composite scoring │ │
│ │ │ │
│ │ opt-in: vector search · anomaly · classify │ │
│ └─────────────────────────────────────────────┘ │
│ │
│ collapse ↔ expand ↔ query ↔ mutate ↔ status │
└─────────────────────────────────────────────────────┘

CLI Reference

Core Commands

CommandDescriptionExample
bit parse <file>Parse to JSON ASTbit parse users.bit | jq .
bit parse <file> --irParse to compiled IRbit parse users.bit --ir
bit fmt <file>Format .bit sourcebit fmt users.bit --write
bit validate <file>Validate against schemabit validate users.bit --schema schema.bit
bit render <file>Render AST to .bit textbit render users.bit
bit query <expr> <files>Query entitiesbit query '@User' *.bit
bit check <file>Run validation checksbit check suite.bit

Store Commands

CommandDescriptionExample
bit collapse [dir]Pack .bit files → .bitstorebit collapse ./project
bit expand <store>Unpack .bitstore → filesbit expand project.bitstore
bit status <store> [dir]Show drift between store and filesbit status project.bitstore ./

Database Commands

CommandDescriptionExample
bit query <store> <expr>Query entities in storebit query db.bitstore "@User where role=admin"
bit insert <store> <ref>Insert entity into storebit insert db.bitstore @User:dave name=Dave
bit update <store> <ref>Update entity fieldsbit update db.bitstore @User:dave role=editor
bit delete <store> <ref>Delete entity from storebit delete db.bitstore @User:dave
bit info <store>Show store statsbit info db.bitstore
bit pages <store>Show page mapbit pages db.bitstore

Utility Commands

CommandDescriptionExample
bit convert <file>Convert JSON/MD → .bitbit convert data.json
bit watch <dir>Watch for .bit changes (NDJSON)bit watch ./project
bit apply <dir>Apply .bit to detected harnessbit apply ./config
bit init [dir]Create new .bit projectbit init my-project

All commands support - for stdin and output JSON to stdout.


SDK Usage

Rust

use bit_core::*;// Parselet doc = parse_source("define:@User\n name: alice").unwrap();// Render backlet text = render_doc(&doc);// Formatlet formatted = fmt("# Title\n[!] Task").unwrap();// Convert from JSONlet doc = from_json(r#"{"User": {"name": "alice"}}"#).unwrap();let bit_text = render_doc(&doc);// Build indexlet idx = build_index(&doc);// Validatelet schemas = load_schemas(&["define:@User\n name: \"\"!\n email: \"\"!"]).unwrap();let result = validate_doc(&doc,&schemas);

JavaScript / TypeScript

import{parse,fmt,fromJson,fromMarkdown,toJson}from'bit-lang';// Parse .bit to ASTconstdoc=parse('define:@User\n name: alice');// Formatconstformatted=fmt('# Title\n[!] Task');// ConvertconstbitText=fromJson('{"User": {"name": "alice"}}');constjson=toJson('define:@User\n name: alice');

Python

importbit_lang# Parse .bit to JSON ASTast=bit_lang.parse('define:@User\n name: alice')
# Formatformatted=bit_lang.fmt('# Title\n[!] Task')
# Convertbit_text=bit_lang.from_json('{"User": {"name": "alice"}}')
json_str=bit_lang.to_json('define:@User\n name: alice')

.bit Language Reference

Syntax Overview

┌─────────────────────────────────────────────┐
│ .bit Document Structure │
├─────────────────────────────────────────────┤
│ │
│ # Group (depth 1) │
│ ## Subgroup (depth 2) │
│ │
│ [!] Pending task │
│ [x] Completed task │
│ [o] In-progress task │
│ [A!] Labeled task │
│ │
│ define:@Entity │
│ field: value │
│ required_field: ""! │
│ int_field: 0# │
│ float_field: 0.0## │
│ bool_field: true? │
│ timestamp: ""@ │
│ enum: :a/:b/:c! │
│ list: [] │
│ json: {} │
│ relation: ->@Other │
│ │
│ mutate:@Entity:id │
│ field: new_value │
│ │
│ flow:name │
│ draft --> review --> approved │
│ │
│ gate:requirement │
│ {condition_met} │
│ │
└─────────────────────────────────────────────┘

Field Sigils

SigilTypeExample
!Requiredname: ""!
#Integercount: 0#
##Floatprice: 0.0##
?Booleanactive: true?
@Timestampcreated: ""@
^Indexedid: ""^
[]Listtags: []
{}JSONmeta: {}
->Relationowner: ->@User

Task Markers

MarkerMeaning
[!]Pending / required
[x]Completed
[o]In progress
[~]Partial / blocked
[A!]Labeled (A = label)

See schema.bit (embedded in every bitstore as @_system:schema) for the complete grammar specification.


Lesson Book

Comprehensive guides and examples for learning .bit:


.bitstore Engine

The .bitstore file is a page-based database — like SQLite for .bit documents. Single file, zero config, instant queries.

┌──────────────────── .bitstore ────────────────────┐
│ │
│ Page 0: Header │
│ ┌──────────────────────────────────────────────┐ │
│ │ BITS │ 4096 │ roots: entity,task,flow, │ │
│ │ │ │ schema,blob │ change_ctr │ │
│ └──────────────────────────────────────────────┘ │
│ │
│ Pages 1..N: B-tree nodes │
│ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │
│ │entity│ │ task │ │ flow │ │ blob │ ... │
│ │B-tree│ │B-tree│ │B-tree│ │B-tree│ │
│ └──────┘ └──────┘ └──────┘ └──────┘ │
│ │
│ 4KB pages · B-tree indexes · O(log n) lookups │
└────────────────────────────────────────────────────┘

How it works

  • Collapse (bit collapse): parses every .bit file, extracts entities/tasks/flows/schemas, inserts into B-tree indexes, stores raw file blobs. One file becomes a queryable database.
  • Query (bit query store "@User where role=admin"): seeks B-tree directly — reads ~3 pages instead of decompressing everything.
  • Mutate (bit insert/update/delete): writes directly to the B-tree. No expand-edit-collapse cycle needed.
  • Expand (bit expand): reads blobs from the B-tree, writes .bit files back to disk. Round-trips cleanly.

Performance

OperationSpeedNotes
Insert 5,000 entities40msB-tree with automatic page splitting
Single entity lookup4μs~3 page reads (root → interior → leaf)
Scan 5,000 entities1.3msLeaf chain traversal
Collapse 100 .bit files36msParse + index + store blobs

Features

  • Single portable file — copy anywhere, query immediately
  • 5 independent B-trees: entities, tasks, flows, schemas, blobs
  • Blake3 content hashing for drift detection
  • Freelist for space reclamation on delete
  • Page cache for repeated reads
  • Portable page-based database format

Store Intelligence

bit-lang-store includes built-in intelligence features that work without external dependencies or models. Every feature ships in the base package.

Zero-Dependency (ships with base package)

FeatureWhat it doesCLI
Schema InferenceInfer field types, required/optional, enums from databit infer store.bitstore @User
Predictive AutocompleteSuggest likely field values based on historical patternsbit suggest store.bitstore @User role
Drift DetectionAlert when data distributions shiftbit drift store.bitstore
Natural Language Query"show me active admins" → @User where role=adminbit query store.bitstore "active admins"
Self-Organizing IndexesAuto-create indexes on frequently-filtered fieldsAutomatic
Schema EvolutionPropose migrations when data doesn't match schemabit evolve store.bitstore @User
Entity LinkingResolve "alice" → @User:alice via aliases and fuzzy matchBuilt into queries
Pattern DetectionSpot duplicates, frequency spikes, value clusteringbit patterns store.bitstore
BM25 SearchFull-text keyword search over entity fieldsbit search store.bitstore "auth error"
Composite ScoringRank by recency + importance + relevanceBuilt into context_window
Template CompressionCollapse similar entities into summariesProgrammatic API

Feature-Flagged (optional)

FeatureFlagSizeWhat it adds
Vector Searchembeddings+23MBSemantic similarity via MiniLM embeddings
Anomaly Detectionml+1MBZ-score and isolation forest outlier detection
Auto-Classificationml+1MBNaive Bayes auto-tagging on insert
# Base: all zero-dep features included
cargo add bit-lang-store
# With ML classification + anomaly detection
cargo add bit-lang-store --features ml
# With semantic embeddings
cargo add bit-lang-store --features embeddings
# Everything
cargo add bit-lang-store --features full

Contributing

git clone https://github.com/zaius-labs/dotbit
cd dotbit
cargo test --workspace

See CONTRIBUTING.md for guidelines.

License

MIT — see LICENSE.

Links

About

The .bit language toolkit — parse, validate, render, store, and convert structured documents

Topics

Resources

Contributing

Stars

6 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages