@lark-people/cli 0.0.5 → 0.0.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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-people/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "The official CLI for People open platform",
5
5
  "bin": {
6
6
  "people-cli": "scripts/run.js"
@@ -309,6 +309,29 @@ function sameResolvedPath(a, b) {
309
309
  }
310
310
  }
311
311
 
312
+ function resolveExistingPath(targetPath) {
313
+ if (!targetPath) {
314
+ return null;
315
+ }
316
+ try {
317
+ return fs.realpathSync(targetPath);
318
+ } catch (_) {
319
+ return targetPath;
320
+ }
321
+ }
322
+
323
+ function isNpxCachePath(packageDir) {
324
+ if (!packageDir) {
325
+ return false;
326
+ }
327
+ const normalized = String(packageDir).replace(/\\/g, "/");
328
+ return normalized.includes("/_npx/") && normalized.includes("/node_modules/");
329
+ }
330
+
331
+ function packageInstallTarget(packageName, version) {
332
+ return version ? `${packageName}@${version}` : packageName;
333
+ }
334
+
312
335
  function parseVersion(version) {
313
336
  if (!version) {
314
337
  return null;
@@ -355,10 +378,19 @@ function planGlobalInstall({
355
378
  currentPackageDir = CURRENT_PACKAGE_DIR,
356
379
  globalPackageDir = resolveGlobalPackageDir(currentPackageName),
357
380
  } = {}) {
381
+ const resolvedCurrentPackageDir = resolveExistingPath(currentPackageDir);
382
+ const resolvedGlobalPackageDir = resolveExistingPath(globalPackageDir);
383
+ const currentPackageFromNpxCache = isNpxCachePath(currentPackageDir) || isNpxCachePath(resolvedCurrentPackageDir);
384
+ const globalPackageLinkedToNpxCache = isNpxCachePath(globalPackageDir) || isNpxCachePath(resolvedGlobalPackageDir);
385
+ const missingGlobalInstallFromNpxCache = currentPackageFromNpxCache && !installedVersion;
386
+ const registryInstallVersion = currentVersion || latestVersion || installedVersion || null;
387
+ const registryInstallTarget = packageInstallTarget(currentPackageName, registryInstallVersion);
358
388
  const useCurrentPackage = Boolean(
359
389
  currentPackageDir &&
360
390
  globalPackageDir &&
361
- !sameResolvedPath(currentPackageDir, globalPackageDir),
391
+ !sameResolvedPath(currentPackageDir, globalPackageDir) &&
392
+ !currentPackageFromNpxCache &&
393
+ !globalPackageLinkedToNpxCache,
362
394
  );
363
395
 
364
396
  if (useCurrentPackage) {
@@ -377,11 +409,12 @@ function planGlobalInstall({
377
409
  installVersion &&
378
410
  compareVersions(installedVersion, installVersion) < 0,
379
411
  );
412
+ const needsRepair = Boolean(globalPackageLinkedToNpxCache || missingGlobalInstallFromNpxCache);
380
413
 
381
414
  return {
382
- skip: Boolean(installedVersion && !needsUpgrade),
415
+ skip: Boolean(installedVersion && !needsUpgrade && !needsRepair),
383
416
  needsUpgrade,
384
- installTarget: currentPackageName,
417
+ installTarget: needsRepair ? registryInstallTarget : currentPackageName,
385
418
  installVersion,
386
419
  useCurrentPackage: false,
387
420
  };
@@ -43,19 +43,36 @@ npx @lark-people/cli install
43
43
 
44
44
  ### Step 2: 检查版本并处理更新
45
45
 
46
- 检查是否有更新:
46
+ 必须先执行结构化检查:
47
+
48
+ ```bash
49
+ people-cli update --check --json
50
+ ```
51
+
52
+ 判断规则:
53
+
54
+ - `update_available=true`:必须立即执行 `people-cli update`,不能继续 Step 3 或任何业务命令。
55
+ - `skills_status.in_sync=false`:即使 CLI 已是最新版,也必须立即执行 `people-cli update` 同步 Skills,不能继续 Step 3 或任何业务命令。
56
+ - 只有 `update_available=false`,且 `skills_status.in_sync` 不为 `false` 时,才能继续 Step 3。
57
+ - 命令失败、输出不是合法 JSON、或缺少 `update_available` 字段:改用文本检查兜底。
58
+
59
+ 文本检查兜底:
47
60
 
48
61
  ```bash
49
62
  people-cli update --check
50
63
  ```
51
64
 
52
- 如果提示有新版本,或后续任意 `people-cli` 输出中提示需要更新 CLI / Skills,执行:
65
+ 如果输出包含 `Update available:` 或提示运行 `people-cli update`,即使命令退出码是 0,也代表存在可更新版本;必须立即执行:
53
66
 
54
67
  ```bash
55
68
  people-cli update
56
69
  ```
57
70
 
58
- 更新完成后重新执行 `people-cli --version`。如果更新同步了 Skills,提醒用户退出并重新打开 AI Agent,让新 Skills 生效。
71
+ 更新完成后必须重新执行 `people-cli --version` 和 `people-cli update --check --json`。只有确认 `update_available=false`,且 `skills_status.in_sync` 不为 `false` 后,才能继续 Step 3 或业务命令。
72
+
73
+ 如果 `people-cli update` 失败、更新后版本仍不是最新,或检查结果仍显示 `update_available=true` / `skills_status.in_sync=false`,停止业务操作,并把错误信息和 CLI 返回的 hint 告知用户。
74
+
75
+ 例外:如果 `people-cli update` 返回 `update_error`,且 `hint` 是明确的 `npm install -g @lark-people/cli@...` 或 `pnpm add -g @lark-people/cli@...` 安装命令,可以按该 hint 执行一次手动安装兜底。兜底完成后仍必须重新执行 `people-cli --version` 和 `people-cli update --check --json`;复查不通过时停止业务操作。
59
76
 
60
77
  ### Step 3: 检查用户身份和授权
61
78
 
Binary file