摘要: 新增 portable 單檔與 zip 資料夾兩種免安裝產物;寵物一律從執行目錄的 pets/ 掃,設定檔不再累積程式自己算出來的路徑。 根本原因: 1. 只有 NSIS 安裝檔,沒有點兩下就能跑的版本。 2. 內附寵物被 asarUnpack 埋在 resources/app.asar.unpacked/pets,使用者要新增寵物得先鑽進 resources 資料夾。 3. loadConfig 會把算出來的來源路徑寫回 config.json,程式一搬家或在安裝版與 portable 之間切換,petSources 就越積越多失效的絕對路徑(實際已累積出 dist/win-unpacked/resources/app.asar.unpacked/pets 這種殘留)。 4. CODEX_PETS_DIR 用到 HOME,但 const HOME 宣告在它下面,會在啟動時就 TDZ ReferenceError。 影響: 沒有免安裝選項;新增寵物的路徑不直覺;設定檔會長出一堆死路徑;且上一版打包後的程式其實一啟動就會崩潰。 修法: - win target 加上 portable 與 zip;portable 設 unpackDirName=ClaudePet、requestExecutionLevel=user。 - pets/ 改用 extraFiles 放到 exe 旁邊(不再進 asar),APP_ROOT 打包後取 process.execPath 的目錄。 - portable 的 NSIS 外殼每次啟動都重解壓、結束就刪整個目錄,因此:hook 腳本另外複製到 ~/.claude-pet/hook/ 並註冊該穩定路徑(否則寵物沒開時 Claude Code 每次觸發 hook 都找不到檔案);使用者寵物放那顆 exe 旁邊;開機自動啟動改用 PORTABLE_EXECUTABLE_FILE。 - petSources 語意改為「只存使用者自己加的額外路徑」;執行目錄的 pets 與 ~/.codex/pets 為隱含來源,由 petSearchDirs() 組出實際掃描清單,載入時剔除隱含項與不存在的路徑。同 id 以使用者自己放的優先。 - 把 HOME/CONFIG_DIR 移到常數區最前面,修掉 TDZ。 - 內附第二隻寵物 xiao-nian-realistic。 驗證: 以 ELECTRON_RUN_AS_NODE 執行打包後的 exe(不開視窗): - 一般模式與模擬 portable 模式下的 pets 路徑、hook 路徑、autostart 指令皆正確。 - 用假的 USERPROFILE 實跑 install/uninstall:hook 腳本確實複製、指令含空白路徑會加引號、其他人的 Stop/PreToolUse hook 與 model 設定在安裝與移除後都完整保留、備份有產生。 - 帶殘留路徑的設定檔會被正確清理,掃描順序為「使用者 pets → 內附 pets → ~/.codex/pets → 額外路徑」。 - 從 app.asar 讀回 main.js 確認出貨的程式碼順序正確。 - 以純 node 載入 main.js,確認常數區與 loadConfig 不再有 TDZ。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
88 lines
2.1 KiB
JSON
88 lines
2.1 KiB
JSON
{
|
||
"name": "claude-pet",
|
||
"version": "0.1.0",
|
||
"description": "Codex Pets 相容的 Claude Code 桌面寵物(spriteVersionNumber 2:9 個動作列 + 16 方向追視)",
|
||
"main": "main.js",
|
||
"private": true,
|
||
"scripts": {
|
||
"start": "electron .",
|
||
"hooks:install": "node scripts/install-hooks.js",
|
||
"hooks:uninstall": "node scripts/uninstall-hooks.js",
|
||
"autostart:install": "node scripts/autostart.js install",
|
||
"autostart:uninstall": "node scripts/autostart.js uninstall",
|
||
"autostart:status": "node scripts/autostart.js status",
|
||
"dist": "electron-builder --win",
|
||
"pack": "electron-builder --win --dir",
|
||
"dist:portable": "electron-builder --win portable"
|
||
},
|
||
"devDependencies": {
|
||
"electron": "^43.4.1",
|
||
"electron-builder": "^26.0.12"
|
||
},
|
||
"author": "JianMiau",
|
||
"build": {
|
||
"appId": "com.jianmiau.claude-pet",
|
||
"productName": "Claude Pet",
|
||
"copyright": "JianMiau",
|
||
"directories": {
|
||
"output": "dist",
|
||
"buildResources": "build"
|
||
},
|
||
"files": [
|
||
"main.js",
|
||
"preload.js",
|
||
"renderer/**/*",
|
||
"lib/**/*",
|
||
"hook/**/*",
|
||
"package.json"
|
||
],
|
||
"asarUnpack": [
|
||
"hook/**/*"
|
||
],
|
||
"win": {
|
||
"target": [
|
||
{
|
||
"target": "nsis",
|
||
"arch": [
|
||
"x64"
|
||
]
|
||
},
|
||
{
|
||
"target": "portable",
|
||
"arch": [
|
||
"x64"
|
||
]
|
||
},
|
||
{
|
||
"target": "zip",
|
||
"arch": [
|
||
"x64"
|
||
]
|
||
}
|
||
],
|
||
"icon": "build/icon.ico"
|
||
},
|
||
"nsis": {
|
||
"oneClick": false,
|
||
"perMachine": false,
|
||
"allowToChangeInstallationDirectory": true,
|
||
"createDesktopShortcut": true,
|
||
"createStartMenuShortcut": true,
|
||
"shortcutName": "Claude Pet",
|
||
"deleteAppDataOnUninstall": false,
|
||
"artifactName": "${productName}-${version}-setup.${ext}"
|
||
},
|
||
"portable": {
|
||
"artifactName": "${productName}-${version}-portable.${ext}",
|
||
"unpackDirName": "ClaudePet",
|
||
"requestExecutionLevel": "user"
|
||
},
|
||
"extraFiles": [
|
||
{
|
||
"from": "pets",
|
||
"to": "pets"
|
||
}
|
||
]
|
||
}
|
||
}
|