@lark-codem/codem-core 0.7.61

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/LICENSE ADDED
@@ -0,0 +1,6 @@
1
+ © Lark Technologies Pte. Ltd. All rights reserved. Use is subject to the Legal Agreements outlined here:
2
+
3
+ Feishu User Terms of Service [https://www.feishu.cn/terms]
4
+ Feishu Privacy Policy [https://www.feishu.cn/privacy]
5
+
6
+ Copyright (c) 2026 Lark Technologies Pte. Ltd.
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+
3
+ const fs = require("node:fs");
4
+
5
+ function normalizeArch(arch) {
6
+ switch (arch) {
7
+ case "x64":
8
+ case "arm64":
9
+ return arch;
10
+ case "ia32":
11
+ return "ia32";
12
+ default:
13
+ throw new Error(`Unsupported architecture: ${arch}`);
14
+ }
15
+ }
16
+
17
+ function detectLinuxLibc() {
18
+ if (process.report && typeof process.report.getReport === "function") {
19
+ try {
20
+ const report = process.report.getReport();
21
+ if (report && report.header && report.header.glibcVersionRuntime) {
22
+ return "gnu";
23
+ }
24
+ } catch {
25
+ // fall through to fs probes
26
+ }
27
+ }
28
+
29
+ const muslProbes = [
30
+ "/lib/ld-musl-x86_64.so.1",
31
+ "/lib/ld-musl-aarch64.so.1",
32
+ "/lib/ld-musl-i386.so.1",
33
+ ];
34
+ for (const probe of muslProbes) {
35
+ if (fs.existsSync(probe)) {
36
+ return "musl";
37
+ }
38
+ }
39
+
40
+ return "gnu";
41
+ }
42
+
43
+ function detectTarget(host = process, env = process.env) {
44
+ if (env && typeof env.LINCO_NPM_TARGET === "string" && env.LINCO_NPM_TARGET.trim()) {
45
+ return env.LINCO_NPM_TARGET.trim();
46
+ }
47
+
48
+ const platform = host.platform;
49
+ const arch = normalizeArch(host.arch);
50
+
51
+ if (platform === "darwin") {
52
+ return `darwin-${arch}`;
53
+ }
54
+ if (platform === "linux") {
55
+ const libc = host.libc || detectLinuxLibc();
56
+ return `linux-${arch}-${libc}`;
57
+ }
58
+ if (platform === "win32") {
59
+ return `win32-${arch}-msvc`;
60
+ }
61
+
62
+ throw new Error(`Unsupported platform: ${platform}`);
63
+ }
64
+
65
+ module.exports = { detectTarget, normalizeArch, detectLinuxLibc };
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ // Windows release binaries are currently cross-compiled from macOS via
4
+ // cargo-zigbuild, which can only produce *-pc-windows-gnu artifacts. The
5
+ // canonical npm target on Windows stays win32-<arch>-msvc (preferred when a
6
+ // Windows-host MSVC build is published); when that platform package is
7
+ // absent we fall back to the sibling win32-<arch>-gnu package.
8
+ const TARGET_FALLBACKS = {
9
+ "win32-x64-msvc": ["win32-x64-gnu"],
10
+ "win32-arm64-msvc": ["win32-arm64-gnu"],
11
+ "win32-ia32-msvc": ["win32-ia32-gnu"],
12
+ };
13
+
14
+ function packageNameForTarget(target) {
15
+ return `@lark-codem/codem-core-${target}`;
16
+ }
17
+
18
+ function binaryNameForTarget(target) {
19
+ return target.startsWith("win32-") ? "codem-core.exe" : "codem-core";
20
+ }
21
+
22
+ function resolvePlatformBinary(target, options = {}) {
23
+ const req = options.require || require;
24
+ const paths = options.paths;
25
+ const candidates = [target, ...(TARGET_FALLBACKS[target] || [])];
26
+
27
+ let lastNotFound;
28
+ for (const candidate of candidates) {
29
+ const request = `${packageNameForTarget(candidate)}/${binaryNameForTarget(candidate)}`;
30
+ try {
31
+ if (paths) {
32
+ return req.resolve(request, { paths });
33
+ }
34
+ return req.resolve(request);
35
+ } catch (error) {
36
+ if (error && error.code === "MODULE_NOT_FOUND") {
37
+ lastNotFound = error;
38
+ continue;
39
+ }
40
+ throw error;
41
+ }
42
+ }
43
+
44
+ const packageName = packageNameForTarget(target);
45
+ const helpLines = [
46
+ `linco: platform package ${packageName} is not installed.`,
47
+ ];
48
+ if (candidates.length > 1) {
49
+ const fallbacks = candidates.slice(1).map(packageNameForTarget).join(", ");
50
+ helpLines.push(`Also tried fallback package(s): ${fallbacks}.`);
51
+ }
52
+ helpLines.push(
53
+ "This usually means optionalDependencies were skipped during install.",
54
+ "Try one of:",
55
+ " - reinstall with optional deps: npm install --include=optional @lark-codem/codem-core",
56
+ ` - override target: LINCO_NPM_TARGET=<other-target> (current: ${target})`
57
+ );
58
+ const wrapped = new Error(helpLines.join("\n"));
59
+ wrapped.code = "LINCO_PLATFORM_PACKAGE_MISSING";
60
+ wrapped.cause = lastNotFound;
61
+ throw wrapped;
62
+ }
63
+
64
+ module.exports = { resolvePlatformBinary };
package/bin/linco ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("node:child_process");
5
+ const fs = require("node:fs");
6
+ const { detectTarget } = require("./lib/detect-target");
7
+ const { resolvePlatformBinary } = require("./lib/resolve-binary");
8
+
9
+ function main() {
10
+ let target;
11
+ try {
12
+ target = detectTarget();
13
+ } catch (error) {
14
+ console.error(`linco: ${error.message}`);
15
+ console.error("Hint: set LINCO_NPM_TARGET to override platform detection.");
16
+ process.exit(1);
17
+ }
18
+
19
+ let binary;
20
+ try {
21
+ binary = resolvePlatformBinary(target);
22
+ } catch (error) {
23
+ console.error(error.message);
24
+ process.exit(1);
25
+ }
26
+
27
+ try {
28
+ fs.chmodSync(binary, 0o755);
29
+ } catch {
30
+ // best-effort
31
+ }
32
+
33
+ const child = spawn(binary, process.argv.slice(2), {
34
+ stdio: "inherit",
35
+ windowsHide: true,
36
+ });
37
+
38
+ child.on("error", (error) => {
39
+ console.error(`linco: failed to spawn ${binary}: ${error.message}`);
40
+ process.exit(1);
41
+ });
42
+
43
+ const forwardSignal = (signal) => {
44
+ try {
45
+ child.kill(signal);
46
+ } catch {
47
+ // child may already be exiting
48
+ }
49
+ };
50
+ const signalHandlers = {
51
+ SIGINT: () => forwardSignal("SIGINT"),
52
+ SIGTERM: () => forwardSignal("SIGTERM"),
53
+ SIGHUP: () => forwardSignal("SIGHUP"),
54
+ };
55
+ for (const [name, handler] of Object.entries(signalHandlers)) {
56
+ process.on(name, handler);
57
+ }
58
+
59
+ child.on("exit", (code, signal) => {
60
+ if (signal) {
61
+ for (const [name, handler] of Object.entries(signalHandlers)) {
62
+ process.off(name, handler);
63
+ }
64
+ process.kill(process.pid, signal);
65
+ return;
66
+ }
67
+ process.exit(code ?? 0);
68
+ });
69
+ }
70
+
71
+ main();
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@lark-codem/codem-core",
3
+ "version": "0.7.61",
4
+ "description": "CodeM CLI.",
5
+ "license": "SEE LICENSE IN LICENSE",
6
+ "bin": {
7
+ "linco": "bin/linco"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "LICENSE"
12
+ ],
13
+ "optionalDependencies": {
14
+ "@lark-codem/codem-core-darwin-arm64": "0.7.61",
15
+ "@lark-codem/codem-core-darwin-x64": "0.7.61",
16
+ "@lark-codem/codem-core-linux-arm64-gnu": "0.7.61",
17
+ "@lark-codem/codem-core-linux-arm64-musl": "0.7.61",
18
+ "@lark-codem/codem-core-linux-x64-gnu": "0.7.61",
19
+ "@lark-codem/codem-core-linux-x64-musl": "0.7.61",
20
+ "@lark-codem/codem-core-win32-arm64-gnu": "0.7.61",
21
+ "@lark-codem/codem-core-win32-arm64-msvc": "0.7.61",
22
+ "@lark-codem/codem-core-win32-ia32-gnu": "0.7.61",
23
+ "@lark-codem/codem-core-win32-ia32-msvc": "0.7.61",
24
+ "@lark-codem/codem-core-win32-x64-gnu": "0.7.61",
25
+ "@lark-codem/codem-core-win32-x64-msvc": "0.7.61"
26
+ },
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "publishConfig": {
31
+ "registry": "https://registry.npmjs.org",
32
+ "access": "public"
33
+ }
34
+ }