bashos¶
bashOS's direction is to become the ultimate open home for all things terminal-first AI runtime: data, tools, resources and transparency, with an inspectable kernel for slash commands and a GUI that sits beside the terminal, not above it, for everyone (constitution §1).
How to work in bashOS: the exact commands, the layout, the hard rules and the generated files, canonical for every coding agent and contributor.
What this repo is¶
bashOS is a terminal-first AI runtime: Markdown slash commands (.claude/commands/*.md) are routed by a LangGraph kernel (src/bashos/kernel/) through a loop (src/bashos/loops/) onto the OpenCode engine (src/bashos/opencode/), authenticated with the user's Claude Code OAuth. It serves people who want an AI-assisted terminal for software development and systems work, through three surfaces on one kernel: the Typer CLI (shell/), the Textual desktop (desktop/) and the loopback GUI (gui/). chui/ is the optional macOS terminal environment. On a machine of its own, bashOS is a layer (os/) on Amrchy (amrchy/, the maintainer's Omarchy fork and bashOS's framework), installed from one ISO; one-os/ builds, checks and deploys the machines it runs on, custom PCs included. A change is done when make test, make lint, node --test tests/shell.test.mjs and .venv/bin/bashos opencode sync (leaving no diff) are all clean, the generated docs are current, and the docs a change affects are updated in the same PR.
Design docs: docs/HARNESS.md (layers, loops, extension guide), docs/OPENCODE.md (policy, credential bridge, projection), docs/DESKTOP.md (the Textual desktop and the GUI), docs/FORGE.md (the dev-box monitoring pattern behind bin/os-health, /health, /dash), docs/OS.md (bashOS as the operating system: the layer on Amrchy or Debian 13, the console, the harness service), docs/AMRCHY.md (the framework under bashOS, the layer, the ISO and its first boot), docs/ONE-OS.md (one-os: building, booting, managing and deploying machines). Every document is indexed in docs/README.md.
Hard rules¶
- bashOS never implements a reasoning loop. OpenCode owns the agent loop, tool broker, sessions and permission gate; bashOS owns userland, routing, policy and the terminal. Work that would add a tool loop to bashOS belongs in the engine layer or nowhere. Loops call the engine, never a model directly. The desktop and GUI are views: they render events, run kernel lines, and never reason or run a loop of their own.
- Loops never get network or write tools. Tool policy is deny-by-default and lives only in
src/bashos/opencode/policy.py— widening that file is the only way to widen what bashOS can touch. Never add a tool that writes, reaches the network, or spawns an agent not bound by the policy. Bash probes on the allowlist must be strictly read-only and must not be able to execute other commands. Remote work goes through fixed, code-owned probes (remote.PROBES); never give a loop ssh or network tools. opencode.jsoncis generated, committed, and credential-free. Never hand-edit it. Change.claude/commands/*.mdorpolicy.py, then run.venv/bin/bashos opencode sync; a test fails on drift. It must never contain a credential — secrets go in the engine's environment only (opencode/auth.py), never on disk.- Anthropic model IDs are limited to
claude-opus-5-5(the default),claude-sonnet-5-5andclaude-haiku-5-5, optionallyanthropic/-qualified. Use no other Claude model strings. - Nothing blocks on a human. Approval requests are auto-refused and a dead event stream releases the prompt. The desktop's interactive affordances (exec confirm, Stop) never loosen this; an approval queue would be a new, explicitly named policy profile, off by default.
Stack & commands¶
Python 3.11+ (LangGraph, langchain-core, httpx to the engine, Typer + Rich, Textual, PyYAML); the engine is the opencode binary, installed outside pip; Node runs only the GUI reducer tests; shellcheck lints the shell code.
npm i -g opencode-ai # the engine (or: curl -fsSL https://opencode.ai/install | bash)
make install # .venv + editable install with the dev extras
./bin/bashos # the desktop (bootstraps .venv itself if make install was skipped)
./bin/bashos gui # …or the GUI desktop, on the same kernel
make test # the offline suite: fake model, no auth, no engine
make lint # ruff check . + shellcheck
node --test tests/shell.test.mjs # GUI layout reducer tests
.venv/bin/bashos opencode sync # regenerate opencode.jsonc after command/policy edits
python3 tools/gen_commands_table.py --write # regenerate the README commands table
python3 tools/docs_index.py --write # regenerate the docs/README.md index
.venv/bin/bashos run -n "/sh ..." # dry-run: routing + rendered prompt, no auth needed
.venv/bin/bashos doctor # auth/backend diagnosis (offline)
.venv/bin/bashos opencode status # boot the engine, report live state
.venv/bin/bashos opencode verify # prove the engine still enforces the tool policy
.venv/bin/bashos gui --browser # the GUI desktop, in a browser tab
bin/bashos chui install --dry-run # macOS terminal environment: the plan, nothing changed
bin/bashos os install --dry-run # Linux OS layer: the plan for this machine, nothing changed
bin/bashos os amrchy status # amrchy/ (the framework) against bamr87/amrchy; pull / push BRANCH
bin/bashos os iso build --stage-only # the bashOS ISO tree: amrchy/ + the bashOS layer (a full build needs Docker, ~30 GB)
bin/bashos os iso seed --user U --disk DEV --disk-bytes N # the cidata drive that installs it unattended
bin/bashos os iso test # that install in a KVM VM, through first boot (the os-iso workflow runs build + test)
bin/bashos os engine update # OpenCode → npm's latest, verified before it is promoted
bin/bashos os image build --docker # the bootable Debian 13 disk image (mkosi, privileged container)
bin/bashos os image test --docker # boot it in QEMU with a seed drive and check it like a user
bin/bashos one-os lint # one-os: shellcheck, ruff, manifest schema (in its builder container on macOS)
bin/bashos one-os test ARGS="-k t21 -v" # one-os: one harness test in QEMU (the fast suite takes ~30 min emulated)
bin/bashos one-os machine check x870e-dark-hero --system bashos # a machine profile's chips against a system's kernel
Before opening a PR: make test, make lint and node --test tests/shell.test.mjs pass, and .venv/bin/bashos opencode sync leaves no diff.
Layout¶
.claude/commands/*.md— userland, the single source of truth. Each file is a Claude Code slash command, a bashOS command and (compiled) an OpenCode command;bashos:frontmatter declares its loop (prompt|refine|react) and optionally its engineagent.src/bashos/kernel/— the LangGraph state machine (parse → classify/dispatch → loop → respond). State lives inkernel/state.py;traceis append-only.src/bashos/loops/— the orchestration loops, registered inkernel/graph.py:_LOOP_NODES.src/bashos/opencode/— the core.policy.pyis the ONLY place that widens bashOS's blast radius;project.pycompiles the registry + policy intoopencode.jsonc;auth.pybridges Claude Code OAuth into the engine process's environment (never to disk);server.py/engine.pysupervise the engine and expose two verbs,complete()andact().src/bashos/runtime/— backend resolution. Defaultopencode; the Claude Agent SDK adapter and the direct API are completion-only fallbacks that cannot run the react loop.src/bashos/remote.py— dev-box integration (bashos remote …): code runs fixed read-only probes over ssh, the model reasons locally over the gathered text, and the interaction mirrors onto the box's tmux console monitor. Extendremote.PROBES; never give loops ssh or network tools.src/bashos/shell/— the Typer CLI (bashos runand friends) and its Rich rendering.src/bashos/desktop/— the Textual desktop: tiling window manager, taskbar, launcher, app suite (AI console, health, doctor, engine, commands, trace, OpenCode TUI). It renders typed events (src/bashos/events.py) and never reasons.src/bashos/gui/— the GUI desktop (bashos gui).http.pyis a ~300-line asyncio HTTP/SSE server (never add a web framework);server.pyroutes onto the kernel behind a loopback + per-process-token guard;web/is hand-written and unbundled —app.jsdraws,shell.jsis a pure layout reducer tested bytests/shell.test.mjs. It runs kernel lines only: no shell passthrough, no policy of its own, never a loop. Window/OS-shell direction: docs/frontend/.bin/—bashos(the launcher: bootstraps.venv, dispatcheschuibefore it) andos-health(the verdict floor/healthand the desktop's Health app run).chui/— the optional macOS terminal environment (Oh My Zsh + p10k + Zellij + modern CLI; formerly bamr87/chui, merged with history). See chui below.amrchy/— the framework: bamr87/amrchy, the Omarchy fork (Arch, Hyprland, its installer, updates and migrations), as a squashed git subtree in upstream's naming. Its one extension point, layers (install/layers/<name>/), is how bashOS installs on it. See amrchy below.os/— the bashOS layer on Amrchy (primary) or Debian 13:bashos os installturns a machine into a bashOS machine (the shared tmux console on the desktop or tty1, the hub's Harness Console as a user service, updates + migrations).os/amrchy/layer/andbashos-firstbootput it on an Amrchy install,os/iso/builds the bashOS ISO and itscidataseed, andos/image/the Debian mkosi image. See os below.one-os/— one-os, the tool that builds, boots, manages and deploys machines (formerly the standalone one-usb): a manifest of pinned ISOs, the Ventoy stick and its Debian home base, the PXE server, the SteamOS deployer, the flash wizard and a QEMU harness. Self-contained, with its own Makefile, builder container, docs and ADRs. See one-os below.tools/— repository scripts that do not ship:capture_desktop.py(the stills/GIFs indocs/DESKTOP-TOUR.md; not in CI, re-run when the front end changes, needspip install playwright pillow),gen_commands_table.py, and the vendoreddocs_index.pyandunwrap-prose.py(themarkdown-onelinegate's fixer).docker-compose.yml,docker/— optional services:phoenix(:6006),langgraph-dev(serves the kernel graph vialanggraph.json, :2024),bashos(the containerized terminal, profilecli). LangChain/LangGraph are in-process libraries otherwise.tests/— the offline pytest suite (tests/desktop/has SVG snapshots) andshell.test.mjs;features/,verify/— the fleet feature index and user scenarios.
Conventions¶
- Backlog of record: GitHub Issues with the fleet labels (
.github/sdlc.yml, issues mode). Pick up issues labelledagent:ready; never touchagent:holdorhuman-review. - Definition of Done: the fleet default pull request checklist (this repo has no
.github/pull_request_template.md), plus the gates under Stack & commands. - Decisions: ADRs in
docs/adr/NNNN-slug.md, indexed indocs/adr/README.md. Add one for anything hard to reverse. - Commits: Conventional Commits (
feat fix docs style refactor test chore perf ci build). The PR title is the squash subject. - Branches:
feature/,fix/,docs/,refactor/,test/orchore/offmain. - Changelog:
CHANGELOG.md(Keep a Changelog) records notable changes. - Generated files — never hand-edit:
opencode.jsonc(bashos opencode sync), theAUTO:commandsspan inREADME.md(tools/gen_commands_table.py), theAUTO:docs-indexspan indocs/README.md(tools/docs_index.py, vendored from the hub — change it there).tests/test_opencode.pyandtests/test_docs.pyfail when any of them is stale. - New commands and loops ship with docs: run
python3 tools/gen_commands_table.py --writefor the README commands table and, for a loop, add a section todocs/HARNESS.md. - Markdown: one paragraph per line (no hard-wrapped prose); every document opens with one H1 and a one-sentence
>summary. - Never: push to
maindirectly, commit lockfiles or secrets, suppress type errors, leave empty exception handlers, or edit generated files by hand.
Code rules¶
- Everything is async; never call sync
invokeinside the kernel — useawait llm.ainvoke(...). The CLI wraps oneasyncio.run; the Textual desktop is the documented exception (Textual owns its loop). - The desktop owns the alternate screen: kernel and engine code never print — emit typed events (
src/bashos/events.py) and let the surface render them. - A loop is a node factory
(registry, llm, config) -> async node. Loops short-circuit on missing args (usage) and onconfig.dry_run(rendered prompt, no model call); tests rely on the dry-run path. - The GUI uses no web framework, no npm and no build step.
- Shell code (
bin/,chui/, generated prompts):set -Eeuo pipefail, quoted expansions, shellcheck-clean.
chui¶
- Plain bash + zsh, no Python dependency:
bin/bashos chui …dispatches tochui/tui.shBEFORE the venv bootstrap, and the Typerbashos chuicommand forwards to the same script. tui.shis the one dispatch table (the zshchuifunction only re-sources prefs);lib.shholds the link table, thelocal.zshmanaged block (never rewrite the rest of that file) and the Zellij key mode. Install never deletes a real file.- Tests:
chui/tests/(stdlib + pytest, a throwaway$HOME,defaults/osascriptshimmed). They run under macOS's stock bash 3.2 too, so keep the scripts 3.2-compatible. Docs: chui/README.md.
os¶
- Plain bash (≥ 4.4; Debian 13 ships 5.2), no Python dependency:
bin/bashos os …dispatches toos/os.shBEFORE the venv bootstrap, and the Typerbashos oscommand forwards to the same script. - Every change to a machine goes through
os/lib.sh(os_root,os_install_file,os_write_file,os_link,os_block_put,os_systemctl) so--dry-runand the fake root (--root DIR) stay truthful; a phase never callssudoor writes a system path itself. A re-run changes nothing — anything a re-run cannot express is a migration inos/migrations/. - The user's files are theirs: only the
>>> bashos os managedblock is written;/etc/bashos/os.confand~/.config/bashos/harness.envare created once; existing hooks (forge's console mirror) are adopted. The layer at/opt/bashosis root-owned. - It never widens
opencode/policy.py, gives a loop a tool, or touches the engine's credential path. Changing what runs on bashOS's machine (the X870E desktop, which replaced forge) is a deploy: an install, or an image written to a disk, needs the maintainer's explicit go-ahead. - Two bases, read from
/etc/os-release(os_base): Amrchy (Arch package lists inos/packages/arch/, pacman, the console as a desktop window) and Debian 13 (apt, tty1). A change that differs by base says so where it branches, and is tested against both fake roots. - The Amrchy layer (
os/amrchy/layer/system.sh) runs inside the installer, as root, with no network: it may only copy, write and enable. Anything that needs the network belongs tobashos-firstboot, which retries by exiting 75 and records every other failure instead of looping. - Building an ISO and installing it into a VM (
bashos os iso test, theos-isoworkflow) is safe. Writing it to a stick or a real disk is the maintainer's step, like every disk write in one-os. - Tests:
os/tests/(fake root + throwaway$HOME; inmake test),os/tests/test_iso.pyfor the layer, first boot, staging and the seed; the Debian image is built and booted byos/image/test/boot-smoke.shin theos-image.ymlworkflow. Docs: os/README.md, docs/OS.md, docs/AMRCHY.md.
amrchy¶
amrchy/is a squashed git subtree of bamr87/amrchy, the fork of record, where the daily AI upstream sync with Omarchy runs. Bring it in withbin/bashos os amrchy pull. Send changes made here back withbin/bashos os amrchy push BRANCHand a pull request there; never push to itsmain.- It is upstream's code: Omarchy's naming (
omarchy-*,/usr/share/omarchy) and its own rules, in amrchy/AGENTS.md. Its shell tests areamrchy/test/shell, and it is outside this repo's ruff and Markdown rules. - Change the framework only for something every layer needs, through its layers contract (amrchy/docs/layers.md); bashOS's own setup belongs in
os/amrchy/layer/. The only edits to upstream files are the tworun_loggedlines that call the layers, which an upstream sync must keep last. os/iso/iso.confpins Omarchy's ISO builder to the day of amrchy's upstream base: move it in the same change as a pull that moves that base. Never runbin/rebrand --applyonamrchy/; the brand is applied to builds.- Docs: docs/AMRCHY.md, ADR 0005, ADR 0003.
one-os¶
- Self-contained:
bin/bashos one-os <target>dispatches toone-os/one-os.shBEFORE the venv bootstrap, which forwards toone-os/Makefile(andone-os vm …toone-os/scripts/oneos-vm,one-os machine …toone-os/scripts/oneos-machine). Nothing insrc/bashos/imports it, and it never widensopencode/policy.pyor gives a loop a tool. - Never write a real disk. No
make flash,scripts/flash*.sh,write-image.py,dd,diskutil erase*oroneos-installagainst hardware: those are the maintainer's steps. A physical stick may be booted read-only in a VM, and the maintainer runs that command too. The full working notes are in one-os/AGENTS.md; read them before changing anything there. - The harness is the definition of done:
make -C one-os lintoften,make -C one-os test ARGS="-k <id>"for the test that covers a change. Its tests boot VMs, so they are not inmake test; theone-osworkflow runs them whenone-os/**changes. - Names: tools are
oneos-*, the package isoneos_harness, variables areONEOS_*. Pins live inone-os/manifest.yaml;scripts/manifest.py lintrejects an unpinned entry. - Machine profiles (
one-os/machines/) record a machine's parts and the first kernel each chip needs; a fact not read off the machine isTBD, never a guess. Runoneos-machine checkbefore deploying a system to a machine. - Docs: docs/ONE-OS.md (the overview), one-os/docs/README.md (user, operator and developer guides), ADR 0004, one-os's own ADRs in
one-os/docs/adr/.
Releasing¶
Releases are cut by release-please (fleet standard, UPS-QA-32); nobody pushes a tag by hand. Every push to main runs .github/workflows/release.yml, whose release job calls the hub's reusable bamr87/bamr87/.github/workflows/release-please.yml@v2 (pinned to the floating major tag, never a branch). That job opens or updates a release PR that bumps pyproject.toml, src/bashos/__init__.py and CHANGELOG.md from the Conventional Commits since the last tag (config: release-please-config.json, .release-please-manifest.json). The PR is opened with the RELEASE_PLEASE_TOKEN repo secret, because this repo's Actions settings forbid GITHUB_TOKEN from creating pull requests; the caller passes strict-pr-creation: true, so a release PR that cannot be opened fails the run instead of only warning. When a human merges the release PR, the resulting push tags vX.Y.Z and creates the GitHub release. The build, PyPI, GitHub-release-asset and GHCR jobs then run in the same workflow run, chained with needs: on the release_created output. No tag-push trigger is involved, so the rule that a tag made by GITHUB_TOKEN triggers no other workflow never applies. To re-publish an existing tag, dispatch release.yml with tag: vX.Y.Z. Agents never merge the release PR and never tag or release unless explicitly asked.
Fleet context¶
Member of the bamr87 fleet, vendored in the hub as the projects/bashos submodule: commit and push here first; the hub bumps its pointer afterwards. The standards live in the hub: https://github.com/bamr87/bamr87/tree/main/specs (the Universal Project Standard); this repo's SDLC declaration is .github/sdlc.yml. CI is ci.yml, a thin caller of the hub's shared standard-ci.yml@v2 (install .[dev], the desktop import smoke, pytest -q and node --test tests/shell.test.mjs on Python 3.11–3.14), with the repo's extra gates (ruff, shellcheck, docker compose config, the image build) beside it in bashos-checks.yml (UPS-QA-20). Loops that act on this repo: claude.yml (the @claude mention handler), conformance.yml (the hub's fleet conformance check), verify.yml (the fleet verify gate over features/ and verify/), and from the hub the daily fleet-pulse doctor (draft fix PRs for failing workflows) and the issue pipeline (agent:ready issues to draft PRs). None of them merges.
Standard deviations¶
amrchy/is a subtree of an upstream project (ADR 0005): it keeps Omarchy's naming, bash style and hard-wrapped documents, ruff excludes it (pyproject.toml), and its tests are its own (amrchy/test/), outsidemake test.one-os/was imported whole (ADR 0004): its documents are hard-wrapped and do not all open with a>summary, its Python followsone-os/ruff.toml(110 columns), and its tests run outsidemake test. New one-os documents follow this repo's Markdown rule.
Governance¶
Read docs/constitution.md before changing anything: it is the highest-precedence rule set here and wins over this file when they disagree. It changes only through a numbered record in docs/amendments/, ratified by the maintainer merging the PR; agents propose, never merge. Every user-facing feature has a stable id in features/features.yml with status, location and the PRD requirement ids it serves; the PRD's "Feature catalog" block is generated from it (python3 <bamr87/bamr87>/tools/governance_lint.py prd-sync . --write; check with … check .). Never hand-edit that block or CHANGELOG.md.