dsh-fish-pet 0.2.1 → 0.2.3

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/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /**
1
+ /**
2
2
  * dsh-fish-pet · host half
3
3
  *
4
4
  * 把桌面蓝鱼托管进 DeepSeek Harness:
@@ -9,7 +9,7 @@
9
9
  * 只动 Windows:脚本依赖 System.Windows.Forms 与 user32 的分层窗口。
10
10
  */
11
11
  import { spawn, spawnSync } from 'node:child_process'
12
- import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs'
12
+ import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
13
13
  import { homedir } from 'node:os'
14
14
  import path from 'node:path'
15
15
  import { fileURLToPath } from 'node:url'
@@ -98,6 +98,7 @@ function startPet(cfg) {
98
98
 
99
99
  function stopPet(state) {
100
100
  if (!state || !state.owned) return
101
+ try { writeFileSync(path.join(DATA_DIR, 'asr.stop'), new Date().toISOString()) } catch { }
101
102
  const pid = readPid() ?? state.pid
102
103
  if (isAlive(pid)) {
103
104
  spawnSync('taskkill', ['/PID', String(pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fish-pet",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Desktop blue fish pet for DeepSeek Harness: per-pixel transparent WinForms window, text chat, and cloud speech-to-text voice conversation.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -12,6 +12,8 @@
12
12
  "lib",
13
13
  "assets",
14
14
  "docs",
15
+ "tools",
16
+ "CHANGELOG.md",
15
17
  "cordis.patch.yml",
16
18
  "README.md",
17
19
  "LICENSE"
@@ -0,0 +1,28 @@
1
+ # encrypt-keys.ps1 · 把明文 key 换成 Windows DPAPI 加密文件
2
+ # 用法: powershell -ExecutionPolicy Bypass -File tools\encrypt-keys.ps1
3
+ # 加密后生成 <name>.key.enc 并删除明文 <name>.key;鱼和耳朵会优先读 .enc
4
+
5
+ $dir = Join-Path $env:USERPROFILE '.dsh\fish-pet'
6
+ if (-not (Test-Path $dir)) { Write-Host "找不到数据目录:$dir"; exit 1 }
7
+
8
+ $encrypted = 0
9
+ foreach ($name in @('deepseek', 'siliconflow')) {
10
+ $plain = Join-Path $dir ($name + '.key')
11
+ if (-not (Test-Path $plain)) { continue }
12
+ $v = (Get-Content -LiteralPath $plain -Raw -ErrorAction SilentlyContinue)
13
+ if (-not $v) { continue }
14
+ $v = $v.Trim()
15
+ if (-not $v) { continue }
16
+ $enc = Join-Path $dir ($name + '.key.enc')
17
+ $v | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString |
18
+ Set-Content -LiteralPath $enc -NoNewline
19
+ Remove-Item $plain -Force
20
+ Write-Host "$name:已加密 -> $enc"
21
+ $encrypted++
22
+ }
23
+
24
+ if ($encrypted -eq 0) {
25
+ Write-Host "没有找到可加密的明文 key(可能已经加密过)"
26
+ } else {
27
+ Write-Host "完成,共加密 $encrypted 个。加密只能在本机当前用户下解开。"
28
+ }
@@ -0,0 +1,46 @@
1
+ # publish.ps1 · 发布 dsh-fish-pet 到 npm(token 只在本机内存/临时 .npmrc 中出现)
2
+ # 用法:在 PowerShell 里运行
3
+ # powershell -ExecutionPolicy Bypass -File tools\publish.ps1
4
+ # token 输入时不回显;发布完自动删除 .npmrc 里的那一行
5
+
6
+ $ErrorActionPreference = 'Stop'
7
+ $pkgDir = Split-Path -Parent $PSScriptRoot
8
+ $npmrc = Join-Path $env:USERPROFILE '.npmrc'
9
+ $registry = 'https://registry.npmjs.org'
10
+
11
+ Write-Host "包目录: $pkgDir" -ForegroundColor Cyan
12
+ Push-Location $pkgDir
13
+ try {
14
+ $pkg = Get-Content "package.json" -Raw | ConvertFrom-Json
15
+ Write-Host "将发布: $($pkg.name)@$($pkg.version)" -ForegroundColor Cyan
16
+
17
+ # 确认没登录也继续(下面用一次性 token)
18
+ $secure = Read-Host "粘贴 npm Granular Token(npm_ 开头,输入不回显)" -AsSecureString
19
+ $bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
20
+ try { $token = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr) } finally { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($bstr) }
21
+ $token = $token.Trim()
22
+ if (-not $token.StartsWith('npm_')) { throw "token 格式不对(应以 npm_ 开头)" }
23
+
24
+ # 备份 .npmrc,追加临时认证行
25
+ $backup = $null
26
+ if (Test-Path $npmrc) { $backup = Get-Content $npmrc -Raw } else { $backup = '' }
27
+ try {
28
+ $line = "//registry.npmjs.org/:_authToken=$token"
29
+ [IO.File]::AppendAllText($npmrc, "`r`n$line`r`n", (New-Object Text.UTF8Encoding($false)))
30
+
31
+ Write-Host "`n正在发布到 $registry ..." -ForegroundColor Yellow
32
+ & npm publish --registry=$registry
33
+ $code = $LASTEXITCODE
34
+ if ($code -ne 0) { Write-Host "发布失败(exit $code)" -ForegroundColor Red }
35
+ else { Write-Host "`n发布成功:https://www.npmjs.com/package/$($pkg.name)" -ForegroundColor Green }
36
+ }
37
+ finally {
38
+ # 还原 .npmrc(彻底去掉 token)
39
+ [IO.File]::WriteAllText($npmrc, $backup, (New-Object Text.UTF8Encoding($false)))
40
+ $left = (Select-String -Path $npmrc -Pattern 'npm_' -ErrorAction SilentlyContinue).Count
41
+ Write-Host ".npmrc 已还原(残留 token 行: $left)" -ForegroundColor Cyan
42
+ }
43
+ }
44
+ finally {
45
+ Pop-Location
46
+ }