feat(runtime): add pi-coding-agent package with CLI tools
- Added pi-coding-agent package definition with buildNpmPackage - Includes npm dependencies and native/build inputs for GUI libraries - Skips generate-models step during build (models already in repo) - Creates 'pi' executable pointing to coding-agent dist/cli.js - Includes update.sh script for version/hash maintenance Fixes build issues where generate-models would fail during build phase
This commit is contained in:
85
packages/pi-coding-agent/default.nix
Normal file
85
packages/pi-coding-agent/default.nix
Normal file
@@ -0,0 +1,85 @@
|
||||
{ lib
|
||||
, buildNpmPackage
|
||||
, fetchFromGitHub
|
||||
, nodejs
|
||||
, pkg-config
|
||||
, pixman
|
||||
, cairo
|
||||
, pango
|
||||
, libjpeg
|
||||
, giflib
|
||||
, librsvg
|
||||
,
|
||||
}:
|
||||
|
||||
buildNpmPackage rec {
|
||||
pname = "pi-coding-agent";
|
||||
version = "0.51.6";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "badlogic";
|
||||
repo = "pi-mono";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-P9IXfHr3brqCP8eQVLn1Sl6yJ9Bx7weqxyk6iHKWZpo=";
|
||||
};
|
||||
|
||||
npmDepsHash = "sha256-dDh9nk3w1pevSbOV20pFAqmHGcjTw9HUV0Z1BLYMNJU=";
|
||||
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
buildInputs = [
|
||||
pixman
|
||||
cairo
|
||||
pango
|
||||
libjpeg
|
||||
giflib
|
||||
librsvg
|
||||
];
|
||||
|
||||
# Skip generate-models in ai package (models.generated.ts already in repo)
|
||||
preBuild = ''
|
||||
substituteInPlace packages/ai/package.json \
|
||||
--replace-fail '"build": "npm run generate-models && tsgo -p tsconfig.build.json"' \
|
||||
'"build": "tsgo -p tsconfig.build.json"'
|
||||
'';
|
||||
|
||||
# Build coding-agent dependencies in order
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
|
||||
cd packages/tui && npm run build && cd ../..
|
||||
cd packages/ai && npm run build && cd ../..
|
||||
cd packages/agent && npm run build && cd ../..
|
||||
cd packages/coding-agent && npm run build && cd ../..
|
||||
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/lib/pi-coding-agent $out/bin
|
||||
|
||||
# Copy node_modules and the packages directory
|
||||
cp -r node_modules $out/lib/pi-coding-agent/
|
||||
cp -r packages $out/lib/pi-coding-agent/
|
||||
|
||||
cat > $out/bin/pi <<EOF
|
||||
#!${nodejs}/bin/node
|
||||
import('$out/lib/pi-coding-agent/packages/coding-agent/dist/cli.js');
|
||||
EOF
|
||||
chmod +x $out/bin/pi
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Coding agent CLI with read, bash, edit, write tools and session management";
|
||||
homepage = "https://github.com/badlogic/pi-mono";
|
||||
downloadPage = "https://www.npmjs.com/package/@mariozechner/pi-coding-agent";
|
||||
changelog = "https://github.com/badlogic/pi-mono/blob/main/packages/coding-agent/CHANGELOG.md";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = with lib.maintainers; [ evanreichard ];
|
||||
mainProgram = "pi";
|
||||
};
|
||||
}
|
||||
15
packages/pi-coding-agent/update.sh
Normal file
15
packages/pi-coding-agent/update.sh
Normal file
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env nix
|
||||
#!nix shell --ignore-environment .#cacert .#nodejs .#git .#nix-update .#nix .#gnused .#findutils .#bash --command bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
version=$(npm view @mariozechner/pi-coding-agent version)
|
||||
|
||||
# Update version and hashes
|
||||
nix-update pi-coding-agent --version="$version" --generate-lockfile
|
||||
|
||||
# nix-update can't update package-lock.json along with npmDepsHash
|
||||
# TODO: Remove this workaround if nix-update can update package-lock.json along with npmDepsHash.
|
||||
(nix-build --expr '((import ./.) { system = builtins.currentSystem; }).pi-coding-agent.npmDeps.overrideAttrs { outputHash = ""; outputHashAlgo = "sha256"; }' 2>&1 || true) \
|
||||
| sed -nE '$s/ *got: *(sha256-[A-Za-z0-9+/=-]+).*/\1/p' \
|
||||
| xargs -I{} sed -i 's|npmDepsHash = "sha256-[^"]*";|npmDepsHash = "{}";|' pkgs/by-name/pi/pi-coding-agent/package.nix
|
||||
Reference in New Issue
Block a user