@ziniao-open/cli 0.1.0-beta.93 → 0.1.0-beta.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,6 +28,13 @@ Windows PowerShell 执行:
28
28
  ziniao-cli doctor fix-path
29
29
  ```
30
30
 
31
+ 遍历当前 PATH 并清理正式目录之外的 `ziniao.exe` 文件(默认只预览):
32
+
33
+ ```powershell
34
+ & "$(npm root -g)\@ziniao-open\cli\scripts\remove-ziniao-cli-shims.ps1"
35
+ & "$(npm root -g)\@ziniao-open\cli\scripts\remove-ziniao-cli-shims.ps1" -Apply
36
+ ```
37
+
31
38
  脚本只探测 `ziniao.app` / `ziniao` 的安装目录;Windows 会优先查询卸载注册表中 `DisplayIcon` 包含 `ziniao.exe` 的条目,再从本体目录的 `resources/app.asar.unpacked/envkit/cli` 查找 CLI。Windows 使用 `%APPDATA%\ziniaobrowser\cli`,macOS/Linux 使用 `~/.local/bin`,在目标目录缺少 CLI 或文件内容发生变化时同步最新文件,并注册当前用户 PATH。找不到源文件时只提示并继续,不阻断 PATH 配置。若安装目录无法自动探测,可设置 `ZINIAO_INSTALL_DIR`;若目标位置不同,可设置 `ZINIAO_APP_CACHE_DIR`。
32
39
 
33
40
  安装时会自动下载当前平台对应的预编译二进制(支持 macOS / Linux / Windows × amd64 / arm64),并做 SHA-256 校验。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziniao-open/cli",
3
- "version": "0.1.0-beta.93",
3
+ "version": "0.1.0-beta.95",
4
4
  "description": "紫鸟开放平台命令行工具,为开发者和 AI Agent 提供统一的接口调用入口。",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -14,7 +14,8 @@
14
14
  "scripts/install.js",
15
15
  "scripts/run.js",
16
16
  "scripts/setup-ziniao-cli.sh",
17
- "scripts/setup-ziniao-cli.ps1"
17
+ "scripts/setup-ziniao-cli.ps1",
18
+ "scripts/remove-ziniao-cli-shims.ps1"
18
19
  ],
19
20
  "engines": {
20
21
  "node": ">=18"
@@ -0,0 +1,43 @@
1
+ # Find and optionally remove ziniao.exe shims created in PATH directories.
2
+ # Run without -Apply first to preview the files that would be removed.
3
+
4
+ [CmdletBinding(SupportsShouldProcess)]
5
+ param(
6
+ [switch]$Apply
7
+ )
8
+
9
+ $ErrorActionPreference = "Stop"
10
+
11
+ function Write-Log([string]$Message) {
12
+ Write-Output "[ziniao-cli-shims] $Message"
13
+ }
14
+
15
+ $targetDir = Join-Path $env:APPDATA "ziniaobrowser\cli"
16
+ $candidates = @()
17
+ foreach ($pathEntry in @($env:Path -split ";" | Where-Object { $_ })) {
18
+ $directory = $pathEntry.TrimEnd('\')
19
+ if (-not $directory -or $directory -ieq $targetDir.TrimEnd('\')) { continue }
20
+ $shimPath = Join-Path $directory "ziniao.exe"
21
+ if (-not (Test-Path -LiteralPath $shimPath -PathType Leaf)) { continue }
22
+ $candidates += $shimPath
23
+ }
24
+
25
+ if (-not $candidates) {
26
+ Write-Log "No ziniao.exe shims found in PATH directories."
27
+ exit 0
28
+ }
29
+
30
+ foreach ($candidate in ($candidates | Select-Object -Unique)) {
31
+ if (-not $Apply) {
32
+ Write-Log "Would remove: $candidate"
33
+ continue
34
+ }
35
+ if ($PSCmdlet.ShouldProcess($candidate, "Remove CLI shim")) {
36
+ Remove-Item -LiteralPath $candidate -Force
37
+ Write-Log "Removed: $candidate"
38
+ }
39
+ }
40
+
41
+ if (-not $Apply) {
42
+ Write-Log "Preview only. Re-run with -Apply to remove these files."
43
+ }
@@ -75,6 +75,17 @@ $targetDir = Join-Path $appCacheDir "cli"
75
75
  $targetPath = Join-Path $targetDir $sourceName
76
76
  New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
77
77
 
78
+ function Get-FileSha256([string]$Path) {
79
+ $sha256 = [System.Security.Cryptography.SHA256]::Create()
80
+ $stream = [System.IO.File]::OpenRead($Path)
81
+ try {
82
+ return ([BitConverter]::ToString($sha256.ComputeHash($stream))).Replace("-", "")
83
+ } finally {
84
+ $stream.Dispose()
85
+ $sha256.Dispose()
86
+ }
87
+ }
88
+
78
89
  if (-not $sourcePath) {
79
90
  foreach ($checkedPath in ($checkedSourcePaths | Select-Object -Unique)) {
80
91
  Write-Log "Checked CLI source path: $checkedPath"
@@ -87,7 +98,7 @@ if (-not $sourcePath) {
87
98
  } else {
88
99
  $needsCopy = -not (Test-Path -LiteralPath $targetPath -PathType Leaf)
89
100
  if (-not $needsCopy) {
90
- $needsCopy = (Get-FileHash -LiteralPath $sourcePath -Algorithm SHA256).Hash -ne (Get-FileHash -LiteralPath $targetPath -Algorithm SHA256).Hash
101
+ $needsCopy = (Get-FileSha256 $sourcePath) -ne (Get-FileSha256 $targetPath)
91
102
  }
92
103
  if ($needsCopy) {
93
104
  Copy-Item -LiteralPath $sourcePath -Destination $targetPath -Force