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 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";
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user