@walkhi/code-relax 0.1.0-beta.6 → 0.1.0-beta.7
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 +1 -1
- package/dist/bin/codex-remote.mjs +10 -1
- package/package.json +1 -1
- package/tools/postinstall.mjs +29 -4
package/README.md
CHANGED
|
@@ -80,4 +80,4 @@ npm uninstall -g @walkhi/code-relax
|
|
|
80
80
|
|
|
81
81
|
## 发布边界
|
|
82
82
|
|
|
83
|
-
registry 当前公开包为 `@walkhi/code-relax@0.1.0-beta.
|
|
83
|
+
registry 当前公开包为 `@walkhi/code-relax@0.1.0-beta.7`,主 CLI 为 `relax`,并保留 `code-relax` 兼容入口。该版沿用 beta6 的启动代次自动迁移,并在 npm 安装控制台明确报告 app-server 是否重启、迁移前后 PID、Bridge 恢复结果和安装日志路径;`doctor` 会区分安装版本与运行代次。通信协议仍为 7。详细规则见 [npm 分发](../docs/npm-distribution.md)。
|
|
@@ -206,7 +206,12 @@ async function main() {
|
|
|
206
206
|
throw new Error(bridge.managedAppServer?.error || 'Bridge 已安装,但受管 app-server 未就绪;未写入 Desktop 环境变量。');
|
|
207
207
|
}
|
|
208
208
|
let managedAppServerMigrated = false;
|
|
209
|
-
|
|
209
|
+
const managedAppServerMigration = {
|
|
210
|
+
required: bridge.managedAppServer.launcherRestartRequired === true,
|
|
211
|
+
restarted: false,
|
|
212
|
+
previousPid: bridge.managedAppServer.pid || null,
|
|
213
|
+
};
|
|
214
|
+
if (managedAppServerMigration.required) {
|
|
210
215
|
await service.restartManagedAppServer();
|
|
211
216
|
const migrationDeadline = Date.now() + 40_000;
|
|
212
217
|
do {
|
|
@@ -220,6 +225,7 @@ async function main() {
|
|
|
220
225
|
throw new Error('受管 app-server 未在 40 秒内完成启动链迁移。');
|
|
221
226
|
}
|
|
222
227
|
managedAppServerMigrated = true;
|
|
228
|
+
managedAppServerMigration.restarted = true;
|
|
223
229
|
}
|
|
224
230
|
const autostart = await residentStartup(installed, 'enable');
|
|
225
231
|
const environment = await configureManagedEnvironment(physicalStateRoot);
|
|
@@ -228,6 +234,9 @@ async function main() {
|
|
|
228
234
|
installed.environment = environment;
|
|
229
235
|
installed.managedAppServer = bridge.managedAppServer;
|
|
230
236
|
installed.managedAppServerMigrated = managedAppServerMigrated;
|
|
237
|
+
installed.managedAppServerMigration = { ...managedAppServerMigration,
|
|
238
|
+
currentPid: bridge.managedAppServer.pid || null,
|
|
239
|
+
launcherRevision: bridge.managedAppServer.launcherRevision ?? null };
|
|
231
240
|
installed.desktop = bridge.desktop;
|
|
232
241
|
installed.desktopRestartRecommended = bridge.desktop?.state === 'ordinary';
|
|
233
242
|
const migrationText = managedAppServerMigrated ? '已自动重建旧启动链的 app-server;安装前尚未完成的任务可能已中断。\n' : '';
|
package/package.json
CHANGED
package/tools/postinstall.mjs
CHANGED
|
@@ -33,12 +33,12 @@ function systemSummary() {
|
|
|
33
33
|
+ `osArch=${os.arch()} processArch=${process.arch} node=${process.version} npmUserAgent=${npm}`;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function runStage(entry, stage, args) {
|
|
36
|
+
function runStage(entry, stage, args, formatOutput = value => value) {
|
|
37
37
|
appendLog(`[${stage}] start`);
|
|
38
38
|
try {
|
|
39
39
|
const output = execFileSync(process.execPath, [entry, ...args], { encoding: 'utf8', windowsHide: true,
|
|
40
40
|
stdio: ['inherit', 'pipe', 'pipe'] });
|
|
41
|
-
if (output) { process.stdout.write(output); appendLog(`[${stage}] stdout\n${output.trimEnd()}`); }
|
|
41
|
+
if (output) { process.stdout.write(formatOutput(output)); appendLog(`[${stage}] stdout\n${output.trimEnd()}`); }
|
|
42
42
|
appendLog(`[${stage}] success`);
|
|
43
43
|
} catch (error) {
|
|
44
44
|
if (error?.stdout) { process.stdout.write(error.stdout); appendLog(`[${stage}] stdout\n${String(error.stdout).trimEnd()}`); }
|
|
@@ -48,6 +48,30 @@ function runStage(entry, stage, args) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
export function formatSetupOutput(output, previous = {}) {
|
|
52
|
+
try {
|
|
53
|
+
const result = JSON.parse(output);
|
|
54
|
+
const migration = result.managedAppServerMigration || {};
|
|
55
|
+
const pid = migration.currentPid || result.managedAppServer?.pid || '未知';
|
|
56
|
+
const appServer = migration.restarted
|
|
57
|
+
? `已重启(旧启动链迁移,PID ${migration.previousPid || '未知'} → ${pid})`
|
|
58
|
+
: previous.valid
|
|
59
|
+
? `未重启(PID ${pid},启动代次 ${migration.launcherRevision ?? '未知'} 已是最新)`
|
|
60
|
+
: `已启动(PID ${pid},启动代次 ${migration.launcherRevision ?? '未知'})`;
|
|
61
|
+
return `Code Relax ${result.version || '未知版本'} 安装成功。\n`
|
|
62
|
+
+ `受管 app-server:${appServer}\n`
|
|
63
|
+
+ `Bridge:${result.restarted ? '已恢复并健康' : '已启动并健康'}\n`
|
|
64
|
+
+ `${result.desktopRestartRecommended ? 'Codex Desktop:建议完全退出后重新打开。\n' : ''}`;
|
|
65
|
+
} catch { return output; }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function formatSkillOutput(output) {
|
|
69
|
+
try {
|
|
70
|
+
const result = JSON.parse(output);
|
|
71
|
+
return `Code Relax Skill:${result.message || (result.installed ? '已安装' : '已检查')}\n`;
|
|
72
|
+
} catch { return output; }
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
function installationSnapshot() {
|
|
52
76
|
const recordPath = path.join(serviceRoot, 'installation.json');
|
|
53
77
|
if (!fs.existsSync(serviceRoot)) return { exists: false, valid: false };
|
|
@@ -101,9 +125,10 @@ if (process.env.npm_config_global === 'true') {
|
|
|
101
125
|
let stage = 'setup';
|
|
102
126
|
appendLog(`[postinstall] start package=${process.env.npm_package_version || 'unknown'} ${systemSummary()}`);
|
|
103
127
|
try {
|
|
104
|
-
runStage(entry, stage, ['setup', '--json']);
|
|
128
|
+
runStage(entry, stage, ['setup', '--json'], output => formatSetupOutput(output, previous));
|
|
105
129
|
stage = 'skill-install';
|
|
106
|
-
runStage(entry, stage, ['skill-install', '--json']);
|
|
130
|
+
runStage(entry, stage, ['skill-install', '--json'], formatSkillOutput);
|
|
131
|
+
console.log(`安装日志:${installLog}`);
|
|
107
132
|
appendLog('[postinstall] success');
|
|
108
133
|
} catch (error) {
|
|
109
134
|
const current = installationSnapshot();
|