anomalyco/opencode-rune houses OpenCode (Rune) (apps/desktop, apps/web, apps/installer) and the shared Rust crates (crates/*) that any Rune app can embed by git dependency.
Start at the top and go deeper only when a feature needs lower-level control. See ARCHITECTURE.md for the complete crate inventory, dependency graph, and "Which file do I touch?" wiring guide.
plugins/(Tier 1 — default): Psychoscript JS plugins (plugins/*.js, CommonJS, typed viaplugins/opencode.d.ts) targetingopencode-plugin-spec, hot-reloaded in place with zero Rust edits.features/(Tier 2): decoupled Rust feature crates (opencode-feature-*) with zero cross-feature dependencies and non-generic&mut dyn *Hostboundaries. Scaffold new plugins or features withscripts/new-feature.sh(orpwsh scripts/new-feature.ps1).crates/(Tier 3): shell kernel (opencode-kernel), bottom-layer UI design-system foundation (opencode-ui, zerosession-viewdependency), headless runtime (opencode-runtime), platform/storage/search/i18n/plugin-runtime libraries, and embeddable crates (session-viewbuilt onopencode-ui,opencode-code-view,opencode-kit,rune-parts,terminal,browser-pane,office-preview,project-icon,hex-client,otlp-lite). Keepsession-viewfree ofopencode-desktop-only window/tab/sidebar assumptions andopencode-kitfree of app-specific concepts so other Rune apps can embed them directly.apps/(Tier 4):apps/desktop(opencode-desktop): shared desktop library (opencode_desktop) plus thin native binary (main.rs), organized into root entry/wiring files and domain folders (shell/,session/,workspace/,surfaces/,dialogs/,plugin_host/,stories/). LegacyAppfields are clustered inshell/app_state.rs; new feature state goes inopencode_kernel::StateSlotsand modal dialogs, Escape layers, commands, and per-frame polls register inFeature::register.apps/web(opencode-web): thinwasm32/WebGPU browser entrypoint depending directly onopencode-desktopwith zero duplicatedfeatures/*dependencies.apps/installer(opencode-rune-setup): Windows per-user setup bootstrapper.apps/desktop-thin+apps/desktop-library: a packaged Windows build is a thinopencode-desktop.exethat loads the app fromopencode-desktop.dllbeside it (apps/installer/scripts/package.ps1);cargo runand the other platforms build the one-file exe ofapps/desktop.apps/browser-engine(opencode-browser-engine): standalone out-of-process CEF sidecar bundle, excluded from the Cargo workspace in rootCargo.toml.apps/office-engine(opencode-office-engine): standalone lazy-downloaded BetterOffice + Vello sidecar binary (usingcrates/office-previewandcrates/office-protocol), excluded from the Cargo workspace in rootCargo.toml.
Rune comes from anomalyco/rune as a git dependency pinned in the root Cargo.toml. Keep every anomalyco/rune dependency and patch on the same rev (enforced by scripts/arch-check.sh); pin only revs on Rune's dev branch and land upstream fixes in anomalyco/rune first (convention).
Application code only. This repo has no automated tests of any kind, and none get added back (Hona and Kit, Nov 10: "Application code is truth, tests are a poor replica"):
- No unit tests,
#[test]or#[cfg(test)]code,tests.rs/*_tests.rsfiles, mocks, fuzzers, golden or snapshot files, motion audits, test benchmarks or CI test steps. - Don't spend time writing, fixing or running tests. Verify a change by building and running the app (
--fixture, a story, or live). - Stories and
--fixtureare app features for looking at the app, not tests: don't turn them into assertions.
- Before pushing (cheap guardrails): run
scripts/guardrails.sh(macOS/Linux/Git Bash) orpwsh scripts/guardrails.ps1(Windows PowerShell). Requires Bun or Node.js 18+ (no Python) and exits non-zero on any failure. Full rule list and conventions live inARCHITECTURE.md:scripts/arch-check.sh: enforces resolved transitive downward crate layers and zero cycles (cargo metadata), zero cross-feature deps, core-crate isolation (temporary exceptions inscripts/arch-check-exceptions.txt), core/feature#,<= 10root.rsfiles inapps/desktop/src/,struct App<= 94effective fields (counting throughshell/app_state.rsand anyTrackedwrappers),apps/webdepending directly onopencode-desktopwith zero duplicatedfeatures/*deps, zero automated tests (#[test],#[cfg(...test...)],tests.rs,*_tests.rs,*_test.rs,tests/), hard<= 800-line cap inapps/desktop/,features/, and hand-written workspacecrates/, zerouse crate::*;wildcards inapps/desktop/src/,opencode-feature-*naming, workspace manifest completeness, a singleanomalyco/runerev pin, and CommonJS built-in Psychoscript JS plugins (no ESMimport/export).scripts/file-size.sh: repo-wide line-count monitor and 1,500-line ratchet across every tracked.rsfile underapps/,crates/, andfeatures/(includingapps/web/,apps/installer/,apps/browser-engine/,crates/browser-pane/, and generated files outsidearch-check.shRule 8); warns> 800, errors> 1500unless ratcheted inscripts/file-size-exceptions.txt.scripts/folder-shape.sh: enforces prefix-family subfolders and folder breadth (> 40warn,> 60error).scripts/dialog-size.sh: every dialog takes anopencode_ui::dialog::DialogSizepreset (re-exported assession_view::dialog::DialogSize;Normal480 × 368,Large680 × 600,XLarge880 × 680;opencode_ui::widgets::{sized, sized_modal}, re-exported ascrate::widgetsinapps/desktop), never its own width or height.scripts/tables-check.sh: checksapps/desktop/src/stories/order.rsagainstSTORY_LIST,apps/desktop/src/shell/commands/order.rsagainst registered built-in commands,crates/opencode-i18n/locales/rune/*.jsoncoverage and unknown keys againsten.json, andcargo run -q -p opencode-plugin-spec -- --checkagainstcontract.json.scripts/guardrails/cursor-allow.mjs: the pointer's cursor follows the official app element by element (the arrow on controls; another cursor only where official's source gives one). Every.cursor(...)call, text link (.link) and selectable text (.selectable) underapps/,crates/andfeatures/is listed inscripts/cursor-allow.txt(path | kind | count | the official line that justifies it); a call that is not listed, a count that differs and a stale line all fail.
- Slow / compile checks (run separately):
scripts/clippy.sh: zero clippy diagnostics (-D warnings) across the workspace and each feature set that compiles different code.cargo check -p session-view --examples: keepsession-view's standalone examples building.pwsh scripts/web.ps1 -Check: checks thewasm32browser build (opencode-web) and runsscripts/web-clock.tsto keepstd::time::InstantandSystemTime::nowout of the browser build.
- Fast local loop & profiles:
scripts/dev-fast.sh/pwsh scripts/dev-fast.ps1with Psychoscript JS--plugin-hot(seedocs/fast-builds.md); macOS.appinstall viaapps/desktop/scripts/dev.sh(apps/desktop/scripts/bundle.sh/scripts/mac-app). - Convention: keep personal paths (
/Users/<real-name>), tailnet hostnames (*.ts.net, except*.example.ts.net), real session IDs, and credentials out of code, scripts, and commits.
The official OpenCode desktop app (https://github.com/anomalyco/opencode, mostly packages/app, packages/ui, and packages/desktop) is the reference for behaviour.
- Match it: when behaviour here differs from it, or a change here would alter what a user sees, read the official source, match it, and cite the file in a comment (e.g.
packages/app/...). - Don't copy bugs: keep a difference only where the official behaviour is plainly a bug; use judgement and say so in a comment at the site.
No implicit state machines. Any behaviour with modes or phases is an explicit state machine. Examples: lifecycle, connection and reconnect, streaming, send/queue/steer, drag, popovers and menus, focus, dialogs, quit, update, animation, and request/retry.
- No encoded state: don't encode state in combinations of
bools,Options, timestamps, counters,dismissed/pending/loadingflags or high-water marks. - Shape:
- One
enum Statewhose variants carry only the data valid in that state, so illegal states can't be represented. - One transition function,
step(&mut State, Event) -> Effects. Effects (I/O, timers, redraws, focus moves) are returned for the caller to run, not performed inside the transition. - Timers and async completions arrive as events.
- One
- Official machines: when the official app has a
*-machine.tsfor the same behaviour, match its states and transitions following the rule above. - Touched code: if you touch code that contains an implicit state machine, convert it in the same change.