From 7080727dce130b678e46f23f83497551dc32aece Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Tue, 3 Feb 2026 20:33:14 -0500 Subject: [PATCH] chore: update llama-cpp to b7898 and opencode to v1.1.48 - Update llama-cpp from b7867 to b7898 - Update opencode from v1.1.12 to v1.1.48 with improved build process: - Replace custom bundle script with official script/build.ts - Add shell completion support - Add version check testing - Simplify node_modules handling - Update llama-swap service config with new llama.cpp options - Clarify opencode agent testing workflow in developer and reviewer configs --- .../opencode/config/agents/developer.md | 9 +- .../opencode/config/agents/reviewer.md | 1 + modules/nixos/services/llama-swap/config.nix | 7 +- packages/llama-cpp/default.nix | 4 +- packages/opencode/bundle.ts | 33 ---- packages/opencode/default.nix | 156 +++++++----------- .../opencode/relax-bun-version-check.patch | 28 ---- ...ve-special-and-windows-build-targets.patch | 99 +++++++++++ 8 files changed, 174 insertions(+), 163 deletions(-) delete mode 100644 packages/opencode/bundle.ts delete mode 100644 packages/opencode/relax-bun-version-check.patch create mode 100644 packages/opencode/remove-special-and-windows-build-targets.patch diff --git a/modules/home/programs/terminal/opencode/config/agents/developer.md b/modules/home/programs/terminal/opencode/config/agents/developer.md index d5d5463..da831d5 100644 --- a/modules/home/programs/terminal/opencode/config/agents/developer.md +++ b/modules/home/programs/terminal/opencode/config/agents/developer.md @@ -28,7 +28,7 @@ You implement code. You're the only agent that modifies files. 1. Read the plan file 2. Read the specific files/lines mentioned in context maps 3. Read incrementally if needed (imports, function definitions, etc.) -4. Implement changes +4. Implement changes and accompanying tests 5. Commit: ```bash git add -A @@ -36,6 +36,13 @@ You implement code. You're the only agent that modifies files. ``` Types: `feat`, `fix`, `refactor`, `docs`, `test`, `chore` +**Testing Requirements:** + +- All tests must pass before committing +- Never ignore or skip failing tests +- If tests fail: either fix the code or fix the test +- Run tests after implementation to verify + **Rules:** - Trust the plan - don't re-analyze or re-plan diff --git a/modules/home/programs/terminal/opencode/config/agents/reviewer.md b/modules/home/programs/terminal/opencode/config/agents/reviewer.md index a7247e1..cddfa0c 100644 --- a/modules/home/programs/terminal/opencode/config/agents/reviewer.md +++ b/modules/home/programs/terminal/opencode/config/agents/reviewer.md @@ -26,6 +26,7 @@ You review code implementations. 1. Check `git status` - if uncommitted changes, stop and tell @developer to commit 2. Review latest commit with `git show` 3. Read full files only if needed for context +4. Do NOT run tests - you only review code **Response format:** diff --git a/modules/nixos/services/llama-swap/config.nix b/modules/nixos/services/llama-swap/config.nix index a3639e2..57178a9 100644 --- a/modules/nixos/services/llama-swap/config.nix +++ b/modules/nixos/services/llama-swap/config.nix @@ -19,8 +19,8 @@ in --port ''${PORT} \ -m /mnt/ssd/Models/GLM/GLM-4.7-Flash-UD-Q4_K_XL.gguf \ -c ''${ctx} \ + -ctk q8_0 \ --jinja \ - --threads -1 \ --temp 0.7 \ --top-p 1.0 \ --min-p 0.01 \ @@ -34,6 +34,11 @@ in env = [ "GGML_CUDA_ENABLE_UNIFIED_MEMORY=1" ]; }; + # --spec-type ngram-mod \ + # --spec-ngram-size-n 24 \ + # --draft-min 48 \ + # --draft-max 64 \ + # https://huggingface.co/unsloth/Devstral-Small-2-24B-Instruct-2512-GGUF/tree/main "devstral-small-2-instruct" = { name = "Devstral Small 2 (24B) - Instruct"; diff --git a/packages/llama-cpp/default.nix b/packages/llama-cpp/default.nix index 11dd66d..53162ca 100644 --- a/packages/llama-cpp/default.nix +++ b/packages/llama-cpp/default.nix @@ -7,12 +7,12 @@ vulkanSupport = true; }).overrideAttrs (oldAttrs: rec { - version = "7867"; + version = "7898"; src = pkgs.fetchFromGitHub { owner = "ggml-org"; repo = "llama.cpp"; tag = "b${version}"; - hash = "sha256-uAsIObuU6BboNatK58XL/YDVLmJsgU3Z6gI2vvFG+pw="; + hash = "sha256-ST7hhE5lWOm46WS+k9lkHJqVQpz8squwHZWE2/XG6MY="; leaveDotGit = true; postFetch = '' git -C "$out" rev-parse --short HEAD > $out/COMMIT diff --git a/packages/opencode/bundle.ts b/packages/opencode/bundle.ts deleted file mode 100644 index 3dce4b0..0000000 --- a/packages/opencode/bundle.ts +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bun - -import solidPlugin from "./node_modules/@opentui/solid/scripts/solid-plugin"; -import fs from "fs"; - -const version = process.env.OPENCODE_VERSION!; -const channel = process.env.OPENCODE_CHANNEL!; - -const result = await Bun.build({ - target: "bun", - outdir: "./dist", - entrypoints: ["./src/index.ts", "./src/cli/cmd/tui/worker.ts"], - plugins: [solidPlugin], - naming: { - entry: "[dir]/[name].js", - }, - define: { - OPENCODE_VERSION: JSON.stringify(version), - OPENCODE_CHANNEL: JSON.stringify(channel), - }, - external: ["@opentui/core-*"], -}); - -if (!result.success) { - console.error("Bundle failed:", result.logs); - process.exit(1); -} - -// Move worker file to worker.ts at the dist root so the code can find it -if (fs.existsSync("./dist/cli/cmd/tui/worker.js")) { - fs.renameSync("./dist/cli/cmd/tui/worker.js", "./dist/worker.ts"); - fs.rmdirSync("./dist/cli/cmd/tui", { recursive: true }); -} diff --git a/packages/opencode/default.nix b/packages/opencode/default.nix index b832992..71f9088 100644 --- a/packages/opencode/default.nix +++ b/packages/opencode/default.nix @@ -7,23 +7,24 @@ , models-dev , nix-update-script , ripgrep -, testers +, installShellFiles +, versionCheckHook , writableTmpDirAsHomeHook , }: -let +stdenvNoCC.mkDerivation (finalAttrs: { pname = "opencode"; - version = "1.1.12"; + version = "1.1.48"; src = fetchFromGitHub { owner = "anomalyco"; repo = "opencode"; - tag = "v${version}"; - hash = "sha256-k6wRBtWFwyLWJ6R0el3dY/nBlg2t+XkTpsuEseLXp+E="; + tag = "v${finalAttrs.version}"; + hash = "sha256-zKkeJSsxEuhucQkWBHxLR7tCTu86q2p6neRST2g/1hA="; # "sha256-RTj64yrVLTFNpVc8MvPAJISOlBo/j2MnuL5jo4VtKWM="; }; node_modules = stdenvNoCC.mkDerivation { - pname = "${pname}-node_modules"; - inherit version src; + pname = "${finalAttrs.pname}-node_modules"; + inherit (finalAttrs) version src; impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ "GIT_PROXY_COMMAND" @@ -40,20 +41,17 @@ let buildPhase = '' runHook preBuild - export BUN_INSTALL_CACHE_DIR=$(mktemp -d) - bun install \ --cpu="*" \ - --filter=./packages/opencode \ - --force \ --frozen-lockfile \ + --filter ./packages/opencode \ + --filter ./packages/desktop \ --ignore-scripts \ --no-progress \ - --os="*" \ - --production + --os="*" - bun run ./nix/scripts/canonicalize-node-modules.ts - bun run ./nix/scripts/normalize-bun-binaries.ts + bun --bun ./nix/scripts/canonicalize-node-modules.ts + bun --bun ./nix/scripts/normalize-bun-binaries.ts runHook postBuild ''; @@ -62,12 +60,7 @@ let runHook preInstall mkdir -p $out - while IFS= read -r dir; do - rel="''${dir#./}" - dest="$out/$rel" - mkdir -p "$(dirname "$dest")" - cp -R "$dir" "$dest" - done < <(find . -type d -name node_modules -prune | sort) + find . -type d -name node_modules -exec cp -R --parents {} $out \; runHook postInstall ''; @@ -75,34 +68,35 @@ let # NOTE: Required else we get errors that our fixed-output derivation references store paths dontFixup = true; - outputHash = "sha256-vRIWQt02VljcoYG3mwJy8uCihSTB/OLypyw+vt8LuL8="; + outputHash = "sha256-aQScGeakRanvH1LxizXrWA17YOmJJfRuypX4Jau4zQw="; # "sha256-37pmIiJzPEWeA7+5u5lz39vlFPI+N13Qw9weHrAaGW4="; outputHashAlgo = "sha256"; outputHashMode = "recursive"; }; -in -stdenvNoCC.mkDerivation (finalAttrs: { - inherit - pname - version - src - node_modules - ; nativeBuildInputs = [ bun + installShellFiles makeBinaryWrapper models-dev + writableTmpDirAsHomeHook ]; patches = [ - ./relax-bun-version-check.patch # NOTE: Relax Bun version check to be a warning instead of an error + ./remove-special-and-windows-build-targets.patch # NOTE: Remove special and windows build targes ./root_fix.patch # https://github.com/anomalyco/opencode/pull/7691 ]; + postPatch = '' + # NOTE: Relax Bun version check to be a warning instead of an error + substituteInPlace packages/script/src/index.ts \ + --replace-fail 'throw new Error(`This script requires bun@''${expectedBunVersionRange}' \ + 'console.warn(`Warning: This script requires bun@''${expectedBunVersionRange}' + ''; + configurePhase = '' runHook preConfigure - cp -R ${node_modules}/. . + cp -R ${finalAttrs.node_modules}/. . runHook postConfigure ''; @@ -113,13 +107,6 @@ stdenvNoCC.mkDerivation (finalAttrs: { preBuild = '' chmod -R u+w ./packages/opencode/node_modules - pushd ./packages/opencode/node_modules/@parcel/ - for pkg in ../../../../node_modules/.bun/@parcel+watcher-*; do - linkName=$(basename "$pkg" | sed 's/@.*+\(.*\)@.*/\1/') - ln -sf "$pkg/node_modules/@parcel/$linkName" "$linkName" - done - popd - pushd ./packages/opencode/node_modules/@opentui/ for pkg in ../../../../node_modules/.bun/@opentui+core-*; do linkName=$(basename "$pkg" | sed 's/@.*+\(.*\)@.*/\1/') @@ -131,74 +118,47 @@ stdenvNoCC.mkDerivation (finalAttrs: { buildPhase = '' runHook preBuild - cd ./packages/opencode - cp ${./bundle.ts} ./bundle.ts - bun run ./bundle.ts + bun --bun ./script/build.ts --single --skip-install + bun --bun ./script/schema.ts schema.json runHook postBuild ''; - dontStrip = true; - installPhase = '' runHook preInstall - mkdir -p $out/lib/opencode - # Copy the bundled dist directory - cp -r dist $out/lib/opencode/ - - # Fix WASM paths in worker.ts - use absolute paths to the installed location - # Main wasm is tree-sitter-.wasm, language wasms are tree-sitter--.wasm - main_wasm=$(find "$out/lib/opencode/dist" -maxdepth 1 -name 'tree-sitter-[a-z0-9]*.wasm' -print -quit) - - substituteInPlace $out/lib/opencode/dist/worker.ts \ - --replace-fail 'module2.exports = "../../../tree-sitter-' 'module2.exports = "'"$out"'/lib/opencode/dist/tree-sitter-' \ - --replace-fail 'new URL("tree-sitter.wasm", import.meta.url).href' "\"$main_wasm\"" - - # Copy only the native modules we need (marked as external in bundle.ts) - mkdir -p $out/lib/opencode/node_modules/.bun - mkdir -p $out/lib/opencode/node_modules/@opentui - - # Copy @opentui/core platform-specific packages - for pkg in ../../node_modules/.bun/@opentui+core-*; do - if [ -d "$pkg" ]; then - cp -r "$pkg" $out/lib/opencode/node_modules/.bun/$(basename "$pkg") - fi - done - - mkdir -p $out/bin - makeWrapper ${lib.getExe bun} $out/bin/opencode \ - --add-flags "run" \ - --add-flags "$out/lib/opencode/dist/index.js" \ - --prefix PATH : ${ - lib.makeBinPath [ - fzf - ripgrep - ] - } \ - --argv0 opencode + install -Dm755 dist/opencode-*/bin/opencode $out/bin/opencode + install -Dm644 schema.json $out/share/opencode/schema.json runHook postInstall ''; - postInstall = '' - # Add symlinks for platform-specific native modules - for pkg in $out/lib/opencode/node_modules/.bun/@opentui+core-*; do - if [ -d "$pkg" ]; then - pkgName=$(basename "$pkg" | sed 's/@opentui+\(core-[^@]*\)@.*/\1/') - ln -sf ../.bun/$(basename "$pkg")/node_modules/@opentui/$pkgName \ - $out/lib/opencode/node_modules/@opentui/$pkgName - fi - done + postInstall = lib.optionalString (stdenvNoCC.buildPlatform.canExecute stdenvNoCC.hostPlatform) '' + installShellCompletion --cmd opencode \ + --bash <($out/bin/opencode completion) ''; + postFixup = '' + wrapProgram $out/bin/opencode \ + --prefix PATH : ${ + lib.makeBinPath [ + fzf + ripgrep + ] + } + ''; + + nativeInstallCheckInputs = [ + versionCheckHook + writableTmpDirAsHomeHook + ]; + doInstallCheck = true; + versionCheckKeepEnvironment = [ "HOME" ]; + versionCheckProgramArg = "--version"; + passthru = { - tests.version = testers.testVersion { - package = finalAttrs.finalPackage; - command = "HOME=$(mktemp -d) opencode --version"; - inherit (finalAttrs) version; - }; + jsonschema = "${placeholder "out"}/share/opencode/schema.json"; updateScript = nix-update-script { extraArgs = [ "--subpackage" @@ -209,13 +169,13 @@ stdenvNoCC.mkDerivation (finalAttrs: { meta = { description = "AI coding agent built for the terminal"; - longDescription = '' - OpenCode is a terminal-based agent that can build anything. - It combines a TypeScript/JavaScript core with a Go-based TUI - to provide an interactive AI coding experience. - ''; - homepage = "https://github.com/sst/opencode"; + homepage = "https://github.com/anomalyco/opencode"; license = lib.licenses.mit; + maintainers = with lib.maintainers; [ + delafthi + graham33 + ]; + sourceProvenance = with lib.sourceTypes; [ fromSource ]; platforms = [ "aarch64-linux" "x86_64-linux" diff --git a/packages/opencode/relax-bun-version-check.patch b/packages/opencode/relax-bun-version-check.patch deleted file mode 100644 index 5d14f16..0000000 --- a/packages/opencode/relax-bun-version-check.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0e07ea8225f5667e39c6aa59eea726266f0afab0 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= -Date: Thu, 13 Nov 2025 10:16:31 +0100 -Subject: [PATCH] Change Bun version check from error to warning -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Signed-off-by: Jörg Thalheim ---- - packages/script/src/index.ts | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/packages/script/src/index.ts b/packages/script/src/index.ts -index 141d2b75..de06d0dc 100644 ---- a/packages/script/src/index.ts -+++ b/packages/script/src/index.ts -@@ -10,7 +10,7 @@ if (!expectedBunVersion) { - } - - if (process.versions.bun !== expectedBunVersion) { -- throw new Error(`This script requires bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`) -+ console.warn(`Warning: This script expects bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`) - } - - const CHANNEL = process.env["OPENCODE_CHANNEL"] ?? (await $`git branch --show-current`.text().then((x) => x.trim())) --- -2.51.0 diff --git a/packages/opencode/remove-special-and-windows-build-targets.patch b/packages/opencode/remove-special-and-windows-build-targets.patch new file mode 100644 index 0000000..43cff96 --- /dev/null +++ b/packages/opencode/remove-special-and-windows-build-targets.patch @@ -0,0 +1,99 @@ +From 4d0a82e8f3cf8bf011e2592677db4aa31b6b290b Mon Sep 17 00:00:00 2001 +From: Thierry Delafontaine +Date: Sun, 4 Jan 2026 20:55:49 +0100 +Subject: [PATCH] Remove special and windows build targets + +--- + packages/opencode/script/build.ts | 70 +++++++++++++++---------------- + 1 file changed, 35 insertions(+), 35 deletions(-) + +diff --git a/packages/opencode/script/build.ts b/packages/opencode/script/build.ts +index f51cb2924..ee3c0e863 100755 +--- a/packages/opencode/script/build.ts ++++ b/packages/opencode/script/build.ts +@@ -33,27 +33,27 @@ const allTargets: { + os: "linux", + arch: "x64", + }, +- { +- os: "linux", +- arch: "x64", +- avx2: false, +- }, +- { +- os: "linux", +- arch: "arm64", +- abi: "musl", +- }, +- { +- os: "linux", +- arch: "x64", +- abi: "musl", +- }, +- { +- os: "linux", +- arch: "x64", +- abi: "musl", +- avx2: false, +- }, ++ // { ++ // os: "linux", ++ // arch: "x64", ++ // avx2: false, ++ // }, ++ // { ++ // os: "linux", ++ // arch: "arm64", ++ // abi: "musl", ++ // }, ++ // { ++ // os: "linux", ++ // arch: "x64", ++ // abi: "musl", ++ // }, ++ // { ++ // os: "linux", ++ // arch: "x64", ++ // abi: "musl", ++ // avx2: false, ++ // }, + { + os: "darwin", + arch: "arm64", +@@ -62,20 +62,20 @@ const allTargets: { + os: "darwin", + arch: "x64", + }, +- { +- os: "darwin", +- arch: "x64", +- avx2: false, +- }, +- { +- os: "win32", +- arch: "x64", +- }, +- { +- os: "win32", +- arch: "x64", +- avx2: false, +- }, ++ // { ++ // os: "darwin", ++ // arch: "x64", ++ // avx2: false, ++ // }, ++ // { ++ // os: "win32", ++ // arch: "x64", ++ // }, ++ // { ++ // os: "win32", ++ // arch: "x64", ++ // avx2: false, ++ // }, + ] + + const targets = singleFlag +-- +2.52.0