@driftsys/markspec 0.6.1 → 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 (103) 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/profile/display_id.d.ts +60 -0
  29. package/esm/profile/display_id.d.ts.map +1 -0
  30. package/esm/profile/display_id.js +80 -0
  31. package/esm/profile/mod.d.ts +3 -0
  32. package/esm/profile/mod.d.ts.map +1 -1
  33. package/esm/profile/mod.js +2 -0
  34. package/esm/profile/trace_targets.d.ts +43 -0
  35. package/esm/profile/trace_targets.d.ts.map +1 -0
  36. package/esm/profile/trace_targets.js +74 -0
  37. package/esm/self_upgrade/compare.d.ts +19 -0
  38. package/esm/self_upgrade/compare.d.ts.map +1 -0
  39. package/esm/self_upgrade/compare.js +35 -0
  40. package/esm/self_upgrade/manifest.d.ts +21 -0
  41. package/esm/self_upgrade/manifest.d.ts.map +1 -0
  42. package/esm/self_upgrade/manifest.js +27 -0
  43. package/esm/self_upgrade/mod.d.ts +12 -0
  44. package/esm/self_upgrade/mod.d.ts.map +1 -0
  45. package/esm/self_upgrade/mod.js +11 -0
  46. package/esm/self_upgrade/pm_detect.d.ts +27 -0
  47. package/esm/self_upgrade/pm_detect.d.ts.map +1 -0
  48. package/esm/self_upgrade/pm_detect.js +55 -0
  49. package/esm/self_upgrade/target.d.ts +25 -0
  50. package/esm/self_upgrade/target.d.ts.map +1 -0
  51. package/esm/self_upgrade/target.js +34 -0
  52. package/package.json +1 -1
  53. package/script/lint/mod.d.ts +2 -0
  54. package/script/lint/mod.d.ts.map +1 -1
  55. package/script/lint/mod.js +3 -1
  56. package/script/lint/rules/xref.d.ts +32 -5
  57. package/script/lint/rules/xref.d.ts.map +1 -1
  58. package/script/lint/rules/xref.js +42 -0
  59. package/script/lint/runner.d.ts.map +1 -1
  60. package/script/lint/runner.js +5 -1
  61. package/script/lint/score_text.d.ts +67 -0
  62. package/script/lint/score_text.d.ts.map +1 -0
  63. package/script/lint/score_text.js +77 -0
  64. package/script/lock/compare.d.ts +34 -0
  65. package/script/lock/compare.d.ts.map +1 -0
  66. package/script/lock/compare.js +67 -0
  67. package/script/lock/mod.d.ts +2 -1
  68. package/script/lock/mod.d.ts.map +1 -1
  69. package/script/lock/mod.js +3 -1
  70. package/script/lock/model.d.ts +13 -0
  71. package/script/lock/model.d.ts.map +1 -1
  72. package/script/lock/parser.d.ts +3 -0
  73. package/script/lock/parser.d.ts.map +1 -1
  74. package/script/lock/parser.js +37 -1
  75. package/script/lock/serializer.d.ts.map +1 -1
  76. package/script/lock/serializer.js +4 -0
  77. package/script/mod.d.ts +7 -3
  78. package/script/mod.d.ts.map +1 -1
  79. package/script/mod.js +82 -63
  80. package/script/profile/display_id.d.ts +60 -0
  81. package/script/profile/display_id.d.ts.map +1 -0
  82. package/script/profile/display_id.js +86 -0
  83. package/script/profile/mod.d.ts +3 -0
  84. package/script/profile/mod.d.ts.map +1 -1
  85. package/script/profile/mod.js +10 -1
  86. package/script/profile/trace_targets.d.ts +43 -0
  87. package/script/profile/trace_targets.d.ts.map +1 -0
  88. package/script/profile/trace_targets.js +79 -0
  89. package/script/self_upgrade/compare.d.ts +19 -0
  90. package/script/self_upgrade/compare.d.ts.map +1 -0
  91. package/script/self_upgrade/compare.js +38 -0
  92. package/script/self_upgrade/manifest.d.ts +21 -0
  93. package/script/self_upgrade/manifest.d.ts.map +1 -0
  94. package/script/self_upgrade/manifest.js +31 -0
  95. package/script/self_upgrade/mod.d.ts +12 -0
  96. package/script/self_upgrade/mod.d.ts.map +1 -0
  97. package/script/self_upgrade/mod.js +20 -0
  98. package/script/self_upgrade/pm_detect.d.ts +27 -0
  99. package/script/self_upgrade/pm_detect.d.ts.map +1 -0
  100. package/script/self_upgrade/pm_detect.js +58 -0
  101. package/script/self_upgrade/target.d.ts +25 -0
  102. package/script/self_upgrade/target.d.ts.map +1 -0
  103. package/script/self_upgrade/target.js +38 -0
package/esm/mod.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * from core/mod.ts, never from internal paths.
9
9
  */
10
10
  import "./_dnt.polyfills.js";
11
- export const VERSION = "0.6.1";
11
+ export const VERSION = "0.6.2";
12
12
  export const CORE_SCHEMA_VERSION = 1;
13
13
  // Model types
14
14
  export { ConfigError, CORE_DISCIPLINE_REGISTRY, CORE_KINDS, DEFAULT_PROJECT_CONFIG, KNOWN_LINK_KINDS, makeDisplayId, makeUlid, MIXED_DISCIPLINE, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
@@ -25,6 +25,8 @@ export { computeCacheKey, computeCacheLocation, defaultAppendFile, defaultRunGit
25
25
  export { buildEffectiveDisciplineRegistry } from "./profile/mod.js";
26
26
  export { inferDisciplineMode, resolveDisciplineMode } from "./profile/mod.js";
27
27
  // DisciplineMode type already re-exported via Task 2.
28
+ export { formatDisplayId, highestDisplayIdNumber, padDisplayIdNumber, parseDisplayIdPattern, } from "./profile/mod.js";
29
+ export { entryMatchesTargets, filterEntriesByTraceTargets, targetsForRelation, } from "./profile/mod.js";
28
30
  export { buildProfileIntrospection } from "./profile/mod.js";
29
31
  // Parser
30
32
  export { detectCaptions, detectDirectives, detectInlineRefs, isSupportedExtension, loadGrammar, parse, parseFile, parseSource, } from "./parser/mod.js";
@@ -42,6 +44,8 @@ export { report } from "./reporter/mod.js";
42
44
  export { ANTI_PATTERN_NOTE, computeScoreRollup, isProseScope, runLint, } from "./lint/mod.js";
43
45
  export * as typl from "./typl/mod.js";
44
46
  // ── Lockfile (ADR-022) ───────────────────────────────────────────────────
45
- export { canonicalEdgeJson, checkDrift, extractEdgeQuads, hashCanonicalEdges, LOCKFILE_SCHEMA_VERSION, parseLockfile, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, serializeLockfile, sha256Bytes, sha256String, } from "./lock/mod.js";
47
+ export { canonicalEdgeJson, checkDrift, extractEdgeQuads, hashCanonicalEdges, isBelowFloor, LOCKFILE_SCHEMA_VERSION, parseLockfile, resolveBoundEntries, resolveProfileChain, resolveReferences, resolveRegistries, resolveUpstreams, serializeLockfile, sha256Bytes, sha256String, } from "./lock/mod.js";
46
48
  // ── External sync model (ADR-022) ────────────────────────────────────────
47
49
  export { aggregateStatusByState, encodeLogLine, inferLockedAttributes, parseLogLine, parseMapping, validateMappings, } from "./sync/mod.js";
50
+ // ── Self-upgrade ─────────────────────────────────────────────────────────
51
+ export { classifyInstallPath, compareVersions, detectTarget, parseSha256Line, platformFromBuild, releaseAssets, } from "./self_upgrade/mod.js";
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @module core/profile/display_id
3
+ *
4
+ * Shared parser for the `display-id-pattern` template used by profile
5
+ * type declarations. Patterns look like:
6
+ *
7
+ * STK_{n:4d}
8
+ * STK_AEB_{n:04d}
9
+ * REQ-{n:03d}-draft
10
+ *
11
+ * The `{n:Nd}` placeholder (with optional leading zero in the Nd
12
+ * form) names the sequential number slot. The text before the
13
+ * placeholder becomes the literal prefix; the text after becomes the
14
+ * literal suffix.
15
+ *
16
+ * Note: the `{scope}` placeholder documented in the profile schema
17
+ * is NOT substituted here — callers handle that separately. For
18
+ * patterns containing `{scope}`, the literal text `{scope}` ends up
19
+ * in `prefix` (or `suffix`) and must be replaced upstream before the
20
+ * pattern is fed to scaffolding.
21
+ */
22
+ /** Width-and-position decomposition of a display-id-pattern. */
23
+ export interface DisplayIdPatternShape {
24
+ /** Literal text before the `{n:Nd}` placeholder. */
25
+ readonly prefix: string;
26
+ /** Width of the zero-padded numeric segment. */
27
+ readonly width: number;
28
+ /** Literal text after the `{n:Nd}` placeholder (often empty). */
29
+ readonly suffix: string;
30
+ }
31
+ /**
32
+ * Parse a `display-id-pattern` template. Returns `undefined` when
33
+ * the pattern does not contain a recognised `{n:Nd}` placeholder so
34
+ * callers can decide how to surface the error (CLI exits, LSP
35
+ * silently skips the type).
36
+ */
37
+ export declare function parseDisplayIdPattern(pattern: string): DisplayIdPatternShape | undefined;
38
+ /**
39
+ * Pad a positive integer with leading zeros to at least `width`
40
+ * characters. Numbers longer than `width` are left unchanged — the
41
+ * pattern's width is a minimum, not a maximum, mirroring printf
42
+ * `%0Nd` semantics.
43
+ */
44
+ export declare function padDisplayIdNumber(n: number, width: number): string;
45
+ /**
46
+ * Format a display ID from a parsed pattern and a numeric value.
47
+ * Inverse of the per-entry scan that {@linkcode highestDisplayIdNumber}
48
+ * performs.
49
+ */
50
+ export declare function formatDisplayId(shape: DisplayIdPatternShape, n: number): string;
51
+ /**
52
+ * Scan `entries` for the highest numeric value used by any display
53
+ * ID that matches the given shape (same prefix AND same suffix; the
54
+ * numeric segment is parsed as a base-10 integer). Returns 0 when no
55
+ * matching ID exists, so `+ 1` yields the next sequential number.
56
+ */
57
+ export declare function highestDisplayIdNumber(shape: DisplayIdPatternShape, entries: Iterable<{
58
+ displayId: string;
59
+ }>): number;
60
+ //# sourceMappingURL=display_id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"display_id.d.ts","sourceRoot":"","sources":["../../src/profile/display_id.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,gEAAgE;AAChE,MAAM,WAAW,qBAAqB;IACpC,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAKD;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GACd,qBAAqB,GAAG,SAAS,CAUnC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,qBAAqB,EAC5B,CAAC,EAAE,MAAM,GACR,MAAM,CAER;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,qBAAqB,EAC5B,OAAO,EAAE,QAAQ,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,GACvC,MAAM,CAcR"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @module core/profile/display_id
3
+ *
4
+ * Shared parser for the `display-id-pattern` template used by profile
5
+ * type declarations. Patterns look like:
6
+ *
7
+ * STK_{n:4d}
8
+ * STK_AEB_{n:04d}
9
+ * REQ-{n:03d}-draft
10
+ *
11
+ * The `{n:Nd}` placeholder (with optional leading zero in the Nd
12
+ * form) names the sequential number slot. The text before the
13
+ * placeholder becomes the literal prefix; the text after becomes the
14
+ * literal suffix.
15
+ *
16
+ * Note: the `{scope}` placeholder documented in the profile schema
17
+ * is NOT substituted here — callers handle that separately. For
18
+ * patterns containing `{scope}`, the literal text `{scope}` ends up
19
+ * in `prefix` (or `suffix`) and must be replaced upstream before the
20
+ * pattern is fed to scaffolding.
21
+ */
22
+ /** Regex capturing the `{n:Nd}` placeholder; `0` and the digit count are both captured. */
23
+ const PLACEHOLDER_RE = /\{n:(\d+)d\}/;
24
+ /**
25
+ * Parse a `display-id-pattern` template. Returns `undefined` when
26
+ * the pattern does not contain a recognised `{n:Nd}` placeholder so
27
+ * callers can decide how to surface the error (CLI exits, LSP
28
+ * silently skips the type).
29
+ */
30
+ export function parseDisplayIdPattern(pattern) {
31
+ const match = PLACEHOLDER_RE.exec(pattern);
32
+ if (!match)
33
+ return undefined;
34
+ const width = parseInt(match[1], 10);
35
+ if (!Number.isFinite(width) || width < 1)
36
+ return undefined;
37
+ return {
38
+ prefix: pattern.slice(0, match.index),
39
+ width,
40
+ suffix: pattern.slice(match.index + match[0].length),
41
+ };
42
+ }
43
+ /**
44
+ * Pad a positive integer with leading zeros to at least `width`
45
+ * characters. Numbers longer than `width` are left unchanged — the
46
+ * pattern's width is a minimum, not a maximum, mirroring printf
47
+ * `%0Nd` semantics.
48
+ */
49
+ export function padDisplayIdNumber(n, width) {
50
+ return n.toString().padStart(width, "0");
51
+ }
52
+ /**
53
+ * Format a display ID from a parsed pattern and a numeric value.
54
+ * Inverse of the per-entry scan that {@linkcode highestDisplayIdNumber}
55
+ * performs.
56
+ */
57
+ export function formatDisplayId(shape, n) {
58
+ return `${shape.prefix}${padDisplayIdNumber(n, shape.width)}${shape.suffix}`;
59
+ }
60
+ /**
61
+ * Scan `entries` for the highest numeric value used by any display
62
+ * ID that matches the given shape (same prefix AND same suffix; the
63
+ * numeric segment is parsed as a base-10 integer). Returns 0 when no
64
+ * matching ID exists, so `+ 1` yields the next sequential number.
65
+ */
66
+ export function highestDisplayIdNumber(shape, entries) {
67
+ let max = 0;
68
+ for (const entry of entries) {
69
+ const id = entry.displayId;
70
+ if (!id.startsWith(shape.prefix))
71
+ continue;
72
+ if (shape.suffix && !id.endsWith(shape.suffix))
73
+ continue;
74
+ const numberPart = id.slice(shape.prefix.length, id.length - shape.suffix.length);
75
+ const n = parseInt(numberPart, 10);
76
+ if (!isNaN(n) && n > max)
77
+ max = n;
78
+ }
79
+ return max;
80
+ }
@@ -19,6 +19,9 @@ export type { MergeResult } from "./merge.js";
19
19
  export { resolveEntryColor } from "./colors.js";
20
20
  export { buildEffectiveDisciplineRegistry } from "./discipline_registry.js";
21
21
  export { inferDisciplineMode, resolveDisciplineMode, } from "./discipline_mode.js";
22
+ export { formatDisplayId, highestDisplayIdNumber, padDisplayIdNumber, parseDisplayIdPattern, } from "./display_id.js";
23
+ export type { DisplayIdPatternShape } from "./display_id.js";
24
+ export { entryMatchesTargets, filterEntriesByTraceTargets, targetsForRelation, } from "./trace_targets.js";
22
25
  export { buildProfileIntrospection } from "./introspect.js";
23
26
  export type { AttributeDetail, ConventionDetail, LabelConcernDetail, ProfileElementDetail, ProfileElementKind, ProfileElementRef, ProfileIntrospection, ProfileOverview, ProvenancedDescription, RelationDetail, TypeDetail, } from "./introspect.js";
24
27
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/profile/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/profile/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE9E,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACb,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,YAAY,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAO9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,gCAAgC,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7D,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,sBAAsB,EACtB,cAAc,EACd,UAAU,GACX,MAAM,iBAAiB,CAAC"}
@@ -17,4 +17,6 @@ export { mergeChain } from "./merge.js";
17
17
  export { resolveEntryColor } from "./colors.js";
18
18
  export { buildEffectiveDisciplineRegistry } from "./discipline_registry.js";
19
19
  export { inferDisciplineMode, resolveDisciplineMode, } from "./discipline_mode.js";
20
+ export { formatDisplayId, highestDisplayIdNumber, padDisplayIdNumber, parseDisplayIdPattern, } from "./display_id.js";
21
+ export { entryMatchesTargets, filterEntriesByTraceTargets, targetsForRelation, } from "./trace_targets.js";
20
22
  export { buildProfileIntrospection } from "./introspect.js";
@@ -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,74 @@
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 { extendsTransitively } from "./discipline_mode.js";
22
+ /**
23
+ * Return the `TargetMatcher[]` for a given source-entry type and
24
+ * relation name, or `undefined` when no rule constrains it. Callers
25
+ * MUST treat `undefined` as "do not filter" rather than "no targets
26
+ * allowed" — the latter would silently hide every suggestion.
27
+ */
28
+ export function targetsForRelation(profile, sourceType, relationName) {
29
+ if (!sourceType)
30
+ return undefined;
31
+ const typeDef = profile.types.get(sourceType);
32
+ if (!typeDef)
33
+ return undefined;
34
+ const rule = typeDef.value.traceability.get(relationName);
35
+ if (!rule)
36
+ return undefined;
37
+ return rule.value.target;
38
+ }
39
+ /**
40
+ * Whether `entry` satisfies any matcher in `targets`. A string
41
+ * matcher matches when the entry's `type` equals or transitively
42
+ * extends the named type. A shape matcher matches when the entry's
43
+ * `shape` equals the matcher's shape. An entry with no resolved
44
+ * `type` only matches shape selectors.
45
+ */
46
+ export function entryMatchesTargets(entry, targets, profile) {
47
+ for (const target of targets) {
48
+ if (typeof target === "string") {
49
+ if (!entry.type)
50
+ continue;
51
+ if (entry.type === target)
52
+ return true;
53
+ if (extendsTransitively(entry.type, target, profile))
54
+ return true;
55
+ }
56
+ else {
57
+ if (entry.shape === target.shape)
58
+ return true;
59
+ }
60
+ }
61
+ return false;
62
+ }
63
+ /**
64
+ * Filter `entries` to those that satisfy at least one of `targets`.
65
+ * Order is preserved.
66
+ */
67
+ export function filterEntriesByTraceTargets(entries, targets, profile) {
68
+ const out = [];
69
+ for (const entry of entries) {
70
+ if (entryMatchesTargets(entry, targets, profile))
71
+ out.push(entry);
72
+ }
73
+ return out;
74
+ }
@@ -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,35 @@
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
+ const VERSION_RE = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
18
+ export function compareVersions(current, target) {
19
+ const c = parse(current);
20
+ const t = parse(target);
21
+ if (c[0] !== t[0])
22
+ return c[0] < t[0] ? "newer-available" : "downgrade";
23
+ if (c[1] !== t[1])
24
+ return c[1] < t[1] ? "newer-available" : "downgrade";
25
+ if (c[2] !== t[2])
26
+ return c[2] < t[2] ? "newer-available" : "downgrade";
27
+ return "up-to-date";
28
+ }
29
+ function parse(s) {
30
+ const stripped = s.startsWith("v") ? s.slice(1) : s;
31
+ const m = VERSION_RE.exec(stripped);
32
+ if (!m)
33
+ throw new Error(`invalid version: ${JSON.stringify(s)}`);
34
+ return [parseInt(m[1], 10), parseInt(m[2], 10), parseInt(m[3], 10)];
35
+ }
@@ -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,27 @@
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
+ const SHA256_LINE_RE = /^([0-9a-fA-F]{64})\s+(\S.*?)\s*$/;
14
+ /** Build the tarball + checksum URLs for a (version, target). */
15
+ export function releaseAssets(baseUrl, version, target) {
16
+ const tag = version.startsWith("v") ? version : `v${version}`;
17
+ const tarballUrl = `${baseUrl}/${tag}/markspec-${target}.tar.gz`;
18
+ const checksumUrl = `${tarballUrl}.sha256`;
19
+ return { tarballUrl, checksumUrl };
20
+ }
21
+ /** Parse a single sha256sum-format line; return the lowercase hex digest. */
22
+ export function parseSha256Line(line) {
23
+ const m = SHA256_LINE_RE.exec(line);
24
+ if (!m)
25
+ throw new Error(`malformed sha256 line: ${JSON.stringify(line)}`);
26
+ return m[1].toLowerCase();
27
+ }
@@ -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,11 @@
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 } from "./compare.js";
9
+ export { classifyInstallPath, } from "./pm_detect.js";
10
+ export { parseSha256Line, releaseAssets, } from "./manifest.js";
11
+ export { detectTarget, platformFromBuild, } from "./target.js";
@@ -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,55 @@
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 function classifyInstallPath(realPath, home) {
22
+ // Normalise to forward slashes for matching. Windows paths use '\';
23
+ // we accept both by replacing.
24
+ const p = realPath.replace(/\\/g, "/");
25
+ const h = home.replace(/\\/g, "/");
26
+ // 1. Homebrew. The Cellar segment is the canonical real-path marker;
27
+ // /opt/homebrew/ on its own catches symlink-without-realpath.
28
+ if (p.includes("/Cellar/") ||
29
+ p.startsWith("/opt/homebrew/")) {
30
+ return { source: "homebrew", hintCommand: "brew upgrade markspec" };
31
+ }
32
+ // 2. npm. node_modules, .npm/, .nvm/.
33
+ if (p.includes("/node_modules/") ||
34
+ p.includes("/.nvm/") ||
35
+ p.includes("/.npm/")) {
36
+ return { source: "npm", hintCommand: "npm update -g markspec" };
37
+ }
38
+ // 3. user-local paths under $HOME.
39
+ if (h && p.startsWith(`${h}/`)) {
40
+ const tail = p.slice(h.length + 1);
41
+ if (tail.startsWith(".local/") ||
42
+ tail.startsWith(".cargo/bin/") ||
43
+ tail.startsWith("bin/") ||
44
+ tail.startsWith("Library/")) {
45
+ return { source: "user-local" };
46
+ }
47
+ }
48
+ // 4. system bins.
49
+ if (p.startsWith("/usr/") ||
50
+ p.startsWith("/opt/") ||
51
+ p.startsWith("/snap/")) {
52
+ return { source: "system" };
53
+ }
54
+ return { source: "unknown" };
55
+ }
@@ -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,34 @@
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
+ /** Return the release target for a platform, or undefined if not shipped. */
15
+ export function detectTarget(platform) {
16
+ const { os, arch } = platform;
17
+ if (os === "linux" && arch === "x86_64")
18
+ return "x86_64-unknown-linux-gnu";
19
+ if (os === "darwin" && arch === "x86_64")
20
+ return "x86_64-apple-darwin";
21
+ if (os === "darwin" && arch === "aarch64")
22
+ return "aarch64-apple-darwin";
23
+ if (os === "windows" && arch === "x86_64")
24
+ return "x86_64-pc-windows-msvc";
25
+ return undefined;
26
+ }
27
+ /** Parse Deno.build.{os,arch} strings into a typed Platform, or undefined. */
28
+ export function platformFromBuild(os, arch) {
29
+ const okOs = os === "linux" || os === "darwin" || os === "windows";
30
+ const okArch = arch === "x86_64" || arch === "aarch64";
31
+ if (!okOs || !okArch)
32
+ return undefined;
33
+ return { os, arch };
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftsys/markspec",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "Markdown flavor and toolchain for traceable industrial documentation",
5
5
  "keywords": [
6
6
  "markdown",
@@ -9,6 +9,8 @@ export { isProseScope, runLint } from "./runner.js";
9
9
  export type { LintOptions, LintResult } from "./runner.js";
10
10
  export { ANTI_PATTERN_NOTE, computeScoreRollup } from "./score.js";
11
11
  export type { EntryScore, RuleContribution, ScoreRollup } from "./score.js";
12
+ export { scoreText } from "./score_text.js";
13
+ export type { ScoreTextOptions, ScoreTextResult } from "./score_text.js";
12
14
  export { segmentSentences } from "./segmenter.js";
13
15
  export type { Sentence } from "./segmenter.js";
14
16
  //# sourceMappingURL=mod.d.ts.map