refactor: reorganize, add package (opencode, osgrep, beads), add ai agent shell

This commit is contained in:
Rasyidan Akbar F. 2025-12-09 15:09:05 +07:00
commit a0f0f39399
58 changed files with 7867 additions and 42 deletions

8
packages/default.nix Normal file
View file

@ -0,0 +1,8 @@
{ pkgs, lib, beads }:
{
osgrep = pkgs.callPackage ./osgrep.nix { };
opencode = pkgs.callPackage ./opencode.nix { };
# Re-export beads from flake input for consistent access
beads = beads.packages.${pkgs.stdenv.hostPlatform.system}.default;
}

59
packages/opencode.nix Normal file
View file

@ -0,0 +1,59 @@
{ lib, stdenv, fetchzip, autoPatchelfHook }:
let
version = "1.0.137";
platformInfo = {
x86_64-darwin = {
name = "darwin-x64";
ext = "zip";
hash = "sha256-ZgzvpW8SAN0HP3Qh+aT1S+WrEoXkTZiL8/8z1w9p9Y0=";
};
aarch64-darwin = {
name = "darwin-arm64";
ext = "zip";
hash = "sha256-w5hs5arVroLtjr9pRAHYXQL+4L5gw1bJVL4DhgvrpLs=";
};
x86_64-linux = {
name = "linux-x64";
ext = "tar.gz";
hash = "sha256-N8IR3xq/dGF5jPq9/UW8Mu/PnAUb7r+Ox6nge6wKw1M=";
};
aarch64-linux = {
name = "linux-arm64";
ext = "tar.gz";
hash = "sha256-LwWbTAVnfEmCjUBNf58bgFFVVvDIQVJkLsGtYX+/EfU=";
};
};
platform = platformInfo.${stdenv.hostPlatform.system} or (throw
"Unsupported system: ${stdenv.hostPlatform.system}");
in stdenv.mkDerivation {
pname = "opencode";
inherit version;
src = fetchzip {
url =
"https://github.com/sst/opencode/releases/download/v${version}/opencode-${platform.name}.${platform.ext}";
hash = platform.hash;
stripRoot = false;
};
nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp opencode $out/bin/opencode
chmod +x $out/bin/opencode
runHook postInstall
'';
meta = {
description = "AI coding assistant CLI from SST";
homepage = "https://opencode.ai";
license = lib.licenses.mit;
mainProgram = "opencode";
platforms =
[ "x86_64-darwin" "aarch64-darwin" "x86_64-linux" "aarch64-linux" ];
};
}

7292
packages/osgrep-package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

32
packages/osgrep.nix Normal file
View file

@ -0,0 +1,32 @@
{ lib, buildNpmPackage, fetchurl, python3 }:
buildNpmPackage rec {
pname = "osgrep";
version = "0.5.16";
src = fetchurl {
url = "https://registry.npmjs.org/${pname}/-/${pname}-${version}.tgz";
hash = "sha256-V23PNxtMCdRaqr4uDOs0rptmSROUrUO7I9HazoGqUCQ=";
};
sourceRoot = "package";
postPatch = ''
cp ${./osgrep-package-lock.json} package-lock.json
'';
npmDepsHash = "sha256-JDeZ3kcsbcZM//0846i1gsvoAgMpIpN8c160cp7wB5s=";
npmFlags = [ "--legacy-peer-deps" ];
dontNpmBuild = true; # Already built in npm package
nativeBuildInputs = [ python3 ];
meta = {
description = "Semantic grep for AI agents";
homepage = "https://github.com/Ryandonofrio3/osgrep";
license = lib.licenses.asl20;
mainProgram = "osgrep";
};
}