2026年10月15日 星期四

Stripe CLI Windows 安裝與登入

Stripe CLI Windows 安裝與登入

Stripe 官方命令列工具,可在終端機操作 Stripe API、把 webhook 轉發到本機測試,這邊自動抓 GitHub 上的最新版本安裝

兩個選項擇一,整段貼到 PowerShell 執行



選項 A:C:\App\stripe-cli(系統變數)

以系統管理員身分執行

先確認權限,沒有顯示錯誤再往下

if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw "請以系統管理員身分執行 PowerShell" }

下載並安裝

# 設定安裝目錄
$StripeDir = "C:\App\stripe-cli"
# 取得最新版本資訊
$Release = Invoke-RestMethod https://api.github.com/repos/stripe/stripe-cli/releases/latest
$Asset = $Release.assets | Where-Object name -like "*_windows_x86_64.zip"
# 下載 stripe
$Zip = "$env:TEMP\stripe.zip"
Invoke-WebRequest -Uri $Asset.browser_download_url -OutFile $Zip
# 驗證檔案
if ((Get-FileHash $Zip -Algorithm SHA256).Hash -ne ($Asset.digest -replace "^sha256:")) { throw "SHA256 不符" }
# 解壓縮到安裝目錄(覆蓋舊版)
Expand-Archive $Zip $StripeDir -Force
Remove-Item $Zip
# 加入系統環境變數
$MachinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if (($MachinePath -split ";") -notcontains $StripeDir) {
    [Environment]::SetEnvironmentVariable("Path", "$MachinePath;$StripeDir", "Machine")
}


選項 B:C:\Users\<你>\.local\bin(使用者變數)

一般權限即可

# 設定安裝目錄
$StripeDir = "$env:USERPROFILE\.local\bin"
# 取得最新版本資訊
$Release = Invoke-RestMethod https://api.github.com/repos/stripe/stripe-cli/releases/latest
$Asset = $Release.assets | Where-Object name -like "*_windows_x86_64.zip"
# 下載 stripe
$Zip = "$env:TEMP\stripe.zip"
Invoke-WebRequest -Uri $Asset.browser_download_url -OutFile $Zip
# 驗證檔案
if ((Get-FileHash $Zip -Algorithm SHA256).Hash -ne ($Asset.digest -replace "^sha256:")) { throw "SHA256 不符" }
# 解壓縮到安裝目錄(覆蓋舊版)
Expand-Archive $Zip $StripeDir -Force
Remove-Item $Zip
# 加入使用者環境變數
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (($UserPath -split ";") -notcontains $StripeDir) {
    [Environment]::SetEnvironmentVariable("Path", "$UserPath;$StripeDir", "User")
}



確認安裝

裝完接著執行,重新載入環境變數並顯示安裝位置

# 重新載入環境變數
$env:Path = (($env:Path -split ";") + ([Environment]::GetEnvironmentVariable("Path", "Machine") -split ";") + ([Environment]::GetEnvironmentVariable("Path", "User") -split ";") | Where-Object { $_ } | Select-Object -Unique) -join ";"
# 顯示安裝位置
Write-Host "stripe 位置:$((Get-Command stripe).Source)"

確認版本

stripe --version



登入

登入 Stripe(瀏覽器會開啟 Dashboard,確認畫面上的配對碼和終端機一致,可一次勾選多個帳號、沙盒或正式環境,再按審核)

stripe login

已登入時再跑一次 stripe login,按 Enter 開啟瀏覽器,可以授權更多帳號、沙盒或正式環境(live)

Stripe 新版建議測試只用沙盒就好,授權時不要勾選沙盒底下的「測試模式」,那是舊式的測試環境


確認環境

列出已授權的帳號,active 是目前使用中的

stripe whoami --format json | ConvertFrom-Json -PipelineVariable me |
    ForEach-Object authorized_accounts |
    Select-Object name, id,
        @{ n = "modes";  e = { $_.modes -join ", " } },
        @{ n = "status"; e = { if ($_.id -eq $me.account_id) { "active" } } }




更新

重跑選項 A 或 B 即可,會抓最新版覆蓋



2026年10月14日 星期三

Gradle Windows 安裝

Gradle Windows 安裝

自動抓 Gradle 官方最新版本安裝,之後重跑同一段就是更新

兩個選項擇一,整段貼到 PowerShell 執行



前置需求

需要 Java 17 以上,沒有的話先看 Java 安裝教學

java -version


選項 A:C:\App\gradle(系統變數)

以系統管理員身分執行

先確認權限,沒有顯示錯誤再往下

if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw "請以系統管理員身分執行 PowerShell" }

下載並安裝

# 設定安裝目錄
$GradleRoot = "C:\App\gradle"
# 取得最新版本資訊
$Latest = Invoke-RestMethod https://services.gradle.org/versions/current
$GradleDir = "$GradleRoot\gradle-$($Latest.version)"
# 下載 gradle
$Zip = "$env:TEMP\gradle.zip"
Invoke-WebRequest -Uri $Latest.downloadUrl -OutFile $Zip
# 驗證檔案
if ((Get-FileHash $Zip -Algorithm SHA256).Hash -ne (Invoke-RestMethod $Latest.checksumUrl).Trim()) { throw "SHA256 不符" }
# 解壓縮(產生帶版本號的資料夾)
Expand-Archive $Zip $GradleRoot -Force
Remove-Item $Zip
# 更新系統環境變數(移除舊版,加入新版)
$MachinePath = (@([Environment]::GetEnvironmentVariable("Path", "Machine") -split ";" | Where-Object { $_ -and $_ -notlike "$GradleRoot\*" }) + "$GradleDir\bin") -join ";"
[Environment]::SetEnvironmentVariable("Path", $MachinePath, "Machine")


選項 B:C:\Users\<你>\.local\gradle(使用者變數)

一般權限即可

# 設定安裝目錄
$GradleRoot = "$env:USERPROFILE\.local\gradle"
# 取得最新版本資訊
$Latest = Invoke-RestMethod https://services.gradle.org/versions/current
$GradleDir = "$GradleRoot\gradle-$($Latest.version)"
# 下載 gradle
$Zip = "$env:TEMP\gradle.zip"
Invoke-WebRequest -Uri $Latest.downloadUrl -OutFile $Zip
# 驗證檔案
if ((Get-FileHash $Zip -Algorithm SHA256).Hash -ne (Invoke-RestMethod $Latest.checksumUrl).Trim()) { throw "SHA256 不符" }
# 解壓縮(產生帶版本號的資料夾)
Expand-Archive $Zip $GradleRoot -Force
Remove-Item $Zip
# 更新使用者環境變數(移除舊版,加入新版)
$UserPath = (@([Environment]::GetEnvironmentVariable("Path", "User") -split ";" | Where-Object { $_ -and $_ -notlike "$GradleRoot\*" }) + "$GradleDir\bin") -join ";"
[Environment]::SetEnvironmentVariable("Path", $UserPath, "User")



確認安裝

裝完接著執行,重新載入環境變數並顯示安裝位置

# 重新載入環境變數
$env:Path = (($env:Path -split ";") + ([Environment]::GetEnvironmentVariable("Path", "Machine") -split ";") + ([Environment]::GetEnvironmentVariable("Path", "User") -split ";") | Where-Object { $_ } | Select-Object -Unique) -join ";"
# 顯示安裝位置
Write-Host "gradle 位置:$((Get-Command gradle).Source)"

確認版本

gradle --version

看到 Gradle x.y.z 和 Java 版本即成功



更新

重跑選項 A 或 B 即可,新版會裝到新的版本資料夾,環境變數會移除舊版並換成新版

舊版資料夾會保留,確認新版沒問題後可手動刪除





Java SDK(Eclipse Temurin)Windows 安裝

Java(Eclipse Temurin)Windows 安裝

Eclipse Temurin 是 Adoptium 發行的免費 OpenJDK,也是 Oracle 以外最多人用的 Java

以下腳本都會自動抓最新 LTS 版本並驗證檔案,三種方式擇一,整段貼到 PowerShell 執行

  • 選項 A:裝好就能用,最簡單
  • 選項 B:全自動,所有使用者共用
  • 選項 C:不需要管理員權限



選項 A:手動安裝 MSI(最簡單)

開啟安裝畫面自己點下一步,PATH 會自動設好,需要 JAVA_HOME 時勾選「Set JAVA_HOME variable」

# 取得最新 LTS 版本資訊
$Lts = (Invoke-RestMethod https://api.adoptium.net/v3/info/available_releases).most_recent_lts
$Pkg = (Invoke-RestMethod "https://api.adoptium.net/v3/assets/latest/$Lts/hotspot?architecture=x64&image_type=jdk&os=windows&vendor=eclipse")[0]
# 下載 MSI
$Msi = "$env:TEMP\temurin.msi"
Invoke-WebRequest -Uri $Pkg.binary.installer.link -OutFile $Msi
# 驗證檔案
if ((Get-FileHash $Msi -Algorithm SHA256).Hash -ne $Pkg.binary.installer.checksum) { throw "SHA256 不符" }
# 開啟安裝畫面
Start-Process $Msi -Wait
Remove-Item $Msi


選項 B:自動安裝 MSI(系統變數)

以系統管理員身分執行,裝到預設位置,含 PATH、JAVA_HOME、.jar 關聯

# 取得最新 LTS 版本資訊
$Lts = (Invoke-RestMethod https://api.adoptium.net/v3/info/available_releases).most_recent_lts
$Pkg = (Invoke-RestMethod "https://api.adoptium.net/v3/assets/latest/$Lts/hotspot?architecture=x64&image_type=jdk&os=windows&vendor=eclipse")[0]
# 下載 MSI
$Msi = "$env:TEMP\temurin.msi"
Invoke-WebRequest -Uri $Pkg.binary.installer.link -OutFile $Msi
# 驗證檔案
if ((Get-FileHash $Msi -Algorithm SHA256).Hash -ne $Pkg.binary.installer.checksum) { throw "SHA256 不符" }

靜默安裝

# 讀取 MSI 內建的預設安裝位置
$Db = (New-Object -ComObject WindowsInstaller.Installer).OpenDatabase($Msi, 0)
function Get-MsiDir($Id) { $v = $Db.OpenView("SELECT ``DefaultDir`` FROM ``Directory`` WHERE ``Directory``='$Id'"); [void]$v.Execute(); ($v.Fetch().StringData(1) -split "\|")[-1] }
$InstallDir = "$env:ProgramFiles\$(Get-MsiDir PRODUCTMANUFACTURER)\$(Get-MsiDir INSTALLDIR)"
$Db = $null; [GC]::Collect(); [GC]::WaitForPendingFinalizers()
# 安裝
Start-Process msiexec -Wait -ArgumentList "/i `"$Msi`" ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR=`"$InstallDir`" /quiet"
Remove-Item $Msi


選項 C:自動安裝 zip(使用者變數)

一般權限即可,裝到 C:\Users\<你>\.local\java

# 設定安裝目錄
$JavaDir = "$env:USERPROFILE\.local\java"
# 取得最新 LTS 版本資訊
$Lts = (Invoke-RestMethod https://api.adoptium.net/v3/info/available_releases).most_recent_lts
$Pkg = (Invoke-RestMethod "https://api.adoptium.net/v3/assets/latest/$Lts/hotspot?architecture=x64&image_type=jdk&os=windows&vendor=eclipse")[0]
# 下載 zip
$Zip = "$env:TEMP\temurin.zip"
Invoke-WebRequest -Uri $Pkg.binary.package.link -OutFile $Zip
# 驗證檔案
if ((Get-FileHash $Zip -Algorithm SHA256).Hash -ne $Pkg.binary.package.checksum) { throw "SHA256 不符" }

解壓縮並設定環境變數

# 解壓縮到安裝目錄(覆蓋舊版)
Expand-Archive $Zip $env:TEMP -Force
if (Test-Path $JavaDir) { Remove-Item $JavaDir -Recurse -Force }
Move-Item "$env:TEMP\$($Pkg.release_name)" $JavaDir
Remove-Item $Zip
# 設定 JAVA_HOME
[Environment]::SetEnvironmentVariable("JAVA_HOME", $JavaDir, "User")
# 加入使用者環境變數
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (($UserPath -split ";") -notcontains "$JavaDir\bin") {
    [Environment]::SetEnvironmentVariable("Path", "$UserPath;$JavaDir\bin", "User")
}




確認安裝

裝完接著執行,重新載入環境變數並顯示安裝位置

# 重新載入環境變數
$env:Path = (($env:Path -split ";") + ([Environment]::GetEnvironmentVariable("Path", "Machine") -split ";") + ([Environment]::GetEnvironmentVariable("Path", "User") -split ";") | Where-Object { $_ } | Select-Object -Unique) -join ";"
foreach ($Scope in "Machine", "User") { $v = [Environment]::GetEnvironmentVariable("JAVA_HOME", $Scope); if ($v) { $env:JAVA_HOME = $v } }
# 顯示安裝位置
Write-Host "java 位置:$((Get-Command java).Source)"
Write-Host "JAVA_HOME:$env:JAVA_HOME"

確認版本

java -version

看到 Temurin-xx 的版本即成功

已裝過其他 Java 時,系統 PATH 會排在使用者 PATH 前面,選項 C 可能被舊版蓋過,先到「設定 > 應用程式」移除舊版




Atlassian CLI(acli)Windows 安裝與登入

Atlassian CLI(acli)Windows 安裝與登入

雖然 Github 上的 issue 已經有基本60分功能,但真的要協作用 jira 當 agent 們的共同記憶區會比較變些,這邊是 Windows 快速安裝的方法



1. 下載並加入 PATH

兩個選項擇一,整段貼到 PowerShell 執行

選項 A:C:\App\atlassian-cli(系統變數)

以系統管理員身分執行

# 設定安裝目錄
$AcliDir = "C:\App\atlassian-cli"
# 建立目錄
New-Item -ItemType Directory -Force $AcliDir | Out-Null
# 下載 acli
Invoke-WebRequest -Uri "https://acli.atlassian.com/windows/latest/acli_windows_amd64/acli.exe" -OutFile "$AcliDir\acli.exe"
# 加入系統環境變數
$MachinePath = [Environment]::GetEnvironmentVariable("Path", "Machine")
if (($MachinePath -split ";") -notcontains $AcliDir) {
    [Environment]::SetEnvironmentVariable("Path", "$MachinePath;$AcliDir", "Machine")
}


選項 B:C:\Users\<你>\.local\bin(使用者變數)

一般權限即可

# 設定安裝目錄
$AcliDir = "$env:USERPROFILE\.local\bin"
# 建立目錄
New-Item -ItemType Directory -Force $AcliDir | Out-Null
# 下載 acli
Invoke-WebRequest -Uri "https://acli.atlassian.com/windows/latest/acli_windows_amd64/acli.exe" -OutFile "$AcliDir\acli.exe"
# 加入使用者環境變數
$UserPath = [Environment]::GetEnvironmentVariable("Path", "User")
if (($UserPath -split ";") -notcontains $AcliDir) {
    [Environment]::SetEnvironmentVariable("Path", "$UserPath;$AcliDir", "User")
}


確認安裝

確認安裝

# 重新載入環境變數
$env:Path = (($env:Path -split ";") + ([Environment]::GetEnvironmentVariable("Path", "Machine") -split ";") + ([Environment]::GetEnvironmentVariable("Path", "User") -split ";") | Where-Object { $_ } | Select-Object -Unique) -join ";"
# 顯示安裝位置
Write-Host "acli 位置:$((Get-Command acli).Source)"

確認版本

acli --version


2. 登入

登入 Jira (瀏覽器授權後,回終端機選站台才算完成)

acli jira auth login --web

登入 Confluence(需要時)

acli confluence auth login --web


3. 測試連線

查看登入狀態

acli jira auth status

列出專案

acli jira project list --limit 10

看到 ✓ Authenticated,且列專案沒有報錯即成功(還沒有專案時清單是空的)




2026年9月23日 星期三

本地 repos 自動清理 github 上已經刪除的分支

自動清理 github 上已經刪除的分支

讓每次 git fetch / git pull 自動清掉遠端已刪除的分支,保持本機的 origin/* 與遠端一致。

git config --global fetch.prune true

復原

git config --global --unset fetch.prune


為什麼需要

遠端刪除分支後,本機的 origin/xxx 並不會跟著消失。時間一久,git branch -r 就會堆滿早已合併刪除的殭屍分支。

開啟後等同每次 fetch 都自動加上 --prune,不用再手動執行 git remote prune origin。


好處

  • 分支清單反映真實狀況:看到的遠端分支就是真的存在的分支
  • 減少雜訊:Tab 補全、git branch -a、GUI 工具都更乾淨
  • 大型 repo 更有感:過期參照累積過多會拖慢部分指令
  • 不用靠記憶:設定一次就好


安全嗎?

安全。它只清理 origin/* 這類 remote-tracking branch,不會刪除你的本地分支。

需要時也可以臨時關閉:

git fetch --no-prune

Git 沒把它設為預設,只是因為被刪的參照不留 reflog,屬保守考量。唯一的小風險是有人誤刪遠端分支時,你本機少了一份可救回的參照。


注意 fetch.pruneTags

相關設定 fetch.pruneTags 會連 tag 一起清理,可能刪掉不是來自該 remote 的本地 tag。fetch.prune 放心開,fetch.pruneTags 視需求再決定。


延伸:找出可清理的本地分支

確認不需要後,用 git branch -d <name> 刪除。-

git branch -vv | grep ': gone]'





2026年6月28日 星期日

OpenClaw 賦予 Cron 有 Glob 讀取檔案的權限

OpenClaw 賦予 Cron 有 Glob 讀取檔案的權限

預設龍蝦的 cron 能用的內部工具是有限的,如果你有下指令讓她根據最近的對話紀錄的之類得,會需要用到搜尋 memory/2026-*.md 就有機率用到下面的的錯誤

I can’t use the tool “glob” here because it isn’t available. I need to stop retrying it and answer without that tool.


基本大概這幾個基礎指令有用到就給她吧

動作需要的工具原因
找記憶檔案 memory/2026-*.mdGlob找檔案模式匹配
讀記憶檔案內容Read讀檔案
搜尋檔案內容Grep搜關鍵字
執行指令Bash查今日 commit
發報告到 DiscordSendMessage發訊息


給全域權限的指令

openclaw config set tools.alsoAllow '["glob","read","grep"]'


也能針對特定 corn 給權限

openclaw cron edit <cron-id> --tools glob,read,grep


看需求自己添加吧