@insmind/cli 1.5.4 → 1.5.6

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.
@@ -5,6 +5,7 @@ import { dirname, resolve } from "node:path";
5
5
  import { loadBundledSkills } from "../src/features/skill/bundled-skills.js";
6
6
  import { syncBundledSkills } from "../src/features/skill/installer.js";
7
7
  import { markWorkBuddyInstallation, readInstallationOwner } from "../src/platform/installation-owner.js";
8
+ import { pinWorkBuddyRuntime } from "../src/platform/workbuddy-runtime.js";
8
9
  export function isSupportedGlobalLifecycle(env) {
9
10
  const userAgent = env.npm_config_user_agent ?? "";
10
11
  if (env.npm_config_global === "true") {
@@ -45,6 +46,7 @@ export async function runPostinstall(options = {}) {
45
46
  const packageRoot = dirname(dirname(primarySkill.sourceDirectory));
46
47
  if (env.GD_CLI_INSTALL_OWNER === "workbuddy") {
47
48
  markWorkBuddyInstallation(packageRoot);
49
+ pinWorkBuddyRuntime(packageRoot);
48
50
  return;
49
51
  }
50
52
  const owner = readInstallationOwner(packageRoot);
@@ -18,7 +18,8 @@ export function createWindAnalytics(options) {
18
18
  userAgent: `${insmind ? "insmind-cli" : "gd-cli"}/${options.version}`,
19
19
  adapters: createNodeAdapters({ fetch: options.fetch, deliveryBudgetMs: 1_500 }) });
20
20
  tracker.set("common", { user_id: identity.userId, is_login: 1,
21
- organization: { org_id: identity.organizationId },
21
+ organization: { org_id: identity.organizationId,
22
+ ...(!insmind ? { uc_id: identity.userId } : {}) },
22
23
  channel_id: options.environment === "prod" ? (insmind ? "781" : "32") : (insmind ? "316" : "31") });
23
24
  trackers.add(tracker);
24
25
  return {
@@ -0,0 +1,57 @@
1
+ import { readlinkSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
2
+ import { join, relative, resolve } from "node:path";
3
+ /** Pin only this managed CLI, not the host's shared `node` or other connectors. */
4
+ export function pinWorkBuddyRuntime(packageRoot) {
5
+ const windows = process.platform === "win32";
6
+ const prefix = resolve(packageRoot, windows ? "../../.." : "../../../..");
7
+ const expectedRoot = join(prefix, ...(windows ? [] : ["lib"]), "node_modules", "@gaoding", "cli");
8
+ if (resolve(packageRoot) !== expectedRoot) {
9
+ throw new Error("无法确认 WorkBuddy CLI 的 npm 安装目录。");
10
+ }
11
+ const binDirectory = windows ? prefix : join(prefix, "bin");
12
+ const bin = join(binDirectory, "gd-cli");
13
+ const entry = join(packageRoot, "dist", "bin", "gd-cli.js");
14
+ const node = process.execPath;
15
+ if (!windows) {
16
+ const launcher = join(packageRoot, "dist", "bin", "workbuddy-gd-cli.sh");
17
+ const target = resolve(binDirectory, readlinkSync(bin));
18
+ if (target !== entry && target !== launcher) {
19
+ throw new Error("WorkBuddy gd-cli 启动入口不属于当前安装。");
20
+ }
21
+ writeFileSync(launcher, `#!/bin/sh\nexec ${shellQuote(node)} ${shellQuote(entry)} "$@"\n`, { mode: 0o755 });
22
+ // Keep an in-package symlink so npm can recognize, update and uninstall its bin.
23
+ unlinkSync(bin);
24
+ symlinkSync(relative(binDirectory, launcher), bin);
25
+ return;
26
+ }
27
+ const target = "node_modules/@gaoding/cli/dist/bin/gd-cli.js";
28
+ // Preserve npm's recognizable target syntax for upgrades/uninstalls on Windows.
29
+ writeFileSync(`${bin}.cmd`, [
30
+ "@ECHO OFF",
31
+ "SETLOCAL DISABLEDELAYEDEXPANSION",
32
+ `"${node.replace(/%/gu, "%%")}" "%~dp0\\${target.replace(/\//gu, "\\")}" %*`,
33
+ "EXIT /b %ERRORLEVEL%",
34
+ ""
35
+ ].join("\r\n"));
36
+ const powershellNode = `'${node.replace(/'/gu, "''")}'`;
37
+ writeFileSync(`${bin}.ps1`, [
38
+ "\uFEFF#!/usr/bin/env pwsh",
39
+ "$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent",
40
+ "if ($MyInvocation.ExpectingInput) {",
41
+ ` $input | & ${powershellNode} "$basedir/${target}" $args`,
42
+ "} else {",
43
+ ` & ${powershellNode} "$basedir/${target}" $args`,
44
+ "}",
45
+ "exit $LASTEXITCODE",
46
+ ""
47
+ ].join("\n"));
48
+ writeFileSync(bin, [
49
+ "#!/bin/sh",
50
+ 'basedir=$(dirname "$(echo "$0" | sed -e \'s,\\\\,/,g\')")',
51
+ `exec ${shellQuote(node.replace(/\\/gu, "/"))} "$basedir/${target}" "$@"`,
52
+ ""
53
+ ].join("\n"), { mode: 0o755 });
54
+ }
55
+ function shellQuote(value) {
56
+ return `'${value.replace(/'/gu, "'\\''")}'`;
57
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insmind/cli",
3
- "version": "1.5.4",
3
+ "version": "1.5.6",
4
4
  "description": "insMind command-line interface for agents and people.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,8 +46,8 @@
46
46
  "@gaoding/cli": "workspace:*"
47
47
  },
48
48
  "gaodingRelease": {
49
- "sourceCommit": "82935101ad55c67cdae952372fb7ae49d10a3baa",
50
- "pipelineId": "198408",
51
- "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/198408"
49
+ "sourceCommit": "696aa5ec28432a2af987f70b7250ed546aef0252",
50
+ "pipelineId": "199209",
51
+ "pipelineUrl": "https://git.intra.gaoding.com/gtt/gaoding-cli/-/pipelines/199209"
52
52
  }
53
53
  }