@driftsys/markspec 0.6.0 → 0.6.2

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.
Files changed (109) hide show
  1. package/esm/lint/mod.d.ts +2 -0
  2. package/esm/lint/mod.d.ts.map +1 -1
  3. package/esm/lint/mod.js +1 -0
  4. package/esm/lint/rules/xref.d.ts +32 -5
  5. package/esm/lint/rules/xref.d.ts.map +1 -1
  6. package/esm/lint/rules/xref.js +40 -0
  7. package/esm/lint/runner.d.ts.map +1 -1
  8. package/esm/lint/runner.js +6 -2
  9. package/esm/lint/score_text.d.ts +67 -0
  10. package/esm/lint/score_text.d.ts.map +1 -0
  11. package/esm/lint/score_text.js +74 -0
  12. package/esm/lock/compare.d.ts +34 -0
  13. package/esm/lock/compare.d.ts.map +1 -0
  14. package/esm/lock/compare.js +64 -0
  15. package/esm/lock/mod.d.ts +2 -1
  16. package/esm/lock/mod.d.ts.map +1 -1
  17. package/esm/lock/mod.js +1 -0
  18. package/esm/lock/model.d.ts +13 -0
  19. package/esm/lock/model.d.ts.map +1 -1
  20. package/esm/lock/parser.d.ts +3 -0
  21. package/esm/lock/parser.d.ts.map +1 -1
  22. package/esm/lock/parser.js +37 -1
  23. package/esm/lock/serializer.d.ts.map +1 -1
  24. package/esm/lock/serializer.js +4 -0
  25. package/esm/mod.d.ts +7 -3
  26. package/esm/mod.d.ts.map +1 -1
  27. package/esm/mod.js +6 -2
  28. package/esm/parser/grammars.d.ts.map +1 -1
  29. package/esm/parser/grammars.js +8 -2
  30. package/esm/parser/markdown.js +11 -21
  31. package/esm/profile/display_id.d.ts +60 -0
  32. package/esm/profile/display_id.d.ts.map +1 -0
  33. package/esm/profile/display_id.js +80 -0
  34. package/esm/profile/mod.d.ts +3 -0
  35. package/esm/profile/mod.d.ts.map +1 -1
  36. package/esm/profile/mod.js +2 -0
  37. package/esm/profile/trace_targets.d.ts +43 -0
  38. package/esm/profile/trace_targets.d.ts.map +1 -0
  39. package/esm/profile/trace_targets.js +74 -0
  40. package/esm/self_upgrade/compare.d.ts +19 -0
  41. package/esm/self_upgrade/compare.d.ts.map +1 -0
  42. package/esm/self_upgrade/compare.js +35 -0
  43. package/esm/self_upgrade/manifest.d.ts +21 -0
  44. package/esm/self_upgrade/manifest.d.ts.map +1 -0
  45. package/esm/self_upgrade/manifest.js +27 -0
  46. package/esm/self_upgrade/mod.d.ts +12 -0
  47. package/esm/self_upgrade/mod.d.ts.map +1 -0
  48. package/esm/self_upgrade/mod.js +11 -0
  49. package/esm/self_upgrade/pm_detect.d.ts +27 -0
  50. package/esm/self_upgrade/pm_detect.d.ts.map +1 -0
  51. package/esm/self_upgrade/pm_detect.js +55 -0
  52. package/esm/self_upgrade/target.d.ts +25 -0
  53. package/esm/self_upgrade/target.d.ts.map +1 -0
  54. package/esm/self_upgrade/target.js +34 -0
  55. package/package.json +1 -1
  56. package/script/lint/mod.d.ts +2 -0
  57. package/script/lint/mod.d.ts.map +1 -1
  58. package/script/lint/mod.js +3 -1
  59. package/script/lint/rules/xref.d.ts +32 -5
  60. package/script/lint/rules/xref.d.ts.map +1 -1
  61. package/script/lint/rules/xref.js +42 -0
  62. package/script/lint/runner.d.ts.map +1 -1
  63. package/script/lint/runner.js +5 -1
  64. package/script/lint/score_text.d.ts +67 -0
  65. package/script/lint/score_text.d.ts.map +1 -0
  66. package/script/lint/score_text.js +77 -0
  67. package/script/lock/compare.d.ts +34 -0
  68. package/script/lock/compare.d.ts.map +1 -0
  69. package/script/lock/compare.js +67 -0
  70. package/script/lock/mod.d.ts +2 -1
  71. package/script/lock/mod.d.ts.map +1 -1
  72. package/script/lock/mod.js +3 -1
  73. package/script/lock/model.d.ts +13 -0
  74. package/script/lock/model.d.ts.map +1 -1
  75. package/script/lock/parser.d.ts +3 -0
  76. package/script/lock/parser.d.ts.map +1 -1
  77. package/script/lock/parser.js +37 -1
  78. package/script/lock/serializer.d.ts.map +1 -1
  79. package/script/lock/serializer.js +4 -0
  80. package/script/mod.d.ts +7 -3
  81. package/script/mod.d.ts.map +1 -1
  82. package/script/mod.js +82 -63
  83. package/script/parser/grammars.d.ts.map +1 -1
  84. package/script/parser/grammars.js +8 -2
  85. package/script/parser/markdown.js +11 -21
  86. package/script/profile/display_id.d.ts +60 -0
  87. package/script/profile/display_id.d.ts.map +1 -0
  88. package/script/profile/display_id.js +86 -0
  89. package/script/profile/mod.d.ts +3 -0
  90. package/script/profile/mod.d.ts.map +1 -1
  91. package/script/profile/mod.js +10 -1
  92. package/script/profile/trace_targets.d.ts +43 -0
  93. package/script/profile/trace_targets.d.ts.map +1 -0
  94. package/script/profile/trace_targets.js +79 -0
  95. package/script/self_upgrade/compare.d.ts +19 -0
  96. package/script/self_upgrade/compare.d.ts.map +1 -0
  97. package/script/self_upgrade/compare.js +38 -0
  98. package/script/self_upgrade/manifest.d.ts +21 -0
  99. package/script/self_upgrade/manifest.d.ts.map +1 -0
  100. package/script/self_upgrade/manifest.js +31 -0
  101. package/script/self_upgrade/mod.d.ts +12 -0
  102. package/script/self_upgrade/mod.d.ts.map +1 -0
  103. package/script/self_upgrade/mod.js +20 -0
  104. package/script/self_upgrade/pm_detect.d.ts +27 -0
  105. package/script/self_upgrade/pm_detect.d.ts.map +1 -0
  106. package/script/self_upgrade/pm_detect.js +58 -0
  107. package/script/self_upgrade/target.d.ts +25 -0
  108. package/script/self_upgrade/target.d.ts.map +1 -0
  109. package/script/self_upgrade/target.js +38 -0
@@ -6,7 +6,7 @@
6
6
  * resolution, and merging. Consumed by the validator pipeline and the CLI.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.buildProfileIntrospection = exports.resolveDisciplineMode = exports.inferDisciplineMode = exports.buildEffectiveDisciplineRegistry = exports.resolveEntryColor = exports.mergeChain = exports.loadProfileForCommand = exports.loadChain = exports.ensureCacheGitignored = exports.defaultRunGit = exports.defaultAppendFile = exports.computeCacheLocation = exports.computeCacheKey = exports.resolveLocalSpecifier = exports.resolveGitSpecifier = exports.parseManifest = void 0;
9
+ exports.buildProfileIntrospection = exports.targetsForRelation = exports.filterEntriesByTraceTargets = exports.entryMatchesTargets = exports.parseDisplayIdPattern = exports.padDisplayIdNumber = exports.highestDisplayIdNumber = exports.formatDisplayId = exports.resolveDisciplineMode = exports.inferDisciplineMode = exports.buildEffectiveDisciplineRegistry = exports.resolveEntryColor = exports.mergeChain = exports.loadProfileForCommand = exports.loadChain = exports.ensureCacheGitignored = exports.defaultRunGit = exports.defaultAppendFile = exports.computeCacheLocation = exports.computeCacheKey = exports.resolveLocalSpecifier = exports.resolveGitSpecifier = exports.parseManifest = void 0;
10
10
  var manifest_js_1 = require("./manifest.js");
11
11
  Object.defineProperty(exports, "parseManifest", { enumerable: true, get: function () { return manifest_js_1.parseManifest; } });
12
12
  var resolver_js_1 = require("./resolver.js");
@@ -35,5 +35,14 @@ Object.defineProperty(exports, "buildEffectiveDisciplineRegistry", { enumerable:
35
35
  var discipline_mode_js_1 = require("./discipline_mode.js");
36
36
  Object.defineProperty(exports, "inferDisciplineMode", { enumerable: true, get: function () { return discipline_mode_js_1.inferDisciplineMode; } });
37
37
  Object.defineProperty(exports, "resolveDisciplineMode", { enumerable: true, get: function () { return discipline_mode_js_1.resolveDisciplineMode; } });
38
+ var display_id_js_1 = require("./display_id.js");
39
+ Object.defineProperty(exports, "formatDisplayId", { enumerable: true, get: function () { return display_id_js_1.formatDisplayId; } });
40
+ Object.defineProperty(exports, "highestDisplayIdNumber", { enumerable: true, get: function () { return display_id_js_1.highestDisplayIdNumber; } });
41
+ Object.defineProperty(exports, "padDisplayIdNumber", { enumerable: true, get: function () { return display_id_js_1.padDisplayIdNumber; } });
42
+ Object.defineProperty(exports, "parseDisplayIdPattern", { enumerable: true, get: function () { return display_id_js_1.parseDisplayIdPattern; } });
43
+ var trace_targets_js_1 = require("./trace_targets.js");
44
+ Object.defineProperty(exports, "entryMatchesTargets", { enumerable: true, get: function () { return trace_targets_js_1.entryMatchesTargets; } });
45
+ Object.defineProperty(exports, "filterEntriesByTraceTargets", { enumerable: true, get: function () { return trace_targets_js_1.filterEntriesByTraceTargets; } });
46
+ Object.defineProperty(exports, "targetsForRelation", { enumerable: true, get: function () { return trace_targets_js_1.targetsForRelation; } });
38
47
  var introspect_js_1 = require("./introspect.js");
39
48
  Object.defineProperty(exports, "buildProfileIntrospection", { enumerable: true, get: function () { return introspect_js_1.buildProfileIntrospection; } });
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @module core/profile/trace_targets
3
+ *
4
+ * Pure helpers for resolving the legal target types of a trace
5
+ * attribute (e.g. `Satisfies:`, `Derived-from:`) given the source
6
+ * entry's type and the active profile chain.
7
+ *
8
+ * A profile declares per-type `traceability:` rules — each relation
9
+ * maps to a `TraceRule.target` list of {@linkcode TargetMatcher}s.
10
+ * A matcher is either a type name (string) or a shape selector
11
+ * (`{ shape: "Authored" | "Reference" }`). An entry matches when its
12
+ * `type` equals or extends a string matcher, or its `shape` equals a
13
+ * shape matcher.
14
+ *
15
+ * The LSP uses these helpers to narrow trace-attribute completion
16
+ * suggestions to the IDs the profile actually allows in that slot.
17
+ * Callers fall back to the unfiltered workspace listing when no
18
+ * rule applies (no source type known, relation undeclared, profile
19
+ * absent).
20
+ */
21
+ import type { Entry } from "../model/mod.js";
22
+ import type { EffectiveProfile, TargetMatcher } from "../model/profile.js";
23
+ /**
24
+ * Return the `TargetMatcher[]` for a given source-entry type and
25
+ * relation name, or `undefined` when no rule constrains it. Callers
26
+ * MUST treat `undefined` as "do not filter" rather than "no targets
27
+ * allowed" — the latter would silently hide every suggestion.
28
+ */
29
+ export declare function targetsForRelation(profile: EffectiveProfile, sourceType: string | undefined, relationName: string): readonly TargetMatcher[] | undefined;
30
+ /**
31
+ * Whether `entry` satisfies any matcher in `targets`. A string
32
+ * matcher matches when the entry's `type` equals or transitively
33
+ * extends the named type. A shape matcher matches when the entry's
34
+ * `shape` equals the matcher's shape. An entry with no resolved
35
+ * `type` only matches shape selectors.
36
+ */
37
+ export declare function entryMatchesTargets(entry: Entry, targets: readonly TargetMatcher[], profile: EffectiveProfile): boolean;
38
+ /**
39
+ * Filter `entries` to those that satisfy at least one of `targets`.
40
+ * Order is preserved.
41
+ */
42
+ export declare function filterEntriesByTraceTargets(entries: Iterable<Entry>, targets: readonly TargetMatcher[], profile: EffectiveProfile): Entry[];
43
+ //# sourceMappingURL=trace_targets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trace_targets.d.ts","sourceRoot":"","sources":["../../src/profile/trace_targets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,YAAY,EAAE,MAAM,GACnB,SAAS,aAAa,EAAE,GAAG,SAAS,CAOtC;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAWT;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,QAAQ,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,OAAO,EAAE,gBAAgB,GACxB,KAAK,EAAE,CAMT"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/profile/trace_targets
4
+ *
5
+ * Pure helpers for resolving the legal target types of a trace
6
+ * attribute (e.g. `Satisfies:`, `Derived-from:`) given the source
7
+ * entry's type and the active profile chain.
8
+ *
9
+ * A profile declares per-type `traceability:` rules — each relation
10
+ * maps to a `TraceRule.target` list of {@linkcode TargetMatcher}s.
11
+ * A matcher is either a type name (string) or a shape selector
12
+ * (`{ shape: "Authored" | "Reference" }`). An entry matches when its
13
+ * `type` equals or extends a string matcher, or its `shape` equals a
14
+ * shape matcher.
15
+ *
16
+ * The LSP uses these helpers to narrow trace-attribute completion
17
+ * suggestions to the IDs the profile actually allows in that slot.
18
+ * Callers fall back to the unfiltered workspace listing when no
19
+ * rule applies (no source type known, relation undeclared, profile
20
+ * absent).
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.targetsForRelation = targetsForRelation;
24
+ exports.entryMatchesTargets = entryMatchesTargets;
25
+ exports.filterEntriesByTraceTargets = filterEntriesByTraceTargets;
26
+ const discipline_mode_js_1 = require("./discipline_mode.js");
27
+ /**
28
+ * Return the `TargetMatcher[]` for a given source-entry type and
29
+ * relation name, or `undefined` when no rule constrains it. Callers
30
+ * MUST treat `undefined` as "do not filter" rather than "no targets
31
+ * allowed" — the latter would silently hide every suggestion.
32
+ */
33
+ function targetsForRelation(profile, sourceType, relationName) {
34
+ if (!sourceType)
35
+ return undefined;
36
+ const typeDef = profile.types.get(sourceType);
37
+ if (!typeDef)
38
+ return undefined;
39
+ const rule = typeDef.value.traceability.get(relationName);
40
+ if (!rule)
41
+ return undefined;
42
+ return rule.value.target;
43
+ }
44
+ /**
45
+ * Whether `entry` satisfies any matcher in `targets`. A string
46
+ * matcher matches when the entry's `type` equals or transitively
47
+ * extends the named type. A shape matcher matches when the entry's
48
+ * `shape` equals the matcher's shape. An entry with no resolved
49
+ * `type` only matches shape selectors.
50
+ */
51
+ function entryMatchesTargets(entry, targets, profile) {
52
+ for (const target of targets) {
53
+ if (typeof target === "string") {
54
+ if (!entry.type)
55
+ continue;
56
+ if (entry.type === target)
57
+ return true;
58
+ if ((0, discipline_mode_js_1.extendsTransitively)(entry.type, target, profile))
59
+ return true;
60
+ }
61
+ else {
62
+ if (entry.shape === target.shape)
63
+ return true;
64
+ }
65
+ }
66
+ return false;
67
+ }
68
+ /**
69
+ * Filter `entries` to those that satisfy at least one of `targets`.
70
+ * Order is preserved.
71
+ */
72
+ function filterEntriesByTraceTargets(entries, targets, profile) {
73
+ const out = [];
74
+ for (const entry of entries) {
75
+ if (entryMatchesTargets(entry, targets, profile))
76
+ out.push(entry);
77
+ }
78
+ return out;
79
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module core/self_upgrade/compare
3
+ *
4
+ * Strict semver-tuple comparison for self-upgrade. Three outcomes:
5
+ * - "up-to-date" current === target
6
+ * - "newer-available" current < target
7
+ * - "downgrade" current > target
8
+ *
9
+ * Accepts an optional leading 'v' on either arg. Rejects pre-release
10
+ * and build-metadata suffixes — the CLI only ships clean MAJOR.MINOR.PATCH
11
+ * tags and any drift means the input is malformed.
12
+ *
13
+ * Throws `Error` on malformed input; callers pass the compiled-in
14
+ * VERSION constant (known good) and the parsed GitHub `tag_name` (also
15
+ * known good if `releases/latest` returned successfully).
16
+ */
17
+ export type Comparison = "up-to-date" | "newer-available" | "downgrade";
18
+ export declare function compareVersions(current: string, target: string): Comparison;
19
+ //# sourceMappingURL=compare.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/compare.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,MAAM,MAAM,UAAU,GAAG,YAAY,GAAG,iBAAiB,GAAG,WAAW,CAAC;AAExE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAO3E"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/self_upgrade/compare
4
+ *
5
+ * Strict semver-tuple comparison for self-upgrade. Three outcomes:
6
+ * - "up-to-date" current === target
7
+ * - "newer-available" current < target
8
+ * - "downgrade" current > target
9
+ *
10
+ * Accepts an optional leading 'v' on either arg. Rejects pre-release
11
+ * and build-metadata suffixes — the CLI only ships clean MAJOR.MINOR.PATCH
12
+ * tags and any drift means the input is malformed.
13
+ *
14
+ * Throws `Error` on malformed input; callers pass the compiled-in
15
+ * VERSION constant (known good) and the parsed GitHub `tag_name` (also
16
+ * known good if `releases/latest` returned successfully).
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.compareVersions = compareVersions;
20
+ const VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
21
+ function compareVersions(current, target) {
22
+ const c = parse(current);
23
+ const t = parse(target);
24
+ if (c[0] !== t[0])
25
+ return c[0] < t[0] ? "newer-available" : "downgrade";
26
+ if (c[1] !== t[1])
27
+ return c[1] < t[1] ? "newer-available" : "downgrade";
28
+ if (c[2] !== t[2])
29
+ return c[2] < t[2] ? "newer-available" : "downgrade";
30
+ return "up-to-date";
31
+ }
32
+ function parse(s) {
33
+ const stripped = s.startsWith("v") ? s.slice(1) : s;
34
+ const m = VERSION_RE.exec(stripped);
35
+ if (!m)
36
+ throw new Error(`invalid version: ${JSON.stringify(s)}`);
37
+ return [parseInt(m[1], 10), parseInt(m[2], 10), parseInt(m[3], 10)];
38
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @module core/self_upgrade/manifest
3
+ *
4
+ * Build the release tarball + SHA-256 URLs for a (version, target) pair,
5
+ * and parse the single-line .sha256 files produced by sha256sum /
6
+ * shasum -a 256 in the release workflow. Pure — no I/O.
7
+ *
8
+ * The .sha256 line format is the standard one shared by GNU coreutils
9
+ * sha256sum and BSD/macOS shasum: `<64-hex> <basename>` with a two-space
10
+ * separator. We accept a trailing newline and lowercase the digest so
11
+ * callers can compare strings directly.
12
+ */
13
+ export interface ReleaseAssets {
14
+ readonly tarballUrl: string;
15
+ readonly checksumUrl: string;
16
+ }
17
+ /** Build the tarball + checksum URLs for a (version, target). */
18
+ export declare function releaseAssets(baseUrl: string, version: string, target: string): ReleaseAssets;
19
+ /** Parse a single sha256sum-format line; return the lowercase hex digest. */
20
+ export declare function parseSha256Line(line: string): string;
21
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAID,iEAAiE;AACjE,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,aAAa,CAKf;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIpD"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/self_upgrade/manifest
4
+ *
5
+ * Build the release tarball + SHA-256 URLs for a (version, target) pair,
6
+ * and parse the single-line .sha256 files produced by sha256sum /
7
+ * shasum -a 256 in the release workflow. Pure — no I/O.
8
+ *
9
+ * The .sha256 line format is the standard one shared by GNU coreutils
10
+ * sha256sum and BSD/macOS shasum: `<64-hex> <basename>` with a two-space
11
+ * separator. We accept a trailing newline and lowercase the digest so
12
+ * callers can compare strings directly.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.releaseAssets = releaseAssets;
16
+ exports.parseSha256Line = parseSha256Line;
17
+ const SHA256_LINE_RE = /^([0-9a-fA-F]{64})\s+(\S.*?)\s*$/;
18
+ /** Build the tarball + checksum URLs for a (version, target). */
19
+ function releaseAssets(baseUrl, version, target) {
20
+ const tag = version.startsWith("v") ? version : `v${version}`;
21
+ const tarballUrl = `${baseUrl}/${tag}/markspec-${target}.tar.gz`;
22
+ const checksumUrl = `${tarballUrl}.sha256`;
23
+ return { tarballUrl, checksumUrl };
24
+ }
25
+ /** Parse a single sha256sum-format line; return the lowercase hex digest. */
26
+ function parseSha256Line(line) {
27
+ const m = SHA256_LINE_RE.exec(line);
28
+ if (!m)
29
+ throw new Error(`malformed sha256 line: ${JSON.stringify(line)}`);
30
+ return m[1].toLowerCase();
31
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module core/self_upgrade
3
+ *
4
+ * Pure helpers for `markspec self-upgrade`. No I/O — see
5
+ * `cli/self_upgrade/` and `cli/commands/self_upgrade.ts` for the
6
+ * orchestrator and helpers that wire these into HTTP + filesystem.
7
+ */
8
+ export { compareVersions, type Comparison } from "./compare.js";
9
+ export { classifyInstallPath, type ClassifyResult, type InstallSource, } from "./pm_detect.js";
10
+ export { parseSha256Line, type ReleaseAssets, releaseAssets, } from "./manifest.js";
11
+ export { type Arch, detectTarget, type Os, type Platform, platformFromBuild, type Target, } from "./target.js";
12
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/mod.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,eAAe,EACf,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,IAAI,EACT,YAAY,EACZ,KAAK,EAAE,EACP,KAAK,QAAQ,EACb,iBAAiB,EACjB,KAAK,MAAM,GACZ,MAAM,aAAa,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/self_upgrade
4
+ *
5
+ * Pure helpers for `markspec self-upgrade`. No I/O — see
6
+ * `cli/self_upgrade/` and `cli/commands/self_upgrade.ts` for the
7
+ * orchestrator and helpers that wire these into HTTP + filesystem.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.platformFromBuild = exports.detectTarget = exports.releaseAssets = exports.parseSha256Line = exports.classifyInstallPath = exports.compareVersions = void 0;
11
+ var compare_js_1 = require("./compare.js");
12
+ Object.defineProperty(exports, "compareVersions", { enumerable: true, get: function () { return compare_js_1.compareVersions; } });
13
+ var pm_detect_js_1 = require("./pm_detect.js");
14
+ Object.defineProperty(exports, "classifyInstallPath", { enumerable: true, get: function () { return pm_detect_js_1.classifyInstallPath; } });
15
+ var manifest_js_1 = require("./manifest.js");
16
+ Object.defineProperty(exports, "parseSha256Line", { enumerable: true, get: function () { return manifest_js_1.parseSha256Line; } });
17
+ Object.defineProperty(exports, "releaseAssets", { enumerable: true, get: function () { return manifest_js_1.releaseAssets; } });
18
+ var target_js_1 = require("./target.js");
19
+ Object.defineProperty(exports, "detectTarget", { enumerable: true, get: function () { return target_js_1.detectTarget; } });
20
+ Object.defineProperty(exports, "platformFromBuild", { enumerable: true, get: function () { return target_js_1.platformFromBuild; } });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @module core/self_upgrade/pm_detect
3
+ *
4
+ * Classify the realpath of the running binary into one of four
5
+ * install-source buckets so the self-upgrade orchestrator can refuse
6
+ * with a per-manager hint instead of fighting the package manager.
7
+ *
8
+ * The check is heuristic and order-sensitive — Homebrew first (because
9
+ * brew's bin paths live under /opt/homebrew or /usr/local), npm second,
10
+ * system third, user-local fourth. Anything that falls through is
11
+ * "unknown" and the orchestrator proceeds with a warning.
12
+ *
13
+ * Path matching is whole-segment (path separator on both sides) to
14
+ * avoid matching e.g. `/foo/.localfish/markspec` against the user-local
15
+ * `.local` rule.
16
+ *
17
+ * Pure — no I/O. Callers must pass the realpath (symlinks resolved) so
18
+ * brew's `/opt/homebrew/bin/markspec` -> `/opt/homebrew/Cellar/.../bin/markspec`
19
+ * is classified correctly.
20
+ */
21
+ export type InstallSource = "user-local" | "homebrew" | "npm" | "system" | "unknown";
22
+ export interface ClassifyResult {
23
+ readonly source: InstallSource;
24
+ readonly hintCommand?: string;
25
+ }
26
+ export declare function classifyInstallPath(realPath: string, home: string): ClassifyResult;
27
+ //# sourceMappingURL=pm_detect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pm_detect.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/pm_detect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,UAAU,GACV,KAAK,GACL,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,cAAc,CA+ChB"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/self_upgrade/pm_detect
4
+ *
5
+ * Classify the realpath of the running binary into one of four
6
+ * install-source buckets so the self-upgrade orchestrator can refuse
7
+ * with a per-manager hint instead of fighting the package manager.
8
+ *
9
+ * The check is heuristic and order-sensitive — Homebrew first (because
10
+ * brew's bin paths live under /opt/homebrew or /usr/local), npm second,
11
+ * system third, user-local fourth. Anything that falls through is
12
+ * "unknown" and the orchestrator proceeds with a warning.
13
+ *
14
+ * Path matching is whole-segment (path separator on both sides) to
15
+ * avoid matching e.g. `/foo/.localfish/markspec` against the user-local
16
+ * `.local` rule.
17
+ *
18
+ * Pure — no I/O. Callers must pass the realpath (symlinks resolved) so
19
+ * brew's `/opt/homebrew/bin/markspec` -> `/opt/homebrew/Cellar/.../bin/markspec`
20
+ * is classified correctly.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.classifyInstallPath = classifyInstallPath;
24
+ function classifyInstallPath(realPath, home) {
25
+ // Normalise to forward slashes for matching. Windows paths use '\';
26
+ // we accept both by replacing.
27
+ const p = realPath.replace(/\\/g, "/");
28
+ const h = home.replace(/\\/g, "/");
29
+ // 1. Homebrew. The Cellar segment is the canonical real-path marker;
30
+ // /opt/homebrew/ on its own catches symlink-without-realpath.
31
+ if (p.includes("/Cellar/") ||
32
+ p.startsWith("/opt/homebrew/")) {
33
+ return { source: "homebrew", hintCommand: "brew upgrade markspec" };
34
+ }
35
+ // 2. npm. node_modules, .npm/, .nvm/.
36
+ if (p.includes("/node_modules/") ||
37
+ p.includes("/.nvm/") ||
38
+ p.includes("/.npm/")) {
39
+ return { source: "npm", hintCommand: "npm update -g markspec" };
40
+ }
41
+ // 3. user-local paths under $HOME.
42
+ if (h && p.startsWith(`${h}/`)) {
43
+ const tail = p.slice(h.length + 1);
44
+ if (tail.startsWith(".local/") ||
45
+ tail.startsWith(".cargo/bin/") ||
46
+ tail.startsWith("bin/") ||
47
+ tail.startsWith("Library/")) {
48
+ return { source: "user-local" };
49
+ }
50
+ }
51
+ // 4. system bins.
52
+ if (p.startsWith("/usr/") ||
53
+ p.startsWith("/opt/") ||
54
+ p.startsWith("/snap/")) {
55
+ return { source: "system" };
56
+ }
57
+ return { source: "unknown" };
58
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @module core/self_upgrade/target
3
+ *
4
+ * Map (os, arch) → the GitHub release target string used in tarball
5
+ * names. Targets match those produced by the Release workflow:
6
+ * x86_64-unknown-linux-gnu, x86_64-apple-darwin,
7
+ * aarch64-apple-darwin, x86_64-pc-windows-msvc.
8
+ *
9
+ * Pure functions — no I/O, no Deno.* APIs. The CLI passes
10
+ * `Deno.build.os` / `Deno.build.arch` strings to platformFromBuild;
11
+ * this module never reads them itself so tests don't need any
12
+ * environment setup.
13
+ */
14
+ export type Os = "linux" | "darwin" | "windows";
15
+ export type Arch = "x86_64" | "aarch64";
16
+ export interface Platform {
17
+ readonly os: Os;
18
+ readonly arch: Arch;
19
+ }
20
+ export type Target = "x86_64-unknown-linux-gnu" | "x86_64-apple-darwin" | "aarch64-apple-darwin" | "x86_64-pc-windows-msvc";
21
+ /** Return the release target for a platform, or undefined if not shipped. */
22
+ export declare function detectTarget(platform: Platform): Target | undefined;
23
+ /** Parse Deno.build.{os,arch} strings into a typed Platform, or undefined. */
24
+ export declare function platformFromBuild(os: string, arch: string): Platform | undefined;
25
+ //# sourceMappingURL=target.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../src/self_upgrade/target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,EAAE,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAChD,MAAM,MAAM,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExC,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,MAAM,GACd,0BAA0B,GAC1B,qBAAqB,GACrB,sBAAsB,GACtB,wBAAwB,CAAC;AAE7B,6EAA6E;AAC7E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAOnE;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,GACX,QAAQ,GAAG,SAAS,CAKtB"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/self_upgrade/target
4
+ *
5
+ * Map (os, arch) → the GitHub release target string used in tarball
6
+ * names. Targets match those produced by the Release workflow:
7
+ * x86_64-unknown-linux-gnu, x86_64-apple-darwin,
8
+ * aarch64-apple-darwin, x86_64-pc-windows-msvc.
9
+ *
10
+ * Pure functions — no I/O, no Deno.* APIs. The CLI passes
11
+ * `Deno.build.os` / `Deno.build.arch` strings to platformFromBuild;
12
+ * this module never reads them itself so tests don't need any
13
+ * environment setup.
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.detectTarget = detectTarget;
17
+ exports.platformFromBuild = platformFromBuild;
18
+ /** Return the release target for a platform, or undefined if not shipped. */
19
+ function detectTarget(platform) {
20
+ const { os, arch } = platform;
21
+ if (os === "linux" && arch === "x86_64")
22
+ return "x86_64-unknown-linux-gnu";
23
+ if (os === "darwin" && arch === "x86_64")
24
+ return "x86_64-apple-darwin";
25
+ if (os === "darwin" && arch === "aarch64")
26
+ return "aarch64-apple-darwin";
27
+ if (os === "windows" && arch === "x86_64")
28
+ return "x86_64-pc-windows-msvc";
29
+ return undefined;
30
+ }
31
+ /** Parse Deno.build.{os,arch} strings into a typed Platform, or undefined. */
32
+ function platformFromBuild(os, arch) {
33
+ const okOs = os === "linux" || os === "darwin" || os === "windows";
34
+ const okArch = arch === "x86_64" || arch === "aarch64";
35
+ if (!okOs || !okArch)
36
+ return undefined;
37
+ return { os, arch };
38
+ }