yak.sh
github jsr
motd
graph

One graph, worked by people and agents through the same doors.

yaks is a toolkit of TypeScript packages for storing, querying and rendering records as entities, plus the packages that run agent sessions, tools and tasks over them. yak is its command line, and yaks.app hosts the apps built with it. Each bundle is an entity patch, and every list is a query.

deno run -A jsr:@yaks/cli/install

This screen runs yak: @yaks/graph over @yaks/ram, with the task vocabulary, every package fetched from JSR as the page loaded. Type yak help below, or slide a disk into the drive.

Every example marked run runs yak in this page: @yaks/graph over @yaks/ram with the task vocabulary, every package fetched from JSR. They all write to one graph.

Name

yaks — the @yaks packages: one graph, and the packages that store, query, draw and work it

Synopsis

deno add jsr:@yaks/graph jsr:@yaks/ram jsr:@yaks/vocab

Description

An entity is a record identified by entity.eid, a uuid. Its components are named objects, each describing one aspect of it. There is no kind column: an entity is what its components make it. A task is doc{title, body} plus task{}; a comment is doc plus comment{target}.

bundle
One entity's components as a JSON object: {entity: {eid}, doc: {title}}.
batch
A list of bundles applied in one transaction. Each component in a bundle is a patch: an omitted property is unchanged, null clears it.
vocabulary
The schema a graph accepts: each package's vocab.json, JSON Schema 2020-12 plus a few keywords of its own.
query
One grammar for every list: .task.status=open .priority<=1. A bare word is a text search over the properties marked search: true.

Start here

A whole graph in memory, from the packages README. It runs here as written:

import { docDoc } from '@yaks/doc'
import { graph } from '@yaks/graph'
import { ram } from '@yaks/ram'
import { loadVocab } from '@yaks/vocab'

let vocab = loadVocab([docDoc])
let g = graph({ storage: ram(vocab), vocab })
await g.apply([{
  entity: { eid: 'first-note' },
  doc: { title: 'Getting started', body: 'A document stored as components.' },
}])
console.log(await g.read('.doc.title="Getting started"'))

Swap ram for @yaks/sqlite to keep it on disk, put @yaks/api in front for HTTP, and use @yaks/client for a browser graph that stays in sync.

Map

Every package in the workspace, and each import of one by another, read from its own source (bin/package-map.ts). Point at a package for what it imports and what imports it; open one for its README.

The package map draws here once the page's scripts run.

Packages

Grouped by what they are for, not by dependency. Nearly all are published on JSR; import only the ones you need.

Graph

graph
entities, components and the phased apply()
vocab
a vocabulary as JSON Schema, read at runtime
query
the query grammar, parsed to an AST
sql
the SQL AST and its renderer
match
the same queries over bundles in memory
ram
storage in a Map, for pages and tests
sqlite
storage in a SQLite file
edge
links between entities, and traversal
fts
full-text search over FTS5
embedding
vectors and .near=<entity>
blob
long values stored by hash
journal
history, undo and a batch feed
effects
work owed by a commit, run by a pool
id
eids, and short ids like T-7
key, alias, names
other ways to address an entity
archetype
each entity's set of component tables
yaml
YAML and Markdown frontmatter as bundles

Doors

api
/apply, /query and /ws subscriptions
mcp
the graph as an MCP server
mcp-client
a remote MCP server's tools, used from here
cli
the yak command, and compose
sync
optimistic writes, reconciled with a server
client
the browser graph, queries as live values
web
the canvas, cards and boards yak serve answers in a browser
workerd
the same handler as a Cloudflare Worker
durable-object
one Durable Object, one graph
d1
the same storage over D1

Rendering

render
pick a renderer by how specifically it matches
preact
that registry in Preact
html
the same views as server-side HTML
text
the same views as Markdown and plain text
tui
the same views in a terminal
markdown
GitHub Flavored Markdown as nodes
canvas
the interface itself stored as data

Agents

session
transcripts as entries, claims, model turns
harness
an agent runner and its terminal app
spawn
claude and codex as sessions
process
a running program as an entity
tools
calls and results, recorded in the graph
model
one model interface; openai, openrouter and workers-ai implement it
context
what a model was given, recorded
builders, dreaming
outputs an agent builds from inputs
heal
an exception files a task about itself
tmux
a terminal somebody can watch

Work

task
tasks, with status computed from marks
project
projects, and boards as saved queries
goal
objectives that are never finished
design
proposals and their decisions
memory
what a person said, in their words
persona
instruction sets, rendered to Markdown
doc
the doc{title, body} everything shares
kernel
provenance: created, updated, comment
wake
coming back to something later
notify
watch, mute and notifications
mail
letters in and out
hook
stored webhook deliveries
page
web pages, captured
git, code, mirror
a repository and its files in the graph

Access and hosting

member
memberships, grants and app access
secrets
written through the graph, kept in a vault
connections
outside services, their credentials as secrets
oauth
one authorization-code client; providers are data
egress
calls out with a credential the caller never holds
platform
what a host keeps about its spaces and apps
esbuild
an app's TypeScript and npm imports, compiled at deploy
tunnel
a space's tunnel to a machine with no open port
admin
the owner's verbs on yaks.app, as yak admin tools; unpublished

See also

yak(1), packages/README.md, jsr.io/@yaks

Name

yak — the command line for a yaks graph, on this machine or behind an MCP server

Synopsis

yak [--config path | --host host] [--json] [--tui]
    [--no-duties] noun verb [args]
yak help [word ...]
yak init

Description

yak turns each tool a graph declares into a subcommand, with arguments and help from the tool's input schema, so a new tool needs no new CLI release. It provides five commands itself: help, init, login, logout and apply. The rest come from a graph opened in this process, or from an MCP server asked at run time. A tool with a noun and a verb is written in either order: yak task list is yak list task.

The terminal below is cli() from @yaks/cli, handed the graph tier of @yaks/graph and the tools of @yaks/task over a graph in memory: the same parser, help pages and exit codes.

The examples here run through cli() from @yaks/cli, handed the graph tier of @yaks/graph and the tools of @yaks/task over a graph in memory: the same parser, help pages and exit codes.

yak help
yak help task
yak list task
yak task list --json

Where a command runs

A command that names a config opens that graph in its own process, runs the tool and exits. It does not need yak serve: SQLite runs in WAL mode, so separate commands and a server share one file. The target is chosen in this order:

InputTarget
--config paththe local graph that config describes
--host hostthe remote MCP server at host/mcp
$YAKS_HOSTthe remote MCP server it names
$YAK_CONFIGthe local graph it describes
~/.yak/yak.jsonthe local graph in that file, if it exists
none of thesehttps://yaks.app/mcp

Local and remote calls both become a call entity run through @yaks/tools, so a person and an agent get the same validation, rules, effects, attribution and stored record.

The config

yak init writes ~/.yak/yak.json with the plugins a graph, its tasks, sessions, /mcp and the web canvas need. A config is plain JSON, so a plugin is one more line:

{
  "db": "graph.db",
  "plugins": ["@yaks/kernel", "@yaks/id", "@yaks/secrets", "@yaks/doc",
              "@yaks/effects", "@yaks/tools", "@yaks/task", "@yaks/api"],
  "numbers": true,
  "port": 8787
}
yak --config yak.json task new 'Buy the cake' --priority 1
yak --config yak.json serve      # @yaks/api's serve tool: HTTP
yak app_list                     # a tool on yaks.app's MCP server

Roles

A plugin is a package, and each kind of thing it contributes is a subpath export. A process serves roles and imports only the facets of the roles it serves, so a command line never loads a web server it will not start.

RoleFacetsWhat the process does
graph./vocab ./graph ./toolsopens the file, admits writes, runs tool calls
web./routesanswers HTTP with the routes @yaks/api hosts
effects./effectsclaims and runs what commits owe, in a pool
a plugin's nameits ./servicekeeps that plugin's timer or poll running

./views is for drawing: the web UI and yak import it to show an answer, so it must work in a browser and import no SQL or storage driver. ./tui adds terminal views for --tui.

Duties

Working the effect pool and each plugin's ./service are duties. Any number of processes work the pool, each claiming a run before it runs it; each service runs under a lease named for its package, so one process at a time runs it. A yak command runs its duties in a thread of its own, only where no live process is serving them. --no-duties takes no lease and runs none.

Exit status

0success
1a tool or server refused or failed the request
2invalid command-line usage
yak task update T-99 done
yak task new

See also

yak-sessions(7), @yaks/cli

Name

sessions, tasks — agent work, kept in the graph

Tasks

A task is doc plus task. Its status (open, done, cancelled) is computed from its completed and cancelled marks, never stored, by one rule that SQL and the in-memory evaluator both read. A board is a saved query, never a stored list: a task is on a board because it matches.

yak task new 'Buy the cake' --priority 1
yak task list
yak task list '.filed.priority<=1'

Edges are entities too (@yaks/edge): edge{from, to} plus a relation component. This page's graph opened with two tasks and the edge between them:

yak graph show T-1
yak task update T-2 done
yak task list .task.status=done

Sessions

A session is an entity with a session component, and each transcript entry is an entity beside it, entry{session, seq}. The components beside entry say what it is:

ComponentsMeaning
content{body}input from a person or system
ask{to, through}a request to a model
content + output{source}model or process output
call{to, id, args, source}a tool call a model requested
result{call} + contenta tool result
stopno further transcript work

settle() runs a transcript until it has nothing more to do, under a lease named for it, so two processes never run one transcript at once. The example from @yaks/session's README, with a model that is a local function; it runs here as written, types removed:

import { graph } from '@yaks/graph'
import { modelDoc } from '@yaks/model'
import { ram } from '@yaks/ram'
import { sessionDoc, sessions, settle, transcript } from '@yaks/session'
import { toolsDoc } from '@yaks/tools/vocab'
import { loadVocab } from '@yaks/vocab'

const vocab = loadVocab([sessionDoc, toolsDoc, modelDoc])
const g = graph({ storage: ram(vocab), vocab, plugins: [sessions()] })
const model = async (request) => ({
  id: crypto.randomUUID(),
  model: request.model,
  items: [{ kind: 'assistant', text: 'pong' }],
})
await g.apply([
  { entity: { eid: '$provider' }, provider: { name: 'local' } },
  { entity: { eid: '$model' }, model: { name: 'example' } },
  { entity: { eid: 'session' }, session: {} },
  {
    entity: { eid: 'input' },
    entry: { session: 'session' },
    content: { body: 'Reply with pong' },
    using: { provider: '$provider', model: '$model' },
  },
])
await settle(g, 'session', { holder: 'here', model, tools: [] })
console.log(await transcript(g, 'session'))

Claims

claim{session} is stored on the entity a session holds. A batch that would replace another session's claim fails whole with Bounced, and the collision is then written down as a conflict{target, loser, holder, at}, in a transaction of its own. Claims do not expire; deleting a session releases them.

yak graph apply --bundles '[{"entity":{"eid":"ada"},"session":{}},{"entity":{"eid":"bo"},"session":{}}]'
yak graph apply --bundles '[{"entity":{"eid":"T-1"},"claim":{"session":"ada"}}]'
yak graph apply --bundles '[{"entity":{"eid":"T-1"},"claim":{"session":"bo"}}]'
yak graph query .conflict

Runners

@yaks/harness runs sessions over any model the @yaks/model interface covers, and names no machine: it runs on a box or in a Cloudflare Worker. @yaks/spawn starts claude or codex as a detached process and reads its JSON-lines output back as the session's entries, so a run outlives the process that started it.

yak session spawn T-1 --provider codex --wait
yak session peek S-2

See also

yak-agents(7), @yaks/session, @yaks/task

Name

agents — MCP, harness hooks, and transcripts read in from outside

MCP

@yaks/mcp serves a graph as an MCP server: at /mcp when a config lists it, or over stdio. Agents get four generic tools that take and return bundles, plus every plugin's own tools; a fifth, search, comes with a search callback.

ToolPurpose
graph_applyapply bundles, answer the applied bundles
graph_queryread the entities a query selects
graph_showread named entities, each whole
graph_schemadescribe components, properties and kinds

The same four are the yak graph commands, declared once in @yaks/graph: an agent calling graph_query and a person typing yak graph query run one implementation, and both leave a call in the graph.

yak graph query '.task&?doc'
yak graph schema claim
yak graph apply --check --bundles '[{"entity":{"eid":"$t"},"task":{},"doc":{"title":"only a check"}}]'

Hooks

yak hooks install writes lifecycle hooks into a Claude-compatible settings file (~/.claude/settings.json by default), replacing an earlier install and leaving every other entry alone. A harness runs each hook with the event as JSON on stdin.

EventCommandEffect
SessionStart, SubagentStartyak session context --hook -creates the session under the harness's id; prints its claims
SessionEndyak session wrap --hook -releases the session's claims

Transcripts from outside

A session a harness runs elsewhere is read into the graph from the harness's own log, by one importer (@yaks/session/tail) with a reader per format, claude and codex. Every entry carries imported{source, line}, and entry ids are derived from the session, the line and the place in it, so a line read twice writes nothing new. The @yaks/session/service duty follows Claude Code's transcript files under ~/.claude/projects.

yak graph apply --bundles '[{"entity":{"eid":"$s"},"session":{}},{"entity":{"eid":"$e"},"entry":{"session":"$s"},"content":{"body":"fix T-2"},"imported":{"source":"claude","line":1}}]'
yak graph query .imported

Outward

@yaks/mcp-client reaches a remote MCP server's tools and hands them to a native session like its own. And yak itself is an MCP client: yak app_list is a tool on yaks.app's server.

See also

yak-sessions(7), @yaks/mcp

Name

run — the same graph on a box, on Cloudflare, or in this page

A box

deno run -A jsr:@yaks/cli/install
yak init
yak serve

yak serve answers HTTP, WebSocket subscriptions and, when the config lists @yaks/mcp, MCP at /mcp, over one SQLite file. @yaks/process runs a program so it outlives the server that started it. Secrets live in a vault of private files beside the database.

Cloudflare

@yaks/workerd serves the same handler from a Worker. @yaks/durable-object makes one Durable Object one graph, in the object's own SQLite, with hibernatable sockets; @yaks/d1 puts the same storage over D1. One apply(), with the same phases and plugins, runs on all three.

This page

A third place: a browser, with no server of its own. This page imports @yaks/graph, @yaks/ram, @yaks/cli and the task and session vocabularies from JSR through esm.sh, with no bundler and no build step, and runs them here.

The count of what this page loaded appears once yak is running.
yak graph query .tool

See also

yaks.app(7), @yaks/workerd

Name

yaks.app — build, host and share web apps

Description

yaks.app is where yaks apps live. A yaks app is an index.html and whatever files sit beside it, served live at space.yaks.app/app/. No build step, no framework, no install. People build them by asking Claude or ChatGPT: the connector at https://yaks.app/mcp gives an assistant app_new, app_files and app_deploy, and the same tools are yak commands.

The store

Every app has a store of its own, a graph of entities, and a page reads it in one line, from its own address:

import { apply, query, search, subscribe } from './api/client.js'

await apply({ entity: { eid: '$r' },
              doc: { title: 'Lemon cake', body: '3 lemons...' } })
let all = await query('.doc')       // everything, oldest first
let some = await search('lemon')    // full-text search, ranked
subscribe('.doc', draw)             // and again whenever it changes

Files beside index.html

vocab.jsonthe app's own components; each gets commands any agent finds later, add_recipe and find_recipe for a recipe
seed.jsonbundles written into the store by the first deploy, so an app opens furnished
worker.jsserver code for every request not under /api/; the D1, R2 and Vectorize bindings its wrangler.jsonc names are created at deploy
NOTES.mdwhat the person wants remembered about how the app is kept
icon.pngthe icon when the app is kept on a phone's home screen

An app is readable by anyone with the link and writable by its members; open lets anyone with the link write, and private shows it to members alone. A space can open a tunnel to a machine: its apps reach only the paths the machine opened, and the machine needs no open port.

This site

This page is a yaks app: apps/yak-sh-v2 in the repository, pushed to its space with the connector's own tools.

yak admin push apps/yak-sh-v2 --owner --space jeff

The home page's examples are apps in the demo space, each one installable: the recipe box, garden, book club, trip, guestbook and chores.

See also

yaks.app, yaks.app/docs.md