@legna-lnc/legnacode 1.1.9 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  All notable changes to LegnaCode CLI will be documented in this file.
4
4
 
5
+ ## [1.2.0] - 2026-04-03
6
+
7
+ ### New Features
8
+
9
+ - **会话按项目分组** — WebUI 会话记录面板按项目路径分组显示
10
+ - **resume 命令带 cd** — 复制的 resume 命令自动包含 `cd` 到项目目录(Windows 用 `cd /d`)
11
+ - **迁移支持会话记录** — 配置迁移面板新增"同时迁移会话记录"选项,复制 `projects/` 目录
12
+ - **Windows 原生编译** — Windows 二进制改为在 Windows 上原生编译
13
+
14
+ ### Fixed
15
+
16
+ - 迁移面板字段名修正为实际 settings.json 字段
17
+
18
+ ## [1.1.10] - 2026-04-03
19
+
20
+ ### Fixed
21
+
22
+ - **Windows 编译脚本修复** — `scripts/compile.ts` 在 Windows 上正确处理 `.exe` 后缀,修复编译后找不到输出文件的问题
23
+ - **Windows 原生二进制重新编译发布** — 使用 Windows 本机 Bun 编译原生 `legna.exe`,替代之前交叉编译的版本
24
+
25
+ ## [1.1.9] - 2026-04-03
26
+
27
+ ### Fixed
28
+
29
+ - **postinstall 自动安装平台包** — 新增 `npm/postinstall.cjs`,`npm install` 阶段自动检测并从官方 registry 安装对应平台二进制包,彻底解决 Windows/镜像源下 optionalDependencies 不生效的问题
30
+ - **强制官方 registry** — postinstall 使用 `--registry https://registry.npmjs.org` 避免淘宝镜像等未同步导致 404
31
+ - **bin wrapper 精简** — 移除运行时 auto-install 逻辑,改由 postinstall 保证
32
+
5
33
  ## [1.1.8] - 2026-04-03
6
34
 
7
35
  ### Fixed
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # LegnaCode CLI
2
2
  <img width="1256" height="416" alt="image" src="https://github.com/user-attachments/assets/5e4717e6-3404-4901-9f5c-1c6462fb1c1a" />
3
+ <img width="1072" height="874" alt="image" src="https://github.com/user-attachments/assets/819c39e8-9db6-4d8d-b911-13600c525422" />
4
+
3
5
  LegnaCode 是一个基于 Anthropic Claude 的智能终端编程助手,让你直接在命令行中与 AI 协作完成软件工程任务——编辑文件、执行命令、搜索代码、管理 Git 工作流等。
4
6
 
5
7
  ---
@@ -10,6 +12,8 @@ LegnaCode 是一个基于 Anthropic Claude 的智能终端编程助手,让你
10
12
 
11
13
  | 版本 | 日期 | 摘要 |
12
14
  |------|------|------|
15
+ | [1.2.0](./CHANGELOG.md#120---2026-04-03) | 2026-04-03 | 会话按项目分组、resume 带 cd、迁移支持会话记录、Windows 原生编译 |
16
+ | [1.1.9](./CHANGELOG.md#119---2026-04-03) | 2026-04-03 | postinstall 自动安装平台包,修复 Windows/镜像源 optionalDependencies 失效 |
13
17
  | [1.1.8](./CHANGELOG.md#118---2026-04-03) | 2026-04-03 | bin wrapper 自动安装缺失平台包,修复 Windows npm 全局安装问题 |
14
18
  | [1.1.7](./CHANGELOG.md#117---2026-04-03) | 2026-04-03 | 彻底修复 Windows external module 报错,清空 external 列表 |
15
19
  | [1.1.6](./CHANGELOG.md#116---2026-04-03) | 2026-04-03 | 修复 Windows external module 报错、全平台发版流程自动化、版本号统一 |
package/npm/bin/legna.cjs CHANGED
@@ -18,43 +18,82 @@ var key = process.platform + "-" + os.arch();
18
18
  var pkg = PLATFORMS[key];
19
19
 
20
20
  if (!pkg) {
21
- console.error(
22
- "legna: unsupported platform " + key + "\n" +
23
- "Supported: " + Object.keys(PLATFORMS).join(", ")
24
- );
21
+ console.error("legna: unsupported platform " + key);
25
22
  process.exit(1);
26
23
  }
27
24
 
28
25
  var binName = process.platform === "win32" ? "legna.exe" : "bin/legna";
29
26
 
30
27
  function findBin() {
28
+ var candidates = [];
29
+
31
30
  // Strategy 1: require.resolve
32
31
  try {
33
32
  var p = path.resolve(require.resolve(pkg + "/package.json"), "..", binName);
33
+ candidates.push(p);
34
34
  if (fs.existsSync(p)) return p;
35
35
  } catch (e) {}
36
36
 
37
37
  // Strategy 2: sibling scope dir (global flat layout)
38
+ // __dirname = .../node_modules/@legna-lnc/legnacode/npm/bin
39
+ // go up to @legna-lnc scope dir, then into sibling package
38
40
  var scopeDir = path.resolve(__dirname, "..", "..", "..");
39
41
  var pkgName = pkg.split("/")[1];
40
42
  var flat = path.resolve(scopeDir, pkgName, binName);
43
+ candidates.push(flat);
41
44
  if (fs.existsSync(flat)) return flat;
42
45
 
43
- // Strategy 3: nested node_modules inside our package (postinstall puts it here)
46
+ // Strategy 3: nested node_modules (postinstall --no-save)
44
47
  var nested = path.resolve(__dirname, "..", "..", "node_modules", pkg, binName);
48
+ candidates.push(nested);
45
49
  if (fs.existsSync(nested)) return nested;
46
50
 
51
+ // Strategy 4: global prefix
52
+ try {
53
+ var prefix = childProcess.execSync("npm prefix -g", { encoding: "utf-8" }).trim();
54
+ var globalPaths = [
55
+ path.join(prefix, "node_modules", pkg, binName),
56
+ path.join(prefix, "lib", "node_modules", pkg, binName),
57
+ ];
58
+ for (var gp of globalPaths) {
59
+ candidates.push(gp);
60
+ if (fs.existsSync(gp)) return gp;
61
+ }
62
+ } catch (e) {}
63
+
64
+ // Debug: print all searched paths
65
+ if (process.env.LEGNA_DEBUG) {
66
+ console.error("legna: searched paths:");
67
+ candidates.forEach(function(c) {
68
+ console.error(" " + (fs.existsSync(c) ? "[OK]" : "[ ]") + " " + c);
69
+ });
70
+ }
71
+
47
72
  return null;
48
73
  }
49
74
 
50
75
  var bin = findBin();
51
76
 
52
77
  if (!bin) {
53
- console.error(
54
- "legna: platform binary not found.\n" +
55
- "Run: npm install -g " + pkg + " --registry https://registry.npmjs.org"
78
+ // Last resort: try to install from official registry
79
+ var version;
80
+ try {
81
+ version = JSON.parse(fs.readFileSync(path.resolve(__dirname, "..", "..", "package.json"), "utf-8")).version;
82
+ } catch (e) { version = "latest"; }
83
+
84
+ console.error("legna: installing platform binary " + pkg + "@" + version + "...");
85
+ var install = childProcess.spawnSync(
86
+ "npm", ["install", "-g", pkg + "@" + version, "--registry", "https://registry.npmjs.org"],
87
+ { stdio: "inherit", shell: true }
56
88
  );
57
- process.exit(1);
89
+ if (install.status === 0) bin = findBin();
90
+
91
+ if (!bin) {
92
+ console.error("legna: platform binary not found after install attempt.");
93
+ console.error("Try: npm install -g " + pkg + " --registry https://registry.npmjs.org");
94
+ console.error("Debug: set LEGNA_DEBUG=1 and run again to see searched paths.");
95
+ process.exit(1);
96
+ }
58
97
  }
59
98
 
60
99
  var result = childProcess.spawnSync(bin, process.argv.slice(2), {
@@ -70,7 +109,7 @@ if (result.error) {
70
109
  env: process.env,
71
110
  });
72
111
  } else {
73
- console.error("legna: " + result.error.message);
112
+ console.error("legna: spawn error: " + result.error.message);
74
113
  process.exit(1);
75
114
  }
76
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legna-lnc/legnacode",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "LegnaCode — legna.lnc's official CLI for coding assistance",
5
5
  "type": "module",
6
6
  "bin": {
@@ -142,10 +142,10 @@
142
142
  "bun": ">=1.2.0"
143
143
  },
144
144
  "optionalDependencies": {
145
- "@legna-lnc/legnacode-darwin-arm64": "1.1.9",
146
- "@legna-lnc/legnacode-darwin-x64": "1.1.9",
147
- "@legna-lnc/legnacode-linux-x64": "1.1.9",
148
- "@legna-lnc/legnacode-linux-arm64": "1.1.9",
149
- "@legna-lnc/legnacode-win32-x64": "1.1.9"
145
+ "@legna-lnc/legnacode-darwin-arm64": "1.2.0",
146
+ "@legna-lnc/legnacode-darwin-x64": "1.2.0",
147
+ "@legna-lnc/legnacode-linux-x64": "1.2.0",
148
+ "@legna-lnc/legnacode-linux-arm64": "1.2.0",
149
+ "@legna-lnc/legnacode-win32-x64": "1.2.0"
150
150
  }
151
151
  }