@walkhi/code-relax 0.1.0-beta.43 → 0.1.0-beta.44
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.
|
@@ -224,7 +224,8 @@ async function main() {
|
|
|
224
224
|
return;
|
|
225
225
|
}
|
|
226
226
|
if (command === 'doctor' || command === 'diag') {
|
|
227
|
-
const
|
|
227
|
+
const cliVersion = readRecord(path.join(packageRoot(path.dirname(fileURLToPath(import.meta.url))), 'package.json'))?.version;
|
|
228
|
+
const result = await doctor({ paths, host, service, ensureAutostart, cliVersion, diagnostics: command === 'diag' });
|
|
228
229
|
console.log(json ? JSON.stringify(result) : formatDoctorOutput(result, command === 'diag'));
|
|
229
230
|
if (!result.ready) process.exitCode = 1;
|
|
230
231
|
return;
|
package/dist/build-platform.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"layout":"npm-platform-packages","version":"0.1.0-beta.
|
|
1
|
+
{"layout":"npm-platform-packages","version":"0.1.0-beta.44"}
|
|
@@ -5,7 +5,14 @@ import { readRecord } from './service-lifecycle.mjs';
|
|
|
5
5
|
import { inspectSkill } from './skill-install.mjs';
|
|
6
6
|
import { recoveryStatus } from './shared-recovery.mjs';
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export function packageDeploymentCheck(cliVersion, installedVersion) {
|
|
9
|
+
if (!cliVersion) return { id: 'package-version', status: 'warning', message: '无法读取当前 CLI 包版本,未确认本次部署版本。' };
|
|
10
|
+
if (cliVersion !== installedVersion) return { id: 'package-version', status: 'error',
|
|
11
|
+
message: `当前 CLI 包为 ${cliVersion},固定服务为 ${installedVersion || '未确认'};本次包尚未完整部署。安装脚本可能未执行或执行失败,不能仅凭 npm 警告判断。请查看 install.log;确认允许部署并中断相关任务后,执行 relax setup,再运行 relax doctor。无需放开全局 npm 脚本权限。` };
|
|
12
|
+
return { id: 'package-version', status: 'ok', message: `CLI 与固定服务版本一致:${cliVersion}。这不单独证明本次 postinstall 执行过;当前可用性以下方服务和内核检查为准。` };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function doctor({ paths, host, service, skillTarget, ensureAutostart, cliVersion, diagnostics = false }) {
|
|
9
16
|
const checks = [];
|
|
10
17
|
let installedVersion;
|
|
11
18
|
let kernelUpdate = null;
|
|
@@ -17,11 +24,12 @@ export async function doctor({ paths, host, service, skillTarget, ensureAutostar
|
|
|
17
24
|
};
|
|
18
25
|
await check('installation', async () => {
|
|
19
26
|
const record = readRecord(path.join(paths.serviceRoot, 'installation.json'));
|
|
20
|
-
if (!record || !fs.existsSync(path.join(paths.serviceRoot, 'dist/bin/codex-remote.mjs'))) throw Error('
|
|
27
|
+
if (!record || !fs.existsSync(path.join(paths.serviceRoot, 'dist/bin/codex-remote.mjs'))) throw Error('尚未完整部署服务;安装脚本可能未执行或执行失败。请查看 install.log,确认部署后执行 relax setup,再运行 relax doctor;不能仅凭 npm 警告判断原因。');
|
|
21
28
|
if (!record.nodeExecutable || !fs.existsSync(record.nodeExecutable)) throw Error('记录的 Node 已失效,请用可用的 Node 重新安装 Code Relax。');
|
|
22
29
|
installedVersion = record.version;
|
|
23
30
|
add('installation', 'ok', `已安装版本:${record.version};Node:${record.nodeExecutable}`);
|
|
24
31
|
});
|
|
32
|
+
checks.push(packageDeploymentCheck(cliVersion, installedVersion));
|
|
25
33
|
await check('bridge-runtime', async () => {
|
|
26
34
|
await host.bridgeEnvironment();
|
|
27
35
|
add('bridge-runtime', 'ok', '桌面服务启动环境正常。');
|
|
@@ -46,9 +54,12 @@ export async function doctor({ paths, host, service, skillTarget, ensureAutostar
|
|
|
46
54
|
}
|
|
47
55
|
add('service', state.running ? 'ok' : 'error', state.running
|
|
48
56
|
? `本机服务正常:${state.mode},端口 ${state.port},运行版本:${state.version || '未知'}` : '服务未就绪;安装后执行 relax start。');
|
|
49
|
-
if (state.running && installedVersion && state.version !== installedVersion) add('service-version', '
|
|
57
|
+
if (state.running && installedVersion && state.version !== installedVersion) add('service-version', 'error', state.version
|
|
50
58
|
? `已安装版本 ${installedVersion},但当前运行版本为 ${state.version};请重新执行安装或重启工作站服务。`
|
|
51
|
-
: `已安装版本 ${installedVersion}
|
|
59
|
+
: `已安装版本 ${installedVersion},但无法确认运行服务版本;请保留诊断结果核查,不能据此认定旧进程或自动重启。`);
|
|
60
|
+
if (state.running) add('execution', state.execution?.ready === true && state.execution?.canWrite === true ? 'ok' : 'error',
|
|
61
|
+
state.execution?.ready === true && state.execution?.canWrite === true
|
|
62
|
+
? 'Codex 完整控制已就绪且可写。' : 'Codex 完整控制尚未确认就绪且可写;请查看内核和连接诊断,不能仅凭服务在线判定健康。');
|
|
52
63
|
const currentVersion = state.managedAppServer?.version || null;
|
|
53
64
|
const selectedVersion = state.managedAppServer?.selectedVersion || null;
|
|
54
65
|
if (state.managedAppServer) kernelUpdate = { pending: state.managedAppServer.updatePending === true,
|
|
@@ -86,7 +97,7 @@ export async function doctor({ paths, host, service, skillTarget, ensureAutostar
|
|
|
86
97
|
export function formatDoctorOutput(result, detail = false) {
|
|
87
98
|
const labels = { 'keep-awake': '保持唤醒', installation: '安装文件', 'bridge-runtime': '运行环境', network: '局域网',
|
|
88
99
|
autostart: '登录自启动', service: '工作站服务', 'managed-app-server': 'Codex 内核',
|
|
89
|
-
'service-version': '服务版本', 'managed-app-server-update': 'Codex 更新',
|
|
100
|
+
execution: '完整控制', 'package-version': '安装包版本', 'service-version': '服务版本', 'managed-app-server-update': 'Codex 更新',
|
|
90
101
|
'managed-app-server-launcher': '工作站更新', skill: 'Codex Skill' };
|
|
91
102
|
const byId = id => result.checks.find(item => item.id === id);
|
|
92
103
|
const summary = (id, success) => {
|
|
@@ -95,7 +106,7 @@ export function formatDoctorOutput(result, detail = false) {
|
|
|
95
106
|
};
|
|
96
107
|
const issues = result.checks.filter(item => item.status !== 'ok');
|
|
97
108
|
const lines = [result.ready ? '工作站检查通过。' : '工作站检查发现问题。',
|
|
98
|
-
summary('installation', '完整'), summary('service', '正在运行'), summary('managed-app-server', '已就绪')];
|
|
109
|
+
summary('installation', '完整'), summary('package-version', 'CLI 与固定服务一致'), summary('service', '正在运行'), summary('managed-app-server', '已就绪'), summary('execution', '已就绪且可写')];
|
|
99
110
|
if (issues.length) lines.push('', '需要处理或留意:', ...issues.map(item => `- ${labels[item.id] || item.id}:${item.message}`));
|
|
100
111
|
if (detail) {
|
|
101
112
|
const info = result.diagnostics || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkhi/code-relax",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"tag": "beta"
|
|
42
42
|
},
|
|
43
43
|
"optionalDependencies": {
|
|
44
|
-
"@walkhi/code-relax-native-win32-x64": "0.1.0-beta.
|
|
45
|
-
"@walkhi/code-relax-native-darwin-arm64": "0.1.0-beta.
|
|
46
|
-
"@walkhi/code-relax-native-darwin-x64": "0.1.0-beta.
|
|
44
|
+
"@walkhi/code-relax-native-win32-x64": "0.1.0-beta.44",
|
|
45
|
+
"@walkhi/code-relax-native-darwin-arm64": "0.1.0-beta.44",
|
|
46
|
+
"@walkhi/code-relax-native-darwin-x64": "0.1.0-beta.44"
|
|
47
47
|
}
|
|
48
48
|
}
|
package/tools/postinstall.mjs
CHANGED
|
@@ -53,7 +53,7 @@ export function formatSetupOutput(output) {
|
|
|
53
53
|
try {
|
|
54
54
|
const result = JSON.parse(output);
|
|
55
55
|
const migration = result.managedAppServerMigration || {};
|
|
56
|
-
return `Code Relax ${result.version || '未知版本'}
|
|
56
|
+
return `Code Relax ${result.version || '未知版本'} setup 已完成;接下来执行安装后健康检查。\n`
|
|
57
57
|
+ '工作站服务和 Codex 内核已就绪,已启用登录自启。\n'
|
|
58
58
|
+ (result.preserveCodex ? '过渡版保留当前 Codex 和内核运行状态;待手机发起下一次完整更新。\n' : migration.restarted ? `Codex 内核已更新:${migration.previousVersion || '未知'} → ${result.managedAppServer?.version || '未知'}(PID ${migration.previousPid} → ${migration.currentPid})。\n` : 'Codex 内核已是当前选定版本,无需切换。\n')
|
|
59
59
|
+ (result.preserveCodex ? '' : result.desktopRestarted ? '电脑版 Codex 已重启,并确认连接到工作站内核。\n' : '安装前未运行电脑版 Codex,保持关闭。\n')
|
|
@@ -152,10 +152,14 @@ if (invokedDirectly && process.env.npm_config_global === 'true') {
|
|
|
152
152
|
prepareNativePackage(fileURLToPath(new URL('../', import.meta.url)));
|
|
153
153
|
setupStarted = true;
|
|
154
154
|
runStage(entry, 'setup', ['setup', '--json'], output => formatSetupOutput(output));
|
|
155
|
-
try {
|
|
155
|
+
try {
|
|
156
|
+
runStage(entry, 'doctor', ['doctor']);
|
|
157
|
+
console.log('Code Relax 自动安装成功:setup 与安装后健康检查均已通过,无需重复执行 setup。');
|
|
158
|
+
console.log('npm 的脚本安全提示与安装结果分别判断;本次安装脚本已实际执行,未修改 npm 安全配置。');
|
|
159
|
+
}
|
|
156
160
|
catch (error) {
|
|
157
161
|
console.error('服务安装已完成,但安装后健康检查未通过;请查看上方诊断与安装日志。');
|
|
158
|
-
process.exitCode = 1;
|
|
162
|
+
process.exitCode = Number.isInteger(error?.status) && error.status > 0 ? error.status : 1;
|
|
159
163
|
}
|
|
160
164
|
console.log(`安装日志:${installLog}`);
|
|
161
165
|
appendLog(process.exitCode ? '[postinstall] failed stage=doctor' : '[postinstall] success');
|