ShtukbaseStandard

The shtuk tool

Commands, package sources, versions, the lock, actions and trust: the help of the tool.

On this site packages install from its registry: shtuk install <id> after install.sh. The commands below with a GitHub address work only with access to the Shtukbase repository, which is closed for now.

shtuk is a small console tool for the Shtukbase Standard. It installs packages (folders of pages and actions) into a project folder, makes a new project from a blueprint, and runs the actions the installed packages bring (check runs the checks among them). Everything else, lenses and servers included, is an action of some package. It needs no node and no daemon, it is written in TypeScript for Bun, and it stays thin on purpose: every norm and every check lives in a package, never in the tool.

shtuk is a working name, kept in one constant (src/name.ts). Version 0: about 1,200 lines of TypeScript, no dependencies, Bun 1.3 or newer (it uses Bun's built-in YAML parser; everything else is plain Node API).

bun test                                  # in apps/shtuk: the tests
bun src/cli.ts --help                     # or link the `shtuk` bin from package.json

Commands

CommandWhat it does
shtuk install <source> [--dir P] [--dry-run] [--fact k=v]... [--defaults] [--trust <id>]...Installs a package with everything it requires, and the includes whose when holds for the project's facts (a new-style package's includes have no when). Never overwrites a page that differs from what the package lays (it is recorded edited and reported). Installing again changes nothing. --dry-run prints the plan and writes nothing: it is the same planning code, without the final write. --fact records a project fact. Then runs the on: install/on: update actions of trusted packages; --trust <id> trusts one more for this run (see Install scripts).
shtuk init <dir> --blueprint <source> [--fact k=v]... [--defaults] [--name N] [--dry-run]A new project: creates the folder (it must be empty or absent), records the facts and runs the same install. The blueprint's start questions are not asked interactively: give each with --fact, or take every default with --defaults. Unanswered questions are printed and the command exits 2 without creating anything.
shtuk update [<id>] [--dir P] [--dry-run] [--registry R]...Every installed package (or the one named) takes the newest version that its recorded source (a folder, with the <id>/<version>/ folders beside it; a git URL; a registry) and the catalogs offer and that the ranges of the packages requiring it allow. The page rules of install apply to every kind, layers included: a page nobody edited is replaced, an edited page is kept and reported (kept N edited), a page deleted on purpose stays deleted, a page the new version drops is removed when nobody edited it. A package a new version newly requires or includes is installed. One line per package: updated a -> b, up to date. Installing a newer version by hand (install id@range) does the same for one package.
shtuk list [--dir P] [--registry R]...Per package: kind, version, source, page states (clean, edited, missing, removed), a newer version if a known source has one, and the conventions it follows (follows). Lists the pages that are not clean, and a note for every followed convention that is not in the project.
shtuk check [--dir P]Runs every action with check: true (and every old enforcer) of every installed package. One line per check (PASS/FAIL), its findings under it, exit 1 when any fails.
shtuk where <path>Shows the owner of a path relative to the current folder, the matching place if any, and the applicable rule counts. Exits 1 when there is no owner.
shtuk run [--dir P] <package> <action> [args]...Runs one action of an installed package with the terminal attached and the arguments as given; exits with the action's code. The lenses and the server are such actions of the lenses package.
shtuk hook <event> [args]...Dispatches pre-commit, commit-msg <file> or agent:<EventName> to the installed hook runners for the affected projects and their ancestors.
shtuk --help, --version

Exit codes: 0 done, 1 failed or a check failed, 2 wrong usage or unanswered start questions; run exits with the action's code. --dir is the current folder by default. --today YYYY-MM-DD (install, init) pins the date recorded in the lock and used for {{today}} in layer and new-style pages.

Projects in one repository

A folder with .shtukbase/ is a project. Projects can nest. A project's index.md can list repository-relative folders in places: [apps/site]. A file belongs to the project with the longest matching place, or to its nearest enclosing project when no place matches. Two projects cannot claim the same place.

Norms apply from the owner through its enclosing projects, nearest first. A rule can exclude projects by name with except: [site]. The name comes from name: in base/packages.md or from the project folder. Other package pages stay in their project. Check actions receive the absolute repository root in SHTUK_ROOT and the project's colon-separated places in SHTUK_PLACES. For a standalone project outside Git, the project folder is the root.

Commands of packages

A package manifest can declare command: <name> using lowercase letters, digits and hyphens, starting with a letter. In a project with the lenses package installed, shtuk lens build runs the same action as shtuk run lenses build.

Use shtuk lens to list its actions and shtuk --help to see all package commands and their action titles. To select another project, use shtuk lens --dir P build or shtuk --help --dir P. Arguments after the action name go to the action as given.

Built-in commands take precedence and help warns about the packages using those names. If multiple packages claim a name, that command exits 2 and names the packages. Use shtuk run <package> <action> to select one explicitly.

Sources

  • ./folder: a package folder. The folder around it is searched for what it requires (packages/<id>/ next to packages/<other>/).
  • <id>[@range]: looked up in catalogs, in this order: --registry R (repeatable), $SHTUK_REGISTRY (folders separated like PATH), registries: [..] in the project's base/packages.md. A catalog is a folder that holds <id>/<version>/ (a registry; an index.md beside them adds yanked versions and tree hashes, which are checked) or <id>/ (the author's packages/ folder). @0.1.0 means exactly that version, anything else is a range (^0.1.0, >=0.1.0 <0.3.0, ~1.2.3, *).
  • <git-url>[#ref][:path]: a shallow clone into the OS cache folder ($SHTUK_CACHE overrides it). With a path, only the folder around the package (it and its sibling packages) is checked out (sparse, cone mode) and only those files are fetched where the server filters (--filter=blob:none; GitHub does): this repository's packages come in about 4 s instead of 28 s; ref is a branch, a tag or a commit, path is the package folder inside the repository. The clone is made again on every run. A dry run writes nothing into the project, but fetching a git source still fills the cache.

Versions: no solver. Each package gets the highest version that satisfies every range asked of it (by requires, by the includes that apply, by the request); an installed version is kept while it satisfies them; an impossible combination is an error that names who asked for what. A set's include whose package is not found anywhere is a warning (sets list packages that are only planned); a missing requires is an error.

What is on disk

The formats are the Python CLI's (apps/standard/lab/package/package), so that both tools can work on one project while the Python one is still in use. They are read under the old names too (bundle.md, type: Bundle, kind: pack|method|schema, pack: in an include, bundles: keys, bundles.lock, bundles.md) and written under the new ones only. All the old names are in src/compat.ts.

WhatWhereDefined in
Package manifestpackage.md in the package folder (type: Package, id, kind: layer|norms|methods|set, or no kind for a new-style package, version, requires, includes of a set, ...)apps/standard/packages/README.md (layers), README-norms.md (norms, methods, sets)
Registry<registry>/index.md and frozen copies <registry>/<id>/<version>/apps/standard/registry/index.md, shtuks/projects/shtukbase-standard/research/bundles-as-packages-2026-11-24.md section 2
Package list pagebase/packages.md in the project: the version range a person wants per package (packages:) and a table rebuilt on every installthe same note, section 3.1; manifest_page in the Python CLI
Lock.shtukbase/packages.lock: per package kind, version, registry, sha256 (tree hash of the package), level, floor, requires, installed, and per page the hash of what was laid (base) and its statethe same note, section 3.2; lock_text in the Python CLI
Layer and new-style packagesthe files under project/ (layer) or pages/ (new-style), with {{project}}, {{name}}, {{today}} filled inengine/space/src/template/render.rs (the node's template/render); src/layer.ts reproduces it

Layer packages are laid by the tool itself, not through the node: src/layer.ts (about 70 lines) fills the install-time names with the same escaping as the node, and the result was compared with the node's template/render for the latest version of all 11 layer packages of the registry (346 pages) and is byte-identical. Questions of a template (asks) are refused; no layer package has any. The node's setup.md page is not laid, as in the Python CLI. A layer's {{today}} is the day of its first install, so an update never changes it.

The tool adds four things to those formats, all optional and ignored by the Python CLI:

  • actions (and the older enforcers) and questions in a package manifest (below);
  • facts: {key: value} and registries: [folder, ..] in the header of base/packages.md;
  • source: in a lock entry for a package that came from a folder or git, not from a registry. The Python CLI drops it when it rewrites the lock; list then shows the registry name.

Facts and conditions

A fact is a flat key (stack.language, client, scope.product) with a text, a flag or a list. They live in facts: in the project's list page, set by --fact k=v (true/false, a,b as a list, empty as null). when is the standard's condition: {fact: k, equals: v}, {fact: k, contains: v}, {scope: {axis: [v, ..]}}, all, any, when. A condition that needs a fact nobody gave is undecided, and an undecided include is skipped (the plan says so); give the fact later and install again.

Blueprint

A blueprint is a package of kind: set that may add start questions:

questions:
  - {fact: stack.language, ask: "What is the main language of the code?", options: [python, rust], default: python}

New-style package

A package.md with no kind is a new-style package (this is how the tool tells it from the old kinds, which work as before). The folder:

  • package.md: type: Package, id, version, title, description, requires: {<id>: ^0.1.0}, optional includes: [{package: <id>, version: ^0.1.0}] (any package may include others and still carry its own pages; an include that is not found is an error), optional actions:, optional follows: [<area>/conventions/<name>] (below).
  • pages/: pages copied to the project root as they are (pages/work/tasks.md lands at <project>/work/tasks.md), with {{project}}, {{name}}, {{today}} filled in as in layer pages; {{today}} is the day of the package's first install, so installing again never changes a page. {{fact:<key>}} is the answer recorded in the project's facts (--fact, or a question's default with --defaults); with no answer the mark stays and one line warns. Updates follow the page rules of update.
  • everything else (checks/, bin/, package.md itself) goes to .shtukbase/packages/<id>/; it is not project content.

A project path belongs to exactly one package, whatever its kind: an install where a package lays a page that another package already owns (in the lock or in the same install) is refused before anything is written. The lock entry has kind: package.

Conventions: follows

A base package may lay a convention: a page <area>/conventions/<name>.md with type: Convention (what a package of that kind gives, what it expects, what is free, how to make an alternative, its health). A package that follows it says so with one optional field, follows: [design/conventions/style] (a list of paths without a leading slash or .md). It is a pointer for agents and people, nothing more: the tool parses it (a value of another shape is a manifest error), keeps it in the lock entry, and shows it in the FOLLOWS column of list. If the page is not in the project (the base package is not installed) or is not type: Convention, install and list print a note. Nothing is ever refused; the health of a convention is norms whose enforcers run in the mode warn and print their findings without failing, so they are the base package's business, not the tool's.

Actions: how a package brings its checks and commands

actions:
  - name: <unique inside the package>
    run: <file inside the package>
    check: true                     # optional: a check, run by `shtuk check`
    on: install                     # optional: install and/or update (a string or a list); see "Install scripts"
    norm: <project path of the norm page the check holds, optional>
    title: <one line>

The older enforcers: [{id, norm, run}] is read as actions with check: true (the id is the name). A package that has actions, and every new-style package, leaves its files except seeds/, project/ and pages/ in .shtukbase/packages/<id>/; at install only actions with on may run (below). An action runs from there with the project root as the working directory: .py with python3, .ts, .js and .mjs with bun, any other file directly when it is executable (the executable bit is kept). For a check, exit 0 means the norm holds, anything else means it is violated or failed, and the lines it prints on stdout are the findings (the first lines of stderr are added for a failure). A check that does not answer in 60 seconds counts as failed. shtuk run starts a plain action with the terminal attached and passes its exit code on. Sensors, hooks and scheduling are outside the tool.

Install scripts

An action with on: install runs after the files of a newly installed package are laid; one with on: update runs after a new version is laid (by install, init or update); installing the same version again runs nothing. They run in install order (requirements first), from the project root, by the same path as shtuk run, and only for a trusted package (like pnpm onlyBuiltDependencies or Bun trustedDependencies). A package is trusted when its source is:

  • the Shtukbase repository: github.com/Shtukbase/shtukbase under apps/standard/packages (any scheme, .git and ref), or any folder inside the Shtukbase checkout this tool runs from;
  • listed under trusted: in trusted.md of a catalog folder that is itself one of the above (the owner's list: apps/standard/packages/trusted.md); the list is read from the source being installed, and a trusted.md anywhere else is ignored;
  • listed under trusted: in the project's base/packages.md (a list beside registries:; folder paths are relative to the project root);
  • named with --trust <id> (repeatable) on this command line; this trusts it for this run only and is not recorded.

An entry is a git source written as host/owner/repo[/folder], a folder path, or a bare package id (that package from any source). A registry copy is compared by its folder. An untrusted package is installed without running its scripts; the tool prints skipped <id>/<action> (on install): ... to run it: shtuk run <id> <action>. --dry-run lists would run and would skip lines. The lock records the outcome per package as scripts: {<action>: <exit code or skipped>}. A failing script is reported and the command exits 1; the files it was laid with stay laid, and the other scripts still run.

Safety

  • Installing a package executes its code only for an on: install/on: update action of a trusted package (above); otherwise package code runs only when you invoke a check or action.
  • A package can write only plain relative paths: no .., no absolute path, nothing under a hidden folder (.git, .shtukbase, .github); .git and .shtukbase inside a package are never read. Symbolic links in a package are ignored. Ids that name folders (id, requires, includes) must be plain names.
  • A registry copy whose tree hash differs from its index.md is refused. Everything is planned before anything is written, so a refusal leaves the project untouched.
  • Folder and git sources are recorded in the lock as a path or a URL: a project meant to be shared should be installed from a registry.

Not here yet

  • Migrations beyond on: update actions: an update lays pages by the rules above.
  • publish (freezing a package into a registry), adopt (recording what an old project already has), doctor, diff, extracting a package from a project.
  • A skill for agents.
  • A "what next" command.
  • Any runner for sensors, hooks or schedules; the sensor field of an old enforcer is not read.
  • Interactive questions: init takes answers as flags.
  • Colours, a config file, a plugin mechanism.
  • A registry in git: a git source is one package folder (with its neighbours for dependencies), not a catalog.
  • Binary files in packages: package files are read as text.

Layout

src/cli.ts (commands), manifest.ts (a package as data), source.ts (folders, git, catalogs), resolve.ts (versions), facts.ts (conditions), install.ts (plan, then write), follows.ts (notes about followed conventions), lock.ts, project.ts (list page, names), layer.ts (templates), check.ts (check and run), trust.ts (which packages may run install scripts), compat.ts (old names), emit.ts (the YAML writer), semver.ts, name.ts, fail.ts. The only Bun-only call is Bun.YAML.parse in manifest.ts; the rest is plain Node API.

test/ holds unit tests per module, e2e.test.ts (the real command line on fixture packages in test/fixtures/packages/, including a bare git repository made inside the test), new-style.test.ts (new-style packages, one owner per page, the sparse git fetch), update.test.ts, install-scripts.test.ts (scripts with on, trusted and not) and parity.test.ts. The last uses the real standard (apps/standard/registry, the node binary, the Python CLI) and skip what is not on the machine.

This page is built from apps/shtuk/README.md.