@leviyuan/lodestar 0.12.2 → 0.12.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/dist/lodestar-update.js +2 -2
- package/package.json +11 -1
- package/scripts/postinstall.cjs +26 -0
package/dist/lodestar-update.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{spawn as b}from"node:child_process";import{existsSync as g}from"node:fs";import{homedir as d}from"node:os";import{join as o}from"node:path";var r=d(),a=process.platform==="win32";function
|
|
2
|
+
import{spawn as b}from"node:child_process";import{existsSync as g}from"node:fs";import{homedir as d}from"node:os";import{join as o}from"node:path";var r=d(),a=process.platform==="win32";function n(e,l,m){if(e)return e;if(l)return o(l,"lodestar");return m}function y(){if(a)return o(process.env.APPDATA??o(r,"AppData","Roaming"),"Lodestar");return o(r,".config","lodestar")}function u(){if(a)return o(process.env.LOCALAPPDATA??o(r,"AppData","Local"),"Lodestar");return o(r,".local","share","lodestar")}var C=n(process.env.LODESTAR_CONFIG_DIR,process.env.XDG_CONFIG_HOME,y()),t=n(process.env.LODESTAR_DATA_DIR,process.env.XDG_DATA_HOME,u()),K=process.env.LODESTAR_CONFIG??o(C,"config.toml"),$=o(t,"daemon.pid"),f=o(t,"daemon.log"),S=o(t,"session-chat-map.json"),i=o(t,"session-resume-map.json"),q=o(t,"session-turns-map.json"),z=o(t,"session-model-map.json"),J=o(t,"tasklist-map.json"),Q=o(t,"notify-callbacks.json"),Y=o(t,"alive-on-shutdown.json"),Z=o(t,"inbox"),W=o(t,"debug.sock"),X=o(t,"debug-context.json");var s={reset:"\x1B[0m",bold:"\x1B[1m",cyan:"\x1B[36m",green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",dim:"\x1B[2m"},p=["@leviyuan/lodestar@latest","@openai/codex@latest","@anthropic-ai/claude-code@latest","@anthropic-ai/claude-agent-sdk@latest","@anthropic-ai/sdk@latest"];function w(){let e=process.platform==="win32"?"npm.cmd":"npm";return new Promise((l)=>{let m=b(e,["install","-g","--include=optional",...p],{stdio:"inherit",shell:process.platform==="win32"});m.on("exit",(c)=>l(c??1)),m.on("error",(c)=>{console.error(`${s.red}spawn npm 失败:${s.reset} ${c.message}`),l(1)})})}async function x(){console.log(`${s.bold}更新 Lodestar + Codex CLI + Claude Code / SDK${s.reset}`),console.log(`${s.dim}npm i -g ${p.join(" ")}${s.reset}
|
|
3
3
|
`);let e=await w();if(e!==0)console.error(`
|
|
4
4
|
${s.red}更新失败 (npm exit ${e})${s.reset}`),process.exit(e);if(console.log(`
|
|
5
|
-
${s.green}✓ 更新完成${s.reset}`),g(
|
|
5
|
+
${s.green}✓ 更新完成${s.reset}`),g($))console.log(),console.log(`${s.yellow}检测到 daemon 仍在跑老版本进程, 用新版本需要重启:${s.reset}`),console.log(` ${s.dim}# systemd / Windows 后台托管的:${s.reset}`),console.log(` ${s.cyan}systemctl --user restart lodestar${s.reset} ${s.dim}# Linux/macOS${s.reset}`),console.log(` ${s.dim}# 或手动重启:${s.reset}`),console.log(` ${s.cyan}lodestar-stop && lodestar-daemon${s.reset}`)}x().catch((e)=>{console.error(`${s.red}lodestar-update:${s.reset} ${e?.message??e}`),process.exit(1)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leviyuan/lodestar",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -61,6 +61,16 @@
|
|
|
61
61
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
62
62
|
"zod": "^4.4.3"
|
|
63
63
|
},
|
|
64
|
+
"optionalDependencies": {
|
|
65
|
+
"@anthropic-ai/claude-agent-sdk-darwin-arm64": "^0.3.181",
|
|
66
|
+
"@anthropic-ai/claude-agent-sdk-darwin-x64": "^0.3.181",
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk-linux-arm64": "^0.3.181",
|
|
68
|
+
"@anthropic-ai/claude-agent-sdk-linux-arm64-musl": "^0.3.181",
|
|
69
|
+
"@anthropic-ai/claude-agent-sdk-linux-x64": "^0.3.181",
|
|
70
|
+
"@anthropic-ai/claude-agent-sdk-linux-x64-musl": "^0.3.181",
|
|
71
|
+
"@anthropic-ai/claude-agent-sdk-win32-arm64": "^0.3.181",
|
|
72
|
+
"@anthropic-ai/claude-agent-sdk-win32-x64": "^0.3.181"
|
|
73
|
+
},
|
|
64
74
|
"devDependencies": {
|
|
65
75
|
"@types/bun": "latest",
|
|
66
76
|
"typescript": "^5.5.0"
|
package/scripts/postinstall.cjs
CHANGED
|
@@ -12,6 +12,32 @@
|
|
|
12
12
|
// 所以这里只打个提示就 process.exit(0), 不 spawn 任何子进程, 永不卡死。
|
|
13
13
|
|
|
14
14
|
const fs = require('fs')
|
|
15
|
+
const path = require('path')
|
|
16
|
+
const { execFileSync } = require('child_process')
|
|
17
|
+
|
|
18
|
+
// 自愈:确保当前平台的 SDK native binary 已装。走 SDK 默认入口后该 binary 是必需,
|
|
19
|
+
// 但 npm i -g 对 nested platform optional 在某些 npm 版本/历史残留下会漏装。
|
|
20
|
+
// 装漏了就在这里补,不依赖 npm 行为。非交互、stdio ignore,不碰 tty(区别于曾导致
|
|
21
|
+
// macOS 卡死的 readline 向导)。
|
|
22
|
+
;(function ensureNativeBinary () {
|
|
23
|
+
const base = `claude-agent-sdk-${process.platform}-${process.arch}`
|
|
24
|
+
const variants = process.platform === 'linux' ? [base, `${base}-musl`] : [base]
|
|
25
|
+
const nm = path.join(__dirname, '..', 'node_modules', '@anthropic-ai')
|
|
26
|
+
const has = (name) =>
|
|
27
|
+
fs.existsSync(path.join(nm, name)) ||
|
|
28
|
+
fs.existsSync(path.join(nm, 'claude-agent-sdk', 'node_modules', '@anthropic-ai', name))
|
|
29
|
+
if (variants.some(has)) return
|
|
30
|
+
try {
|
|
31
|
+
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
|
|
32
|
+
execFileSync(npm, ['install', '--include=optional', '--no-save', '--no-audit', '--no-fund'], {
|
|
33
|
+
cwd: path.join(__dirname, '..'),
|
|
34
|
+
stdio: 'ignore',
|
|
35
|
+
timeout: 180000,
|
|
36
|
+
})
|
|
37
|
+
} catch {
|
|
38
|
+
// 补装失败:静默(optional)。daemon 启动时 SDK 会报明确的 "Native CLI binary not found"
|
|
39
|
+
}
|
|
40
|
+
})()
|
|
15
41
|
|
|
16
42
|
function termWrite (msg) {
|
|
17
43
|
try {
|