Skip to content

Commit 9dee8f8

Browse files
authored
Merge pull request #709 from zrubing/main
ECA - Editor Code Assistant
2 parents 973f640 + 60fa65c commit 9dee8f8

File tree

4 files changed

+238
-0
lines changed

4 files changed

+238
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ This repository uses GitHub Actions to automatically update all packages and fla
4444
- **Homepage**: https://github.com/wandb/catnip
4545
- **Usage**: `nix run .#catnip -- --help`
4646

47+
#### eca
48+
49+
- **Description**: Editor Code Assistant (ECA) - AI pair programming capabilities agnostic of editor
50+
- **Version**: 0.72.0
51+
- **Source**: binary
52+
- **License**: Apache-2.0
53+
- **Homepage**: https://github.com/editor-code-assistant/eca
54+
- **Usage**: `nix run .#eca -- --help`
55+
4756
#### claude-code
4857

4958
- **Description**: Agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster

packages/eca/default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
(import ./package.nix)

packages/eca/package.nix

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{ pkgs }:
2+
3+
let
4+
version = "0.73.5";
5+
6+
# Function to create native binary derivation for each platform
7+
mkNativeBinary = { system, url, hash }: pkgs.stdenv.mkDerivation rec {
8+
pname = "eca";
9+
inherit version;
10+
11+
src = pkgs.fetchzip {
12+
inherit url hash;
13+
stripRoot = false;
14+
};
15+
16+
dontUnpack = true;
17+
dontBuild = true;
18+
19+
installPhase = ''
20+
runHook preInstall
21+
mkdir -p $out/bin
22+
cp $src/eca $out/bin/eca
23+
chmod +x $out/bin/eca
24+
runHook postInstall
25+
'';
26+
27+
meta = with pkgs.lib; {
28+
description = "Editor Code Assistant (ECA) - AI pair programming capabilities agnostic of editor";
29+
homepage = "https://github.com/editor-code-assistant/eca";
30+
license = licenses.asl20;
31+
maintainers = with maintainers; [ jojo ];
32+
mainProgram = "eca";
33+
platforms = [ system ];
34+
};
35+
};
36+
37+
in
38+
# Use native binary for all supported platforms
39+
if pkgs.stdenv.hostPlatform.system == "x86_64-linux" then
40+
mkNativeBinary {
41+
system = "x86_64-linux";
42+
url = "https://github.com/editor-code-assistant/eca/releases/download/${version}/eca-native-linux-amd64.zip";
43+
hash = "sha256-ZqGjAhUEU/uh3T4m5GV8DHsCaTDtuD86DVFeGR7CJSs=";
44+
}
45+
else if pkgs.stdenv.hostPlatform.system == "aarch64-linux" then
46+
mkNativeBinary {
47+
system = "aarch64-linux";
48+
url = "https://github.com/editor-code-assistant/eca/releases/download/${version}/eca-native-linux-aarch64.zip";
49+
hash = "sha256-mbYgTFj7ymZ1u08TIQVJS0H0XtEbRkmrWj/EXHuz+GE=";
50+
}
51+
else if pkgs.stdenv.hostPlatform.system == "x86_64-darwin" then
52+
mkNativeBinary {
53+
system = "x86_64-darwin";
54+
url = "https://github.com/editor-code-assistant/eca/releases/download/${version}/eca-native-macos-amd64.zip";
55+
hash = "sha256-olQ6RYH+11lnC0tzNjPoypWjoB2mLM5A18lAW6Owns8=";
56+
}
57+
else if pkgs.stdenv.hostPlatform.system == "aarch64-darwin" then
58+
mkNativeBinary {
59+
system = "aarch64-darwin";
60+
url = "https://github.com/editor-code-assistant/eca/releases/download/${version}/eca-native-macos-aarch64.zip";
61+
hash = "sha256-EYSsesFN8SSATEgPVe0MYgn61lz84zm3XFi0MYE8SCs=";
62+
}
63+
else
64+
# Fallback to JAR version for unsupported platforms
65+
pkgs.stdenv.mkDerivation rec {
66+
pname = "eca";
67+
inherit version;
68+
69+
src = pkgs.fetchurl {
70+
url = "https://github.com/editor-code-assistant/eca/releases/download/${version}/eca.jar";
71+
hash = "sha256-10m85fdmzf2dcfphxcwr3cr985g3wswsm7gvylh30fwr4q2w7g56";
72+
};
73+
74+
nativeBuildInputs = [
75+
pkgs.makeWrapper
76+
];
77+
78+
buildInputs = [
79+
pkgs.jre
80+
];
81+
82+
dontUnpack = true;
83+
dontBuild = true;
84+
85+
installPhase = ''
86+
runHook preInstall
87+
mkdir -p $out/bin
88+
mkdir -p $out/lib
89+
cp $src $out/lib/eca.jar
90+
91+
cat > $out/bin/eca << EOF
92+
#!${pkgs.stdenv.shell}
93+
export JAVA_HOME="${pkgs.jre}"
94+
export PATH="${pkgs.jre}/bin:\$PATH"
95+
exec "${pkgs.jre}/bin/java" -jar "$out/lib/eca.jar" "\$@"
96+
EOF
97+
98+
chmod +x $out/bin/eca
99+
runHook postInstall
100+
'';
101+
102+
meta = with pkgs.lib; {
103+
description = "Editor Code Assistant (ECA) - AI pair programming capabilities agnostic of editor";
104+
homepage = "https://github.com/editor-code-assistant/eca";
105+
license = licenses.asl20;
106+
maintainers = with maintainers; [ jojo ];
107+
mainProgram = "eca";
108+
};
109+
}

packages/eca/update.sh

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Get the directory of this script
5+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6+
package_file="$script_dir/package.nix"
7+
8+
# Function to fetch latest version from GitHub releases
9+
fetch_latest_version() {
10+
# Use GitHub API to get the latest release tag
11+
curl -s \
12+
-H "Accept: application/vnd.github.v3+json" \
13+
https://api.github.com/repos/editor-code-assistant/eca/releases/latest | \
14+
jq -r '.tag_name'
15+
}
16+
17+
# Fetch latest version
18+
echo "Fetching latest version from GitHub releases..."
19+
latest_version=$(fetch_latest_version)
20+
21+
# Remove 'v' prefix if present
22+
latest_version="${latest_version#v}"
23+
echo "Latest version: $latest_version"
24+
25+
# Extract current version from package.nix
26+
current_version=$(nix eval .#eca.version --raw)
27+
echo "Current version: $current_version"
28+
29+
# Check if update is needed
30+
if [ "$latest_version" = "$current_version" ]; then
31+
echo "Package is already up to date!"
32+
exit 0
33+
fi
34+
35+
echo "Update available: $current_version -> $latest_version"
36+
37+
# Calculate hashes for all platforms
38+
echo "Calculating hashes for all platforms..."
39+
40+
# Create temporary file for updated content
41+
tmp_file=$(mktemp)
42+
cp "$package_file" "$tmp_file"
43+
44+
# Update version
45+
sed -i "s/version = \"${current_version}\";/version = \"${latest_version}\";/" "$tmp_file"
46+
47+
# Platform-specific URLs and hash calculation
48+
declare -A platforms=(
49+
["x86_64-linux"]="https://github.com/editor-code-assistant/eca/releases/download/${latest_version}/eca-native-linux-amd64.zip"
50+
["aarch64-linux"]="https://github.com/editor-code-assistant/eca/releases/download/${latest_version}/eca-native-linux-aarch64.zip"
51+
["x86_64-darwin"]="https://github.com/editor-code-assistant/eca/releases/download/${latest_version}/eca-native-macos-amd64.zip"
52+
["aarch64-darwin"]="https://github.com/editor-code-assistant/eca/releases/download/${latest_version}/eca-native-macos-aarch64.zip"
53+
)
54+
55+
for platform in "${!platforms[@]}"; do
56+
url="${platforms[$platform]}"
57+
echo " Calculating hash for $platform..."
58+
59+
# Use nix-build to automatically get the correct hash
60+
export NIX_PATH=nixpkgs=flake:nixpkgs
61+
62+
# All platforms now use native binary zip files
63+
hash_output=$(nix-build -E "with import <nixpkgs> {}; fetchzip { url = \"${url}\"; sha256 = \"\"; }" 2>&1 || true)
64+
65+
new_hash=$(echo "$hash_output" | grep "got:" | awk '{print $2}')
66+
67+
if [ -z "$new_hash" ]; then
68+
echo " ERROR: Failed to calculate hash for $platform"
69+
echo " Output: $hash_output"
70+
continue
71+
fi
72+
73+
# Update the specific hash for this platform
74+
# Find the line number for this platform's hash
75+
line_num=$(grep -n "system = \"$platform\"" "$tmp_file" | cut -d: -f1)
76+
if [ -n "$line_num" ]; then
77+
# Find the next hash = line after the system declaration
78+
# Look for the pattern in the rest of the file from the system declaration
79+
hash_line=$(tail -n "+$line_num" "$tmp_file" | grep -n "hash = " | head -1 | cut -d: -f1)
80+
if [ -n "$hash_line" ]; then
81+
actual_line=$((line_num + hash_line - 1))
82+
sed -i "${actual_line}s|hash = \"[^\"]*\";|hash = \"${new_hash}\";|" "$tmp_file"
83+
echo " $platform: $new_hash"
84+
else
85+
echo " WARNING: Could not find hash line for $platform"
86+
fi
87+
else
88+
# If not found in platform-specific section, try to find JAR version hash
89+
jar_line=$(grep -n "eca.jar" "$tmp_file" | head -1 | cut -d: -f1)
90+
if [ -n "$jar_line" ]; then
91+
# Find the hash line near the JAR file URL
92+
hash_line=$(tail -n "+$jar_line" "$tmp_file" | grep -n "hash = " | head -1 | cut -d: -f1)
93+
if [ -n "$hash_line" ]; then
94+
actual_line=$((jar_line + hash_line - 1))
95+
sed -i "${actual_line}s|hash = \"[^\"]*\";|hash = \"${new_hash}\";|" "$tmp_file"
96+
echo " JAR version: $new_hash"
97+
else
98+
echo " WARNING: Could not find hash line for JAR version"
99+
fi
100+
else
101+
echo " WARNING: Could not find platform or JAR section for $platform"
102+
fi
103+
fi
104+
done
105+
106+
# Check if any changes were made
107+
if ! diff -q "$tmp_file" "$package_file" >/dev/null 2>&1; then
108+
# Move updated file back
109+
mv "$tmp_file" "$package_file"
110+
111+
echo "Building package to verify..."
112+
nix build .#eca
113+
114+
echo "Update completed successfully!"
115+
echo "eca has been updated from $current_version to $latest_version"
116+
else
117+
echo "No changes needed - all hashes are already correct"
118+
rm -f "$tmp_file"
119+
fi

0 commit comments

Comments
 (0)