@glyphlang/glyph 0.1.100 → 0.1.102
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/README.md +1 -1
- package/bin/resolve.js +66 -4
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/chadetov/glyph/actions/workflows/ci.yml)
|
|
8
8
|
[](https://packagephobia.com/result?p=@glyphlang/glyph)
|
|
9
9
|
[](https://github.com/chadetov/glyph)
|
|
10
|
-
[](https://badge.socket.dev/npm/package/@glyphlang/glyph/0.1.102)
|
|
11
11
|
[](https://scorecard.dev/viewer/?uri=github.com/chadetov/glyph)
|
|
12
12
|
|
|
13
13
|
Glyph is a statically typed language that **transpiles to TypeScript**, built so AI agents can read, write, and modify code safely. It looks almost like TypeScript, so you read it on day one with no tutorial. Where it differs, each difference closes a hole an agent falls through and `tsc --strict` waves past.
|
package/bin/resolve.js
CHANGED
|
@@ -23,20 +23,68 @@ function binaryName(platform) {
|
|
|
23
23
|
return platform === "win32" ? "glyph.exe" : "glyph";
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Detect musl libc (Alpine and similar) on the current Linux process.
|
|
28
|
+
*
|
|
29
|
+
* The published `linux-*` packages are glibc builds; there is no `linux-x64-musl`
|
|
30
|
+
* target. `process.platform` alone cannot tell glibc and musl Linux apart, both
|
|
31
|
+
* report `"linux"`, so without this check the launcher hands a musl machine a
|
|
32
|
+
* binary it cannot execute: Alpine ships no glibc dynamic loader, `execve` fails,
|
|
33
|
+
* and the spawn error surfaces as a bare `ENOENT` that reads like "binary not
|
|
34
|
+
* found" rather than "wrong libc".
|
|
35
|
+
*
|
|
36
|
+
* The signal is `process.report`'s `header.glibcVersionRuntime`: Node embeds it
|
|
37
|
+
* on glibc builds and omits it on musl builds, confirmed on both Node majors this
|
|
38
|
+
* package supports (18 and 20). `report` is injectable so this is testable with
|
|
39
|
+
* a synthetic report object instead of a real Alpine container. Any failure to
|
|
40
|
+
* read the signal (no report support, a throwing report) is treated as "not
|
|
41
|
+
* musl" rather than raised as musl, a wrong glibc diagnosis on a real glibc
|
|
42
|
+
* machine would be strictly worse than the ENOENT it replaces.
|
|
43
|
+
*/
|
|
44
|
+
function isMusl({
|
|
45
|
+
platform = process.platform,
|
|
46
|
+
report = () => process.report && process.report.getReport(),
|
|
47
|
+
} = {}) {
|
|
48
|
+
// The glibc signal is Linux-only, so its absence means nothing anywhere else.
|
|
49
|
+
// Without this line the function answers `true` on macOS and Windows, where
|
|
50
|
+
// `glibcVersionRuntime` is simply not a field that exists, and the only thing
|
|
51
|
+
// standing between that and a bogus "this looks like musl" on every Mac is
|
|
52
|
+
// the caller remembering to check the platform first. Answering the question
|
|
53
|
+
// correctly for any input is worth more than trusting the next caller.
|
|
54
|
+
if (platform !== "linux") {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
let rep;
|
|
58
|
+
try {
|
|
59
|
+
rep = report();
|
|
60
|
+
} catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
// No report or no header at all means the signal could not be read (older
|
|
64
|
+
// Node, report disabled, an environment this was never taught about) --
|
|
65
|
+
// stay silent rather than guess musl from the absence of information.
|
|
66
|
+
if (!rep || !rep.header) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return !rep.header.glibcVersionRuntime;
|
|
70
|
+
}
|
|
71
|
+
|
|
26
72
|
/**
|
|
27
73
|
* Resolve the absolute path of the glyph binary for the current platform.
|
|
28
74
|
*
|
|
29
75
|
* `GLYPH_BINARY` overrides everything (development and CI smoke tests). Options
|
|
30
76
|
* are injectable so the resolution logic is testable: `resolve` defaults to
|
|
31
|
-
* `require.resolve`, `platform`/`arch` to `process.*`, `env` to `process.env
|
|
32
|
-
* Throws a descriptive error when
|
|
33
|
-
*
|
|
77
|
+
* `require.resolve`, `platform`/`arch` to `process.*`, `env` to `process.env`,
|
|
78
|
+
* `report` to `process.report` (see `isMusl`). Throws a descriptive error when
|
|
79
|
+
* the platform is unsupported, the platform is musl Linux (no prebuilt binary
|
|
80
|
+
* for it), or the matching optional dependency was not installed.
|
|
34
81
|
*/
|
|
35
82
|
function resolveBinary({
|
|
36
83
|
platform = process.platform,
|
|
37
84
|
arch = process.arch,
|
|
38
85
|
resolve = require.resolve,
|
|
39
86
|
env = process.env,
|
|
87
|
+
report,
|
|
40
88
|
} = {}) {
|
|
41
89
|
if (env.GLYPH_BINARY) {
|
|
42
90
|
return env.GLYPH_BINARY;
|
|
@@ -49,6 +97,20 @@ function resolveBinary({
|
|
|
49
97
|
`Build from source: https://github.com/chadetov/glyph.`
|
|
50
98
|
);
|
|
51
99
|
}
|
|
100
|
+
// Every "linux-*" package is a glibc build. Diagnose musl (Alpine) here, before
|
|
101
|
+
// the resolve attempt below, rather than letting it fail as an opaque spawn
|
|
102
|
+
// ENOENT once the caller tries to run the binary this returns.
|
|
103
|
+
// `platform` is forwarded rather than letting `isMusl` read
|
|
104
|
+
// `process.platform` for itself: two independent reads of the same fact can
|
|
105
|
+
// disagree, and when they do the caller's guard silently stops matching the
|
|
106
|
+
// condition the callee tested.
|
|
107
|
+
if (isMusl({ platform, report })) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`glyph: this looks like musl libc (Alpine or similar), and ${pkg} is a glibc build ` +
|
|
110
|
+
`that will not run here. There is no prebuilt musl binary yet. ` +
|
|
111
|
+
`Build from source: https://github.com/chadetov/glyph.`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
52
114
|
try {
|
|
53
115
|
return resolve(`${pkg}/bin/${binaryName(platform)}`);
|
|
54
116
|
} catch {
|
|
@@ -60,4 +122,4 @@ function resolveBinary({
|
|
|
60
122
|
}
|
|
61
123
|
}
|
|
62
124
|
|
|
63
|
-
module.exports = { PLATFORM_PACKAGES, packageForPlatform, binaryName, resolveBinary };
|
|
125
|
+
module.exports = { PLATFORM_PACKAGES, packageForPlatform, binaryName, isMusl, resolveBinary };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glyphlang/glyph",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.102",
|
|
4
4
|
"description": "TypeScript your AI agents can't quietly break: a statically typed language that transpiles to TypeScript, with no any, exhaustive matching, and runtime-checked types.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"glyph": "bin/glyph.js"
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"node": ">=18"
|
|
16
16
|
},
|
|
17
17
|
"optionalDependencies": {
|
|
18
|
-
"@glyphlang/darwin-x64": "0.1.
|
|
19
|
-
"@glyphlang/darwin-arm64": "0.1.
|
|
20
|
-
"@glyphlang/linux-x64": "0.1.
|
|
21
|
-
"@glyphlang/linux-arm64": "0.1.
|
|
22
|
-
"@glyphlang/win32-x64": "0.1.
|
|
18
|
+
"@glyphlang/darwin-x64": "0.1.102",
|
|
19
|
+
"@glyphlang/darwin-arm64": "0.1.102",
|
|
20
|
+
"@glyphlang/linux-x64": "0.1.102",
|
|
21
|
+
"@glyphlang/linux-arm64": "0.1.102",
|
|
22
|
+
"@glyphlang/win32-x64": "0.1.102"
|
|
23
23
|
},
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|