Dashboard › opencode › Distillation
8a5c1121-81f0-4cd9-9c60-1ebc475ccb1d["lore_tm_v1_1ggf8mNKERAqayxF3E0Ofyiy0GOZWuXZqgXiN_GA0Po","lore_tm_v1_Tbih489jR9WmmY1IPaPA1QhpuVWrs6QYTMt1vAfDP5U","lore_tm_v1_8LPDWbMfU0vzaoyOzp6wB2DBC838uLKZdnas6OM4wkg","lore_tm_v1_sCsmYX3Xcjro-FgAkeGgcLGbzGltsr4btb50IsdP2W0","lore_tm_v1_wt0QnpndCpcH7QT7TRH3KZaOWMHPnzc47nYyQDa_OPc","lore_tm_v1_zYzrds9SGn9wOOWdTWNwosC1rdlh9fqXgKy6fzCegG4","lore_tm_v1_jVLEJ15HkxCdhlQH3e8PjTtmasBpqR6942IJBP2kHBw","lore_tm_v1_VQWntzTugndDhtW9_h7zyvenaoE8ayhAVFJAnNgzLJQ","lore_tm_v1_EDZJWqRpfxMmS8eT3EfIvYlCIwBaX7_BbTWE1qVrjOI","lore_tm_v1_w1oyzUI9sX3ApA1cSWF5iLs2tuVJME-96ugAzNmSDxY","lore_tm_v1_Ak_5WpsdqdvFa2YZ3b-EUrHP5T0fzKtTDMAgbY_O9_o"]
Date: Sep 8, 2026
/home/byk/Code/opencode-v2-pilot/packages/core/src/shell/parse.ts:13-171 defines shell scanning with Result = { commands: Array<{ resource: string; save: string }>; directories: string[] }, CWD-changing commands cd, chdir, popd, pushd, push-location, and set-location, PowerShell path flags -literalpath and -path, and an ARITY map whose maximum prefix length is 3. scan(command, shell, cwd, options?) selects scanPortable only when options?.portable is true; otherwise it uses scanLegacy./home/byk/Code/opencode-v2-pilot/packages/core/src/shell/parse.ts:22-160 assigns command-prefix arities: single-token commands use 1; most CLI roots use 2; and selected roots/subcommands use 3, including aws, az, doctl, gcloud, gh, sfdx, bun run, bun x, cargo add, cargo run, consul kv, docker builder, docker compose, docker container, docker image, docker network, docker volume, eksctl create, git config, git remote, git stash, ip addr, ip link, ip netns, ip route, kind create, kubectl kustomize, kubectl rollout, mc admin, npm exec, npm init, npm run, npm view, openssl req, openssl x509, pnpm dlx, pnpm exec, pnpm run, podman container, podman image, pulumi stack, terraform workspace, vault auth, vault kv, yarn dlx, and yarn run./home/byk/Code/opencode-v2-pilot/packages/core/src/shell/parse.ts:173-205 implements scanLegacy using lazily loaded Tree-sitter PowerShell or Bash parsers. A parse failure raises Error("Failed to parse shell command"); each descendant command is tokenized via parts(), CWD commands contribute normalized directory arguments, and other commands produce a resource from the enclosing redirected_statement when present plus a saved wildcard grant ${prefix(tokens).join(" ")} *. The parse tree is deleted through Effect.acquireUseRelease./home/byk/Code/opencode-v2-pilot/packages/core/src/shell/parse.ts:207-265 implements scanPortable through dynamic import of ./scan.js; import failures become Error("Portable shell scanner failed to load: ..."), and opaque scans fail with Error("Portable shell scanner cannot analyze command: ..."). It skips declarations, truncates words before redirects using redirectWordCount, skips PowerShell statement-head words matching /^foreach(?:-|$)/i, splits inline PowerShell -LiteralPath:value/-Path:value into parameter and word parts, and computes conventional grants from at most PREFIX_LENGTH words./home/byk/Code/opencode-v2-pilot/packages/core/src/shell/parse.ts:244-258 preserves existing portable-scan grants as the conventional normalized ${selected.join(" ")} * unless PowerShell normalization loses the original source boundary. In that case it uses wordEnds, searches for a whitespace/source boundary, preserves whitespace and optional backtick-newline continuation with /^\s+(?:(?:\r\n|\r|\n)\s*)?/, and appends *` to the original source slice.opencode2 references. Build/package references include .github/workflows/publish.yml:171, root package.json:11, nix/opencode.nix:65,67,83-85,104, nix/desktop.nix:93, packages/cli/package.json:8, packages/cli/vite.node.config.ts:269, packages/cli/script/build.ts:15, packages/cli/script/build-node.ts:114, packages/cli/script/publish.ts:123,131, packages/cli/script/publish-aur.ts:14,72, and packages/cli/script/service-smoke.ts:14.opencode2 search found runtime/UI/test references in packages/session-ui/src/storybook/current-session-fixtures.ts:523, packages/tui/src/util/presentation.ts:32, packages/tui/test/util/presentation.test.ts:7, packages/cli/src/services/updater.ts:103, packages/cli/test/updater-install.test.ts:219,236, packages/desktop/src/main/wsl/servers.test.ts:12-13,26,43,135,170,207, packages/desktop/src/main/wsl/runtime.ts:334, packages/desktop/src/main/wsl/local.ts:36,44, packages/desktop/src/main/service/desktop-cli.ts:40, packages/desktop/scripts/utils.ts:79,92, packages/app/src/runtime/i18n/desktop-native.ts:288, packages/core/src/plugin/websearch/tavily.ts:54, and packages/core/test/plugin/websearch.test.ts:259,275./home/byk/Code/opencode-v2-pilot/packages/cli/script/build-node.ts:17-67 pins NODE_VERSION = "26.4.0" and supports flags --outdir=, --bundle-only, --single, --skip-install, --app-archive-only, --app-archive=, and --target=. Default targets are Linux arm64/x64, Darwin arm64, and Windows arm64/x64. darwin-x64 is explicitly rejected because Node 26.4 SEA does not support macOS x64; output cannot be the package directory or dist-node./home/byk/Code/opencode-v2-pilot/packages/cli/script/build-node.ts:47-63 runs process.execPath install --os=* --cpu=* unless --skip-install. --app-archive-only requires --app-archive=<path>, writes buildAppArchive(Script.channel), and exits. A supplied app archive is read and trimmed; otherwise the archive is built directly./home/byk/Code/opencode-v2-pilot/packages/cli/script/build-node.ts:69-85 defines assertTextImportsInlined(bundlePath), checking that the bundle contains "zhipuai" and does not contain /assets/snapshot or ="/assets/. This guards against Vite silently rewriting .txt imports into asset URLs, including the models.dev snapshot and bundled prompt/tool descriptions./home/byk/Code/opencode-v2-pilot/packages/cli/script/build-node.ts:88-154 builds each Node target as cli-node-${targetName(target)}: collects and hashes assets, rebuilds dist-node, invokes Vite with mainConfig, validates dist-node/opencode.mjs, runs host --version and --help smoke checks, and emits opencode2-node or opencode2-node.exe. SEA config uses mainFormat: "module", disableExperimentalSEAWarning: true, useSnapshot: false, useCodeCache: false, execArgv: nodeExecArgv, execArgvExtension: "none", and assets from seaAssetMap(). Non-Windows outputs receive mode 0o755; native macOS builds are ad-hoc signed with codesign --sign -; cross-built macOS output emits a signing warning./home/byk/Code/opencode-v2-pilot/packages/cli/script/build-node.ts:137-153 writes a package manifest named @opencode/cli-node-${targetName(target)} with Script.version, the CLI package license, repository git+https://github.com/anomalyco/opencode.git, and exact target os/cpu; it then calls verifyArtifact, followed by smoke(output) for host builds./home/byk/Code/opencode-v2-pilot/packages/cli/script/build-node.ts:156-220 resolves a host Node 26.4.0 from NODE_BIN or node; otherwise it downloads a target runtime from https://nodejs.org/dist/v26.4.0, verifies SHA-256 against SHASUMS256.txt, and caches it under .cache/node/node-v26.4.0-${platform}-${arch} with a .verified marker. Extraction uses tar -xzf, Windows System32\tar.exe, or unzip -q depending on host/target.@opencode/client and location-scoped data in packages/tui/src/context/data.tsx rather than adding dependencies on legacy sync state, and preserving established TUI behavior unless a task intentionally changes it./home/byk/Code/opencode-v2-pilot/packages/plugin/src/source.node.ts:7-43 implements fresh plugin-source loading with a monotonically incremented generation initialized from Date.now(). prepareSource(entrypoint, track) adds __opencode_reload=<version> query parameters, registers a Node module resolve hook, and only propagates freshness through imports whose parent has the current reload version./home/byk/Code/opencode-v2-pilot/packages/plugin/src/source.node.ts:20-42 resolves relative imports directly and bare imports through localSource(specifier, dirname(parentURL)); node_modules and non-file: resolutions remain untouched. Failed local resolution tracks the containing directory with track(directory, true) before rethrowing; successful local files call track(file) and receive a fresh URL. The returned object is { version: specifier, load: () => Host.load(specifier), dispose: () => hook.deregister() }./home/byk/Code/opencode-v2-pilot/packages/protocol/src/groups/session.ts:378-396 defines POST /api/session/:sessionID/skill as endpoint session.skill (v2.session.skill), with optional SessionMessage.ID, required Skill.ID, optional resume, NoContent success, and errors SessionNotFoundError and SkillNotFoundError./home/byk/Code/opencode-v2-pilot/packages/protocol/src/groups/session.ts:398-419 defines POST /api/session/:sessionID/synthetic as endpoint session.synthetic (v2.session.synthetic). Its payload has optional SessionMessage.ID, required text, optional description, required SessionMessage.Synthetic.fields.metadata, optional SessionInbox.Delivery, and optional resume; success is { data: SessionInbox.Synthetic }, with ConflictError and SessionNotFoundError. Its description states that synthetic input is durably admitted and execution is scheduled unless resume is false./home/byk/Code/opencode-v2-pilot/packages/protocol/src/groups/session.ts:421-439 defines POST /api/session/:sessionID/shell as endpoint session.shell (v2.session.shell), accepting optional Event.ID and required command, returning NoContent, and exposing SessionNotFoundError. The endpoint executes one shell command in the session working directory and emits shell.started before execution and shell.ended with merged output afterward./home/byk/Code/opencode-v2-pilot/packages/server/src/handlers/session.ts:360-404 maps session.skill to session.skill(...), translating Session.NotFoundError and Session.SkillNotFoundError; the latter becomes SkillNotFoundError with message Skill not found: ${error.skill}. It maps session.synthetic to session.synthetic(...), translating Session.NotFoundError and Session.SyntheticConflictError; a conflict becomes ConflictError with message Synthetic input ID conflicts with an existing durable record: ${error.inputID} and resource: error.inputID./home/byk/Code/opencode-v2-pilot/packages/core/src/session.ts:380-430 delegates location-scoped session operations through sessions.forSession(sessionID) for prompt, shell, skill, switchAgent, switchModel, rename, compact, wait, resume, synthetic, interrupt, and revert operations. generate separately provides Instance.Service, Database.Service, and LLMClient.Service; command provides Instance.Service./home/byk/Code/opencode-v2-pilot/packages/core/src/session.ts:404-420 implements Session.background: validates the session, calls jobs.backgroundAll({ sessionID }), returns when no jobs were backgrounded, otherwise admits a synthetic message listing each backgrounded job as - ${job.type}: ${job.title || job.id} and instructing the model that work remains unfinished, to continue other useful work or finish its response, and not to wait, sleep, poll, or report completion until a later completion notification. Session.SyntheticConflictError is converted to a defect with Effect.die./home/byk/Code/opencode-v2-pilot/packages/core/src/session/session.ts:255-273 implements Session.compact: retrieves the session, commits an existing revert, creates SessionMessage.ID when absent, admits compaction with default delivery "steer", translates SessionInbox.LifecycleConflict to CompactionConflictError({ sessionID, inputID }), wakes execution, and returns the admitted input./home/byk/Code/opencode-v2-pilot/packages/core/src/session/session.ts:274-327 defines wait as session validation plus execution.awaitIdle, resume as validation plus execution.resume, and interrupt as uninterruptible execution.interrupt(sessionID, options)./home/byk/Code/opencode-v2-pilot/packages/core/src/session/session.ts:282-323 implements Session.synthetic as an uninterruptible operation. It validates the session, creates an input ID when absent, constructs a SessionInbox.Item of type "synthetic" with SessionInbox.SyntheticPayload.make({ text, description, metadata }) and default delivery "steer", durably admits it, maps SessionInbox.LifecycleConflict to SyntheticConflictError({ sessionID, inputID }), and wakes execution only when resume !== false and the session is not reverted./home/byk/Code/opencode-v2-pilot/packages/core/src/session/session.ts:328-354 makes revert stage and clear fail with BusyError({ sessionID }) while execution is active. stage provides Instance.Service, Database.Service, and Bus.Service; clear provides Instance.Service and Bus.Service then wakes execution; commit also rejects active execution before calling SessionRevert.commit./home/byk/Code/opencode-v2-pilot/packages/core/src/session/session.ts:355-427 collects session operations and exposes a forSession(sessionID) facade with all methods bound to that ID: get, message, updateMessage, view, rename, switchAgent, switchModel, inbox, prompt, synthetic, shell, skill, compact, wait, resume, interrupt, cancelInbox, steerInbox, queueInbox, and revert stage, clear, and commit./home/byk/Code/opencode-v2-pilot/packages/core/src/session/message-updater.ts:120-179 clears current retry state on session.execution.succeeded, .failed, and .interrupted. session.instructions.updated appends a system message only when event.data.text exists, using SessionMessage.ID.fromEvent(event.id) and description Instructions updated: ${Object.keys(event.data.delta).join(", ")}. session.synthetic appends a synthetic message carrying text, description, metadata, event-derived ID, and creation time; session.skill.activated appends a skill message; session.shell.started appends a shell message and merges background: true into metadata when indicated.packages/core/test/tool-subagent.test.ts, tool-shell.test.ts, session-shell.test.ts, session-runner.test.ts, session-prompt.test.ts, session-projector.test.ts, session-instructions.test.ts, session-execution.test.ts, and config/command-subagent.test.ts; runtime references occur in packages/tui/src/routes/session/rows.ts, packages/core/src/session/transfer.ts, instructions.ts, inbox.ts, compaction.ts, runner/to-llm-message.ts, packages/client/src/solid/data.ts, and packages/app/src/session/requests/background.ts./home/byk/Code/opencode-v2-pilot/packages/tui/src/routes/session/rows.ts includes treating user and synthetic messages similarly for input tracking and indexing, recognizing synthetic inbox items with nonblank descriptions, and omitting synthetic messages with no nonblank description from rendered rows.