diff --git a/experimental/pi-everything-edition/flake.lock b/experimental/pi-everything-edition/flake.lock new file mode 100644 index 0000000..352298d --- /dev/null +++ b/experimental/pi-everything-edition/flake.lock @@ -0,0 +1,162 @@ +{ + "nodes": { + "bun2nix": { + "inputs": { + "flake-parts": [ + "llm-agents", + "flake-parts" + ], + "nixpkgs": [ + "llm-agents", + "nixpkgs" + ], + "systems": [ + "llm-agents", + "systems" + ], + "treefmt-nix": [ + "llm-agents", + "treefmt-nix" + ] + }, + "locked": { + "lastModified": 1788011267, + "narHash": "sha256-mEq2kU+ljompTToZ44Afvm7d/rHJ5iMBl0tjZuyShJs=", + "owner": "Mic92", + "repo": "bun2nix", + "rev": "5765b0614591f75ee8ba5596e81ae85c167d1071", + "type": "github" + }, + "original": { + "owner": "Mic92", + "ref": "fix-structured-attrs-hook", + "repo": "bun2nix", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "llm-agents", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1788450739, + "narHash": "sha256-glZLQlzIn1fXH6PazR2iUmTo7kzzyYSshrWhLS9TqCU=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "31729ca8cbdb4fa927b34e5f4353e6a83f39e993", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "llm-agents": { + "inputs": { + "bun2nix": "bun2nix", + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "systems": "systems", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1789915986, + "narHash": "sha256-pAC+DUWg2MLosBAh+fSserUm4OiTRclGal7BhBCqiZM=", + "owner": "numtide", + "repo": "llm-agents.nix", + "rev": "eacea85aeddb2b401e907b562c0b2f3640da615f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "llm-agents.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1789754019, + "narHash": "sha256-N8gMcziRWB1CnSykjQPuf8lQKDD69LjnURRzaNXoPb4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2e032a04454b525daa6c6651264aaa5d3e98cf54", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "pi-automode": { + "flake": false, + "locked": { + "lastModified": 1788810790, + "narHash": "sha256-AZf+wH83JBjgwvkLFEewEdkCtT2sD8CTChwblMAY5aM=", + "owner": "czottmann", + "repo": "pi-automode", + "rev": "4ede089a7a49f2e2ab71eff8488b2dbd68553d0b", + "type": "github" + }, + "original": { + "owner": "czottmann", + "ref": "v1.16.0", + "repo": "pi-automode", + "type": "github" + } + }, + "root": { + "inputs": { + "llm-agents": "llm-agents", + "nixpkgs": [ + "llm-agents", + "nixpkgs" + ], + "pi-automode": "pi-automode" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "llm-agents", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1786901030, + "narHash": "sha256-WSFCsDSE5ffgD2MqzkM2CYjeFiKhRF/dJUN8uedb6YE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "27b3b12a8e6375f28ebe122f07d230ca5459bbfa", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/experimental/pi-everything-edition/flake.nix b/experimental/pi-everything-edition/flake.nix new file mode 100644 index 0000000..3aa2be9 --- /dev/null +++ b/experimental/pi-everything-edition/flake.nix @@ -0,0 +1,117 @@ +{ + description = "Pi with Gondolin isolation and Claude Code-style automatic permission review"; + + inputs = { + llm-agents.url = "github:numtide/llm-agents.nix"; + nixpkgs.follows = "llm-agents/nixpkgs"; + + pi-automode = { + url = "github:czottmann/pi-automode/v1.16.0"; + flake = false; + }; + }; + + outputs = + { + self, + nixpkgs, + llm-agents, + pi-automode, + }: + let + systems = [ + "aarch64-darwin" + "x86_64-linux" + "aarch64-linux" + ]; + in + { + packages = nixpkgs.lib.genAttrs systems ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + inherit (pkgs) lib; + upstream = llm-agents.packages.${system}.pi; + + # Upstream's lock has incomplete integrity metadata in dev-only nested + # packages. Retain its complete runtime dependency closure instead. + automodeSource = pkgs.runCommand "pi-automode-1.16.0-runtime-source" { nativeBuildInputs = [ pkgs.jq ]; } '' + cp -R ${pi-automode}/. "$out" + chmod -R u+w "$out" + jq 'del(.devDependencies, .peerDependencies)' \ + "$out/package.json" > "$out/package.json.new" + mv "$out/package.json.new" "$out/package.json" + jq ' + del(.packages[""].devDependencies, .packages[""].peerDependencies) + | .packages |= with_entries(select(.key == "" or ((.value.dev // false) | not))) + ' "$out/package-lock.json" > "$out/package-lock.json.new" + mv "$out/package-lock.json.new" "$out/package-lock.json" + ''; + + automode = pkgs.buildNpmPackage { + pname = "pi-automode-extension"; + version = "1.16.0"; + src = automodeSource; + npmDepsHash = "sha256-iWUfwecra8jfCHJms7U3zHgwMqGd3BdsSbwzRSD7AtQ="; + dontNpmBuild = true; + dontNpmRebuild = true; + installPhase = '' + runHook preInstall + mkdir -p "$out" + cp -R extensions skills package.json node_modules "$out/" + runHook postInstall + ''; + }; + + gondolin = pkgs.buildNpmPackage { + pname = "pi-gondolin-extension"; + inherit (upstream) version; + src = "${upstream}/libexec/pi/examples/extensions/gondolin"; + npmDepsHash = "sha256-qLEXRuMq6Rzawmy2oEdKv31TPQiuU8ZSCUqxqLcyR1o="; + dontNpmBuild = true; + dontNpmRebuild = true; + installPhase = '' + runHook preInstall + mkdir -p "$out" + cp -R index.ts package.json node_modules "$out/" + runHook postInstall + ''; + }; + + pi-everything-edition = pkgs.symlinkJoin { + name = "pi-everything-edition-${upstream.version}"; + paths = [ upstream ]; + postBuild = '' + rm "$out/bin/pi" + cat >"$out/bin/pi" <<'EOF' + #!${pkgs.runtimeShell} + export PATH=${lib.makeBinPath [ pkgs.qemu ]}:$PATH + + case "''${1-}" in + install|remove|uninstall|update|list|config) + exec ${lib.getExe upstream} "$@" + ;; + esac + + exec ${lib.getExe upstream} \ + --extension ${automode}/extensions/auto-mode.ts \ + --extension ${gondolin} \ + --skill ${automode}/skills/automode-diagnostics \ + "$@" + EOF + chmod +x "$out/bin/pi" + ''; + meta = upstream.meta // { + mainProgram = "pi"; + description = "${upstream.meta.description} with pi-automode and Gondolin"; + }; + }; + in + { + default = pi-everything-edition; + pi = pi-everything-edition; + inherit automode gondolin; + } + ); + }; +}