@ganglion/xacpx 0.8.2 → 0.8.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.
Files changed (2) hide show
  1. package/dist/cli.js +29 -7
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2023,7 +2023,7 @@ var require_lib = __commonJS((exports, module) => {
2023
2023
 
2024
2024
  // src/util/private-file.ts
2025
2025
  import { chmod, mkdir, writeFile } from "node:fs/promises";
2026
- import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
2026
+ import { chmodSync, mkdirSync as mkdirSync2, writeFileSync } from "node:fs";
2027
2027
  import { dirname } from "node:path";
2028
2028
  async function writePrivateFileAtomic(path, content) {
2029
2029
  await mkdir(dirname(path), { recursive: true });
@@ -2057,7 +2057,7 @@ async function writePrivateFileAtomic(path, content) {
2057
2057
  }
2058
2058
  }
2059
2059
  function writePrivateFileSync(path, content, deps = {}) {
2060
- mkdirSync(dirname(path), { recursive: true });
2060
+ mkdirSync2(dirname(path), { recursive: true });
2061
2061
  const platform = deps.platform ?? process.platform;
2062
2062
  const atomicWrite = deps.atomicWrite ?? ((p, c) => import_write_file_atomic.default.sync(p, c, { mode: PRIVATE_FILE_MODE, encoding: "utf8", fsync: true }));
2063
2063
  try {
@@ -31142,24 +31142,24 @@ import { fileURLToPath as fileURLToPath7 } from "node:url";
31142
31142
 
31143
31143
  // src/runtime/migrate-core-home.ts
31144
31144
  init_core_home();
31145
- import { cpSync, existsSync as existsSync2, readFileSync } from "node:fs";
31145
+ import { copyFileSync, cpSync, existsSync as existsSync2, mkdirSync, readFileSync } from "node:fs";
31146
31146
  import { join as join2 } from "node:path";
31147
31147
  function migrateCoreHome(home, deps = {}) {
31148
31148
  const log = deps.log ?? ((message) => console.error(message));
31149
31149
  const isProcessAlive = deps.isProcessAlive ?? defaultIsProcessAlive;
31150
31150
  const primary = join2(home, CORE_HOME_DIR_NAME);
31151
- if (existsSync2(primary)) {
31152
- return { migrated: false, reason: "already-current" };
31153
- }
31154
31151
  const legacy = join2(home, CORE_HOME_LEGACY_DIR_NAME);
31155
31152
  if (!existsSync2(legacy)) {
31156
- return { migrated: false, reason: "no-legacy" };
31153
+ return existsSync2(primary) ? { migrated: false, reason: "already-current" } : { migrated: false, reason: "no-legacy" };
31157
31154
  }
31158
31155
  const legacyPid = readLegacyDaemonPid(legacy);
31159
31156
  if (legacyPid !== null && isProcessAlive(legacyPid)) {
31160
31157
  log(`检测到运行中的旧守护进程 (pid ${legacyPid}),暂不迁移 ${legacy} → ${primary};` + `请先停止守护进程(weacpx stop / xacpx stop)后重试,期间仍使用旧目录。`);
31161
31158
  return { migrated: false, reason: "daemon-running", from: legacy };
31162
31159
  }
31160
+ if (existsSync2(primary)) {
31161
+ return supplementMissingCoreFiles({ legacy, primary, log });
31162
+ }
31163
31163
  try {
31164
31164
  cpSync(legacy, primary, { recursive: true });
31165
31165
  log(`已将状态目录从 ${legacy} 复制到 ${primary}(旧目录保留为备份,可手动删除)。`);
@@ -31170,6 +31170,28 @@ function migrateCoreHome(home, deps = {}) {
31170
31170
  return { migrated: false, reason: "failed", from: legacy };
31171
31171
  }
31172
31172
  }
31173
+ function supplementMissingCoreFiles(input) {
31174
+ const copied = [];
31175
+ for (const fileName of ["config.json", "state.json"]) {
31176
+ const from = join2(input.legacy, fileName);
31177
+ const to = join2(input.primary, fileName);
31178
+ if (!existsSync2(from) || existsSync2(to))
31179
+ continue;
31180
+ try {
31181
+ mkdirSync(input.primary, { recursive: true });
31182
+ copyFileSync(from, to);
31183
+ copied.push(fileName);
31184
+ } catch (error) {
31185
+ const detail = error instanceof Error ? error.message : String(error);
31186
+ input.log(`补迁移 ${from} → ${to} 失败,已跳过:${detail}`);
31187
+ }
31188
+ }
31189
+ if (copied.length === 0) {
31190
+ return { migrated: false, reason: "already-current" };
31191
+ }
31192
+ input.log(`已从旧目录补迁移 ${copied.join(", ")} 到 ${input.primary}(未覆盖任何现有文件)。`);
31193
+ return { migrated: true, reason: "supplemented", from: input.legacy, to: input.primary };
31194
+ }
31173
31195
  function readLegacyDaemonPid(legacyHome) {
31174
31196
  try {
31175
31197
  const content = readFileSync(join2(legacyHome, "runtime", "daemon.pid"), "utf8");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ganglion/xacpx",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "随时随地通过聊天频道(微信 / 飞书 / 元宝等)远程控制 `acpx` 上的 Claude Code、Codex 等 Agents。",
5
5
  "keywords": [
6
6
  "acpx",