From 13cad6c62baa160d3f9eca045e897630694785a7 Mon Sep 17 00:00:00 2001 From: pionxe Date: Sun, 29 Mar 2026 15:20:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E4=BB=A5=E5=8F=8A=E7=B3=BB=E7=BB=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=8C=85=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E8=A7=A3=E5=86=B3=E4=BA=86=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 2 + .github/workflows/release.yml | 3 +- .goreleaser.yaml | 36 +++++++++++++++++- README.md | 49 +++++++++++++++++++++++++ scripts/install.ps1 | 69 +++++++++++++++++++++++++++++++++++ scripts/install.sh | 61 +++++++++++++++++++++++++++++++ 6 files changed, 218 insertions(+), 2 deletions(-) create mode 100644 .gitattributes create mode 100644 scripts/install.ps1 create mode 100644 scripts/install.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..f8601b71 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# 强制 scripts 目录下的 Shell 脚本始终使用 LF 换行符 +scripts/*.sh text eol=lf \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 58ef19bc..2173ce19 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,4 +35,5 @@ jobs: args: release --clean env: # GitHub Actions 自动注入的 Token,用于发布 Release - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 7130ee80..954cd815 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,4 +1,5 @@ # .goreleaser.yaml +project_name: neocode version: 2 # 必须声明为 v2 语法 before: @@ -44,4 +45,37 @@ changelog: filters: exclude: - '^docs:' - - '^test:' \ No newline at end of file + - '^test:' + +# ================= 新增:包管理器分发配置 ================= + +# 1. 生成 Debian (.deb) 安装包 +nfpms: + - id: default + file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + homepage: "https://github.com/1024XEngineer/neocode" # 换成官方或你的仓库地址 + description: "A local Coding Agent MVP." + maintainer: "NeoCode Team" + formats: + - deb + +# 2. 生成 Homebrew 配方并自动推送到你的 homebrew-neocode 仓库 +brews: + - repository: + owner: 1024XEngineer # <--- 改成你的 GitHub 用户名 + name: homebrew-neocode # 你刚才建好的仓库名 + token: "{{ .Env.TAP_GITHUB_TOKEN }}" # 使用刚才传进来的秘钥 + directory: Formula + homepage: "https://github.com/1024XEngineer/neocode" + description: "A local Coding Agent MVP." + test: | + system "#{bin}/neocode --version" # 简单的安装后测试脚本 + +# 3. 生成 Scoop 清单并自动推送到你的 scoop-bucket 仓库 +scoops: + - repository: + owner: 1024XEngineer # <--- 改成你的 GitHub 用户名 + name: scoop-bucket # 你刚才建好的仓库名 + token: "{{ .Env.TAP_GITHUB_TOKEN }}" + homepage: "https://github.com/1024XEngineer/neocode" + description: "A local Coding Agent MVP." \ No newline at end of file diff --git a/README.md b/README.md index 4398146a..47847be3 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,55 @@ tool_timeout_sec: 20 - `/provider`:打开 provider 选择器。 - `/model`:打开当前 provider 的模型选择器。 + + +## 安装指南 (快速开始) + +NeoCode 提供了极其原生的系统级安装体验,真正的开箱即用(无需 Go 环境)。请根据你的操作系统选择最适合的安装方式: + +### 🍎 macOS / Linux (推荐 Homebrew) + +对于习惯使用 Homebrew 的用户,只需一行命令即可接入官方 Tap 并安装: + +```bash +brew install 1024XEngineer/homebrew-neocode/neocode +``` + +### 🪟 Windows (推荐 Scoop) + +对于 Windows 极客玩家,我们提供了官方的 Scoop 分发源: + +```PowerShell +scoop bucket add neocode https://github.com/1024XEngineer/scoop-bucket.git +scoop install neocode +``` + +### 🐧 Ubuntu / Debian (.deb) + +前往项目的 [Releases 页面](https://www.google.com/search?q=https://github.com/pionxe/neo-code/releases) 下载最新版本的 `.deb` 安装包,然后在终端执行: + +```Bash +sudo dpkg -i neo-code_*_linux_amd64.deb +``` + +### 🚀 兜底方案:一键安装脚本 + +如果你的系统没有安装上述包管理器,也可以使用我们提供的自动化脚本一键下载并配置: + +**Linux / macOS:** + +```Bash +curl -sSL https://raw.githubusercontent.com/1024XEngineer/neo-code/main/scripts/install.sh | bash +``` + +**Windows (PowerShell):** + +```PowerShell +irm https://raw.githubusercontent.com/1024XEngineer/neo-code/main/scripts/install.ps1 | iex +``` + + + ## 运行 ```bash diff --git a/scripts/install.ps1 b/scripts/install.ps1 new file mode 100644 index 00000000..397fab25 --- /dev/null +++ b/scripts/install.ps1 @@ -0,0 +1,69 @@ +$ErrorActionPreference = "Stop" + +# 配置仓库信息 +$Repo = "pionxe/neo-code" +$ProjectName = "neo-code" +$BinaryName = "neocode.exe" + +Write-Host "🚀 开始安装 $BinaryName..." -ForegroundColor Cyan + +# 1. 获取系统架构 +$Arch = $env:PROCESSOR_ARCHITECTURE +if ($Arch -eq "AMD64") { + $ArchName = "x86_64" +} elseif ($Arch -eq "ARM64") { + $ArchName = "arm64" +} else { + Write-Error "❌ 不支持的系统架构: $Arch" + exit +} + +# 2. 从 GitHub API 获取最新 Release 版本号 +Write-Host "🔍 正在获取最新版本信息..." +$ApiUrl = "https://api.github.com/repos/$Repo/releases/latest" +try { + $LatestRelease = Invoke-RestMethod -Uri $ApiUrl + $LatestTag = $LatestRelease.tag_name +} catch { + Write-Error "❌ 无法获取最新版本,请检查网络或 GitHub 访问权限。" + exit +} +Write-Host "📦 发现最新版本: $LatestTag" + +# 3. 拼接下载链接 +$ZipFile = "${ProjectName}_Windows_${ArchName}.zip" +$DownloadUrl = "https://github.com/$Repo/releases/download/$LatestTag/$ZipFile" + +# 4. 下载并解压到临时目录 +$TempDir = Join-Path $env:TEMP "neocode_install" +if (Test-Path $TempDir) { Remove-Item -Recurse -Force $TempDir } +New-Item -ItemType Directory -Force -Path $TempDir | Out-Null +$ZipPath = Join-Path $TempDir $ZipFile + +Write-Host "⬇️ 正在下载压缩包..." +Invoke-WebRequest -Uri $DownloadUrl -OutFile $ZipPath + +Write-Host "📦 正在解压..." +Expand-Archive -Path $ZipPath -DestinationPath $TempDir -Force + +# 5. 部署到用户目录 +$InstallDir = Join-Path $env:LOCALAPPDATA "NeoCode" +if (!(Test-Path $InstallDir)) { + New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null +} +Write-Host "⚙️ 正在将可执行文件部署到 $InstallDir..." +Copy-Item -Path (Join-Path $TempDir $BinaryName) -Destination $InstallDir -Force + +# 6. 配置环境变量 PATH +$UserPath = [Environment]::GetEnvironmentVariable("PATH", "User") +if ($UserPath -notmatch [regex]::Escape($InstallDir)) { + Write-Host "🔧 正在配置环境变量..." + $NewPath = "$UserPath;$InstallDir" + [Environment]::SetEnvironmentVariable("PATH", $NewPath, "User") + Write-Host "⚠️ 环境变量已更新!安装完成后,请重启终端(PowerShell/CMD)以使命令生效。" -ForegroundColor Yellow +} + +# 7. 清理临时文件 +Remove-Item -Recurse -Force $TempDir + +Write-Host "✅ 安装成功!" -ForegroundColor Green \ No newline at end of file diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 00000000..c90db9ac --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,61 @@ +#!/bin/bash +set -e + +# 配置仓库信息 +REPO="pionxe/neo-code" +PROJECT_NAME="neo-code" +BINARY_NAME="neocode" + +echo "🚀 开始安装 $BINARY_NAME..." + +# 1. 获取系统和架构信息 +OS="$(uname -s)" +ARCH="$(uname -m)" + +if [ "$OS" = "Linux" ]; then + OS_NAME="Linux" +elif [ "$OS" = "Darwin" ]; then + OS_NAME="Darwin" +else + echo "❌ 不支持的操作系统: $OS" + exit 1 +fi + +if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then + ARCH_NAME="x86_64" +elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then + ARCH_NAME="arm64" +else + echo "❌ 不支持的系统架构: $ARCH" + exit 1 +fi + +# 2. 从 GitHub API 获取最新 Release 版本号 +echo "🔍 正在获取最新版本信息..." +LATEST_TAG=$(curl -s "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + +if [ -z "$LATEST_TAG" ]; then + echo "❌ 无法获取最新版本,请检查网络或 GitHub 访问权限。" + exit 1 +fi +echo "📦 发现最新版本: $LATEST_TAG" + +# 3. 拼接下载链接 (匹配 GoReleaser 默认命名) +TAR_FILE="${PROJECT_NAME}_${OS_NAME}_${ARCH_NAME}.tar.gz" +DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/$TAR_FILE" + +# 4. 下载并解压 +echo "⬇️ 正在下载: $DOWNLOAD_URL" +curl -L -o "$TAR_FILE" "$DOWNLOAD_URL" + +echo "📦 正在解压..." +tar -xzf "$TAR_FILE" "$BINARY_NAME" + +# 5. 安装到全局 PATH +echo "⚙️ 正在安装到 /usr/local/bin (此步可能需要输入密码以获取 sudo 权限)..." +sudo mv "$BINARY_NAME" /usr/local/bin/ + +# 6. 清理临时文件 +rm "$TAR_FILE" + +echo "✅ 安装成功!请在终端运行 '$BINARY_NAME --help' 开始使用。" \ No newline at end of file From debde9f379abd98603b4419ac697cb9f942db430 Mon Sep 17 00:00:00 2001 From: pionxe Date: Mon, 30 Mar 2026 19:58:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E5=88=A0=E9=99=A4=E4=BA=86?= =?UTF-8?q?=E5=8C=85=E7=AE=A1=E7=90=86=E5=99=A8=E5=88=86=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 2 -- .goreleaser.yaml | 32 -------------------------------- 2 files changed, 34 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2173ce19..18fefece 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,6 +34,4 @@ jobs: version: '~> v2' args: release --clean env: - # GitHub Actions 自动注入的 Token,用于发布 Release - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 954cd815..9d95045a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -47,35 +47,3 @@ changelog: - '^docs:' - '^test:' -# ================= 新增:包管理器分发配置 ================= - -# 1. 生成 Debian (.deb) 安装包 -nfpms: - - id: default - file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' - homepage: "https://github.com/1024XEngineer/neocode" # 换成官方或你的仓库地址 - description: "A local Coding Agent MVP." - maintainer: "NeoCode Team" - formats: - - deb - -# 2. 生成 Homebrew 配方并自动推送到你的 homebrew-neocode 仓库 -brews: - - repository: - owner: 1024XEngineer # <--- 改成你的 GitHub 用户名 - name: homebrew-neocode # 你刚才建好的仓库名 - token: "{{ .Env.TAP_GITHUB_TOKEN }}" # 使用刚才传进来的秘钥 - directory: Formula - homepage: "https://github.com/1024XEngineer/neocode" - description: "A local Coding Agent MVP." - test: | - system "#{bin}/neocode --version" # 简单的安装后测试脚本 - -# 3. 生成 Scoop 清单并自动推送到你的 scoop-bucket 仓库 -scoops: - - repository: - owner: 1024XEngineer # <--- 改成你的 GitHub 用户名 - name: scoop-bucket # 你刚才建好的仓库名 - token: "{{ .Env.TAP_GITHUB_TOKEN }}" - homepage: "https://github.com/1024XEngineer/neocode" - description: "A local Coding Agent MVP." \ No newline at end of file