@driftsys/markspec 0.7.4 → 0.8.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/esm/mod.d.ts 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 declare const VERSION = "0.7.4";
11
+ export declare const VERSION = "0.8.0";
12
12
  export declare const CORE_SCHEMA_VERSION = 1;
13
13
  export { ConfigError, CORE_DISCIPLINE_REGISTRY, CORE_KINDS, CORE_RELATIONS, DEFAULT_PROJECT_CONFIG, descendantsOf, KNOWN_LINK_KINDS, LOCK_EXTRA_INVERSE_KEYS, makeDisplayId, makeUlid, MIXED_DISCIPLINE, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
14
14
  export type { Attribute, BodyToken, BodyTokenKind, Caption, CaptionConventions, CaptionPosition, ConfigFieldError, Diagnostic, Directive, Discipline, DisciplineRegistry, DisplayId, EarsTrigger, EffectiveProfile, EffectiveTypeDef, EntityRefConvention, Entry, EntryShape, EntrySource, ExtractorRule, InlineRef, KindDecl, LabelConcern, LabelConcernKind, LabelValue, Link, LinkKind, LoadedProfile, ModalCase, PaletteHue, ProfileChain, ProfileConvention, ProjectConfig, ProvenancedMap, ProvenancedMapEntry, ProvenancedValue, RelationDef, Severity, SourceLocation, Ulid, } from "./model/mod.js";
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.7.4";
11
+ export const VERSION = "0.8.0";
12
12
  export const CORE_SCHEMA_VERSION = 1;
13
13
  // Model types
14
14
  export { ConfigError, CORE_DISCIPLINE_REGISTRY, CORE_KINDS, CORE_RELATIONS, DEFAULT_PROJECT_CONFIG, descendantsOf, KNOWN_LINK_KINDS, LOCK_EXTRA_INVERSE_KEYS, makeDisplayId, makeUlid, MIXED_DISCIPLINE, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAQD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAuDtC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAcD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA4FtC"}
package/esm/refs/mod.js CHANGED
@@ -43,6 +43,11 @@ export function buildRefIndex(entries) {
43
43
  }
44
44
  /** Trailer trace line: indent, key, `:` + spaces, value-rest. */
45
45
  const TRACE_TRAILER_RE = /^(\s{4,})([A-Z][A-Za-z-]*)(\s*:\s*)(.*)$/;
46
+ /**
47
+ * A `\`-continuation line of a multi-line trace value: leading indent then a
48
+ * non-empty value-rest (no `Key:` — that sat on the first physical line).
49
+ */
50
+ const CONTINUATION_LINE_RE = /^(\s+)(\S.*)$/;
46
51
  /** Token splitter that preserves separators between value tokens. */
47
52
  const VALUE_TOKEN_RE = /[^\s,]+/g;
48
53
  /**
@@ -91,18 +96,55 @@ export function canonicalizeRefs(content, entries, index, ledger) {
91
96
  const [, indent, key, sep, rest] = m;
92
97
  if (!TRACE_ATTRIBUTE_KEYS.has(key))
93
98
  continue;
94
- // Multi-line continuation — leave untouched (debt: full multi-line support).
95
- if (rest.endsWith("\\"))
96
- continue;
97
99
  const sourceUlid = sourceUlidForLine(i + 1);
98
- const rewritten = rest.replace(VALUE_TOKEN_RE, (token) => rewriteToken(token, sourceUlid, key, index, ledgerByKey));
99
- if (rewritten !== rest) {
100
- lines[i] = `${indent}${key}${sep}${rewritten}${cr ? "\r" : ""}`;
100
+ // Rewrite the key line's value, preserving any trailing `\` continuation
101
+ // marker (only resolvable tokens change — indentation, separators and the
102
+ // backslash stay byte-for-byte).
103
+ const newRest = rewriteValuePreservingContinuation(rest, sourceUlid, key, index, ledgerByKey);
104
+ if (newRest !== rest) {
105
+ lines[i] = `${indent}${key}${sep}${newRest}${cr ? "\r" : ""}`;
101
106
  changed = true;
102
107
  }
108
+ // Multi-line value: a `\`-continued value splits across physical lines,
109
+ // each non-final line ending in `\`. Walk the continuation lines (indent +
110
+ // value, no key) and rewrite each the same way, stopping at the first line
111
+ // that does not end in `\`. `i` is advanced past the consumed lines so the
112
+ // outer loop does not re-scan them (#606).
113
+ let continues = rest.endsWith("\\");
114
+ let j = i;
115
+ while (continues && j + 1 < lines.length) {
116
+ j++;
117
+ const crj = lines[j].endsWith("\r");
118
+ const barej = crj ? lines[j].slice(0, -1) : lines[j];
119
+ const cm = CONTINUATION_LINE_RE.exec(barej);
120
+ if (!cm) {
121
+ j--; // not a continuation line — leave it for the outer loop
122
+ break;
123
+ }
124
+ const [, cIndent, cVal] = cm;
125
+ const newVal = rewriteValuePreservingContinuation(cVal, sourceUlid, key, index, ledgerByKey);
126
+ if (newVal !== cVal) {
127
+ lines[j] = `${cIndent}${newVal}${crj ? "\r" : ""}`;
128
+ changed = true;
129
+ }
130
+ continues = cVal.endsWith("\\");
131
+ }
132
+ i = j;
103
133
  }
104
134
  return { output: lines.join("\n"), changed };
105
135
  }
136
+ /**
137
+ * Rewrite the value tokens of one trace-value line, preserving a trailing `\`
138
+ * continuation marker verbatim. The backslash is split off before token
139
+ * rewriting (so it is never mistaken for a value token) and re-appended after,
140
+ * keeping the multi-line continuation lossless.
141
+ */
142
+ function rewriteValuePreservingContinuation(value, sourceUlid, relation, index, ledgerByKey) {
143
+ const hasBackslash = value.endsWith("\\");
144
+ const core = hasBackslash ? value.slice(0, -1) : value;
145
+ const rewritten = core.replace(VALUE_TOKEN_RE, (token) => rewriteToken(token, sourceUlid, relation, index, ledgerByKey));
146
+ return hasBackslash ? `${rewritten}\\` : rewritten;
147
+ }
106
148
  function rewriteToken(token, sourceUlid, relation, index, ledgerByKey) {
107
149
  if (ULID_RE.test(token)) {
108
150
  // Rule 1: ULID → current display ID (canonicalise).
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @module core/self_upgrade/pm_detect
3
3
  *
4
- * Classify the realpath of the running binary into one of four
4
+ * Classify the realpath of the running binary into one of five
5
5
  * install-source buckets so the self-upgrade orchestrator can refuse
6
6
  * with a per-manager hint instead of fighting the package manager.
7
7
  *
8
8
  * The check is heuristic and order-sensitive — Homebrew first (because
9
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.
10
+ * cargo third, user-local fourth, system fifth. Anything that falls
11
+ * through is "unknown" and the orchestrator proceeds with a warning.
12
12
  *
13
13
  * Path matching is whole-segment (path separator on both sides) to
14
14
  * avoid matching e.g. `/foo/.localfish/markspec` against the user-local
@@ -18,7 +18,7 @@
18
18
  * brew's `/opt/homebrew/bin/markspec` -> `/opt/homebrew/Cellar/.../bin/markspec`
19
19
  * is classified correctly.
20
20
  */
21
- export type InstallSource = "user-local" | "homebrew" | "npm" | "system" | "unknown";
21
+ export type InstallSource = "user-local" | "homebrew" | "npm" | "cargo" | "system" | "unknown";
22
22
  export interface ClassifyResult {
23
23
  readonly source: InstallSource;
24
24
  readonly hintCommand?: string;
@@ -1 +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"}
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,OAAO,GACP,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,CAsDhB"}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @module core/self_upgrade/pm_detect
3
3
  *
4
- * Classify the realpath of the running binary into one of four
4
+ * Classify the realpath of the running binary into one of five
5
5
  * install-source buckets so the self-upgrade orchestrator can refuse
6
6
  * with a per-manager hint instead of fighting the package manager.
7
7
  *
8
8
  * The check is heuristic and order-sensitive — Homebrew first (because
9
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.
10
+ * cargo third, user-local fourth, system fifth. Anything that falls
11
+ * through is "unknown" and the orchestrator proceeds with a warning.
12
12
  *
13
13
  * Path matching is whole-segment (path separator on both sides) to
14
14
  * avoid matching e.g. `/foo/.localfish/markspec` against the user-local
@@ -35,17 +35,23 @@ export function classifyInstallPath(realPath, home) {
35
35
  p.includes("/.npm/")) {
36
36
  return { source: "npm", hintCommand: "npm update -g markspec" };
37
37
  }
38
- // 3. user-local paths under $HOME.
38
+ // 3. Cargo (`~/.cargo/bin`). A package-manager location like Homebrew/npm,
39
+ // so it is refused rather than overwritten — self-upgrade's rename-swap
40
+ // would leave cargo's own metadata stale (#575). Checked before the
41
+ // user-local rule, which would otherwise claim `.cargo/bin/`.
42
+ if (h && p.startsWith(`${h}/.cargo/bin/`)) {
43
+ return { source: "cargo", hintCommand: "cargo install markspec --force" };
44
+ }
45
+ // 4. user-local paths under $HOME.
39
46
  if (h && p.startsWith(`${h}/`)) {
40
47
  const tail = p.slice(h.length + 1);
41
48
  if (tail.startsWith(".local/") ||
42
- tail.startsWith(".cargo/bin/") ||
43
49
  tail.startsWith("bin/") ||
44
50
  tail.startsWith("Library/")) {
45
51
  return { source: "user-local" };
46
52
  }
47
53
  }
48
- // 4. system bins.
54
+ // 5. system bins.
49
55
  if (p.startsWith("/usr/") ||
50
56
  p.startsWith("/opt/") ||
51
57
  p.startsWith("/snap/")) {
@@ -1 +1 @@
1
- {"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AA+C9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
1
+ {"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AAsD9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
@@ -45,7 +45,12 @@ const validateEnum = (value, decl) => {
45
45
  const values = decl.values ?? [];
46
46
  if (values.includes(value))
47
47
  return null;
48
- return `value '${value}' is not in declared enum [${values.join(", ")}]`;
48
+ const base = `value '${value}' is not in declared enum [${values.join(", ")}]`;
49
+ // Case-only mismatch: the author most likely title/upper-cased a valid
50
+ // member (e.g. `Approved` → `approved`). Suggest the declared spelling
51
+ // (#215). A genuine unknown value falls through with no hint.
52
+ const match = values.find((v) => v.toLowerCase() === value.toLowerCase());
53
+ return match !== undefined ? `${base}; did you mean '${match}'?` : base;
49
54
  };
50
55
  // ---------------------------------------------------------------------------
51
56
  // Individual validators (Task 6.4 ID/URI types)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driftsys/markspec",
3
- "version": "0.7.4",
3
+ "version": "0.8.0",
4
4
  "description": "Markdown flavor and toolchain for traceable industrial documentation",
5
5
  "keywords": [
6
6
  "markdown",
package/script/mod.d.ts 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 declare const VERSION = "0.7.4";
11
+ export declare const VERSION = "0.8.0";
12
12
  export declare const CORE_SCHEMA_VERSION = 1;
13
13
  export { ConfigError, CORE_DISCIPLINE_REGISTRY, CORE_KINDS, CORE_RELATIONS, DEFAULT_PROJECT_CONFIG, descendantsOf, KNOWN_LINK_KINDS, LOCK_EXTRA_INVERSE_KEYS, makeDisplayId, makeUlid, MIXED_DISCIPLINE, PALETTE_HUES, REFHUB_URL, } from "./model/mod.js";
14
14
  export type { Attribute, BodyToken, BodyTokenKind, Caption, CaptionConventions, CaptionPosition, ConfigFieldError, Diagnostic, Directive, Discipline, DisciplineRegistry, DisplayId, EarsTrigger, EffectiveProfile, EffectiveTypeDef, EntityRefConvention, Entry, EntryShape, EntrySource, ExtractorRule, InlineRef, KindDecl, LabelConcern, LabelConcernKind, LabelValue, Link, LinkKind, LoadedProfile, ModalCase, PaletteHue, ProfileChain, ProfileConvention, ProjectConfig, ProvenancedMap, ProvenancedMapEntry, ProvenancedValue, RelationDef, Severity, SourceLocation, Ulid, } from "./model/mod.js";
package/script/mod.js CHANGED
@@ -46,7 +46,7 @@ exports.resolveReleaseEndpoints = exports.releaseAssets = exports.platformFromBu
46
46
  * from core/mod.ts, never from internal paths.
47
47
  */
48
48
  require("./_dnt.polyfills.js");
49
- exports.VERSION = "0.7.4";
49
+ exports.VERSION = "0.8.0";
50
50
  exports.CORE_SCHEMA_VERSION = 1;
51
51
  // Model types
52
52
  var mod_js_1 = require("./model/mod.js");
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAQD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAuDtC"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/refs/mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAO7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,CAGnD,CAAC;AAEH,iFAAiF;AACjF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,SAAS,KAAK,EAAE,GAAG,QAAQ,CAajE;AAcD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,SAAS,KAAK,EAAE,EACzB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA4FtC"}
@@ -48,6 +48,11 @@ function buildRefIndex(entries) {
48
48
  }
49
49
  /** Trailer trace line: indent, key, `:` + spaces, value-rest. */
50
50
  const TRACE_TRAILER_RE = /^(\s{4,})([A-Z][A-Za-z-]*)(\s*:\s*)(.*)$/;
51
+ /**
52
+ * A `\`-continuation line of a multi-line trace value: leading indent then a
53
+ * non-empty value-rest (no `Key:` — that sat on the first physical line).
54
+ */
55
+ const CONTINUATION_LINE_RE = /^(\s+)(\S.*)$/;
51
56
  /** Token splitter that preserves separators between value tokens. */
52
57
  const VALUE_TOKEN_RE = /[^\s,]+/g;
53
58
  /**
@@ -96,18 +101,55 @@ function canonicalizeRefs(content, entries, index, ledger) {
96
101
  const [, indent, key, sep, rest] = m;
97
102
  if (!exports.TRACE_ATTRIBUTE_KEYS.has(key))
98
103
  continue;
99
- // Multi-line continuation — leave untouched (debt: full multi-line support).
100
- if (rest.endsWith("\\"))
101
- continue;
102
104
  const sourceUlid = sourceUlidForLine(i + 1);
103
- const rewritten = rest.replace(VALUE_TOKEN_RE, (token) => rewriteToken(token, sourceUlid, key, index, ledgerByKey));
104
- if (rewritten !== rest) {
105
- lines[i] = `${indent}${key}${sep}${rewritten}${cr ? "\r" : ""}`;
105
+ // Rewrite the key line's value, preserving any trailing `\` continuation
106
+ // marker (only resolvable tokens change — indentation, separators and the
107
+ // backslash stay byte-for-byte).
108
+ const newRest = rewriteValuePreservingContinuation(rest, sourceUlid, key, index, ledgerByKey);
109
+ if (newRest !== rest) {
110
+ lines[i] = `${indent}${key}${sep}${newRest}${cr ? "\r" : ""}`;
106
111
  changed = true;
107
112
  }
113
+ // Multi-line value: a `\`-continued value splits across physical lines,
114
+ // each non-final line ending in `\`. Walk the continuation lines (indent +
115
+ // value, no key) and rewrite each the same way, stopping at the first line
116
+ // that does not end in `\`. `i` is advanced past the consumed lines so the
117
+ // outer loop does not re-scan them (#606).
118
+ let continues = rest.endsWith("\\");
119
+ let j = i;
120
+ while (continues && j + 1 < lines.length) {
121
+ j++;
122
+ const crj = lines[j].endsWith("\r");
123
+ const barej = crj ? lines[j].slice(0, -1) : lines[j];
124
+ const cm = CONTINUATION_LINE_RE.exec(barej);
125
+ if (!cm) {
126
+ j--; // not a continuation line — leave it for the outer loop
127
+ break;
128
+ }
129
+ const [, cIndent, cVal] = cm;
130
+ const newVal = rewriteValuePreservingContinuation(cVal, sourceUlid, key, index, ledgerByKey);
131
+ if (newVal !== cVal) {
132
+ lines[j] = `${cIndent}${newVal}${crj ? "\r" : ""}`;
133
+ changed = true;
134
+ }
135
+ continues = cVal.endsWith("\\");
136
+ }
137
+ i = j;
108
138
  }
109
139
  return { output: lines.join("\n"), changed };
110
140
  }
141
+ /**
142
+ * Rewrite the value tokens of one trace-value line, preserving a trailing `\`
143
+ * continuation marker verbatim. The backslash is split off before token
144
+ * rewriting (so it is never mistaken for a value token) and re-appended after,
145
+ * keeping the multi-line continuation lossless.
146
+ */
147
+ function rewriteValuePreservingContinuation(value, sourceUlid, relation, index, ledgerByKey) {
148
+ const hasBackslash = value.endsWith("\\");
149
+ const core = hasBackslash ? value.slice(0, -1) : value;
150
+ const rewritten = core.replace(VALUE_TOKEN_RE, (token) => rewriteToken(token, sourceUlid, relation, index, ledgerByKey));
151
+ return hasBackslash ? `${rewritten}\\` : rewritten;
152
+ }
111
153
  function rewriteToken(token, sourceUlid, relation, index, ledgerByKey) {
112
154
  if (mod_js_1.ULID_RE.test(token)) {
113
155
  // Rule 1: ULID → current display ID (canonicalise).
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @module core/self_upgrade/pm_detect
3
3
  *
4
- * Classify the realpath of the running binary into one of four
4
+ * Classify the realpath of the running binary into one of five
5
5
  * install-source buckets so the self-upgrade orchestrator can refuse
6
6
  * with a per-manager hint instead of fighting the package manager.
7
7
  *
8
8
  * The check is heuristic and order-sensitive — Homebrew first (because
9
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.
10
+ * cargo third, user-local fourth, system fifth. Anything that falls
11
+ * through is "unknown" and the orchestrator proceeds with a warning.
12
12
  *
13
13
  * Path matching is whole-segment (path separator on both sides) to
14
14
  * avoid matching e.g. `/foo/.localfish/markspec` against the user-local
@@ -18,7 +18,7 @@
18
18
  * brew's `/opt/homebrew/bin/markspec` -> `/opt/homebrew/Cellar/.../bin/markspec`
19
19
  * is classified correctly.
20
20
  */
21
- export type InstallSource = "user-local" | "homebrew" | "npm" | "system" | "unknown";
21
+ export type InstallSource = "user-local" | "homebrew" | "npm" | "cargo" | "system" | "unknown";
22
22
  export interface ClassifyResult {
23
23
  readonly source: InstallSource;
24
24
  readonly hintCommand?: string;
@@ -1 +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"}
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,OAAO,GACP,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,CAsDhB"}
@@ -2,14 +2,14 @@
2
2
  /**
3
3
  * @module core/self_upgrade/pm_detect
4
4
  *
5
- * Classify the realpath of the running binary into one of four
5
+ * Classify the realpath of the running binary into one of five
6
6
  * install-source buckets so the self-upgrade orchestrator can refuse
7
7
  * with a per-manager hint instead of fighting the package manager.
8
8
  *
9
9
  * The check is heuristic and order-sensitive — Homebrew first (because
10
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.
11
+ * cargo third, user-local fourth, system fifth. Anything that falls
12
+ * through is "unknown" and the orchestrator proceeds with a warning.
13
13
  *
14
14
  * Path matching is whole-segment (path separator on both sides) to
15
15
  * avoid matching e.g. `/foo/.localfish/markspec` against the user-local
@@ -38,17 +38,23 @@ function classifyInstallPath(realPath, home) {
38
38
  p.includes("/.npm/")) {
39
39
  return { source: "npm", hintCommand: "npm update -g markspec" };
40
40
  }
41
- // 3. user-local paths under $HOME.
41
+ // 3. Cargo (`~/.cargo/bin`). A package-manager location like Homebrew/npm,
42
+ // so it is refused rather than overwritten — self-upgrade's rename-swap
43
+ // would leave cargo's own metadata stale (#575). Checked before the
44
+ // user-local rule, which would otherwise claim `.cargo/bin/`.
45
+ if (h && p.startsWith(`${h}/.cargo/bin/`)) {
46
+ return { source: "cargo", hintCommand: "cargo install markspec --force" };
47
+ }
48
+ // 4. user-local paths under $HOME.
42
49
  if (h && p.startsWith(`${h}/`)) {
43
50
  const tail = p.slice(h.length + 1);
44
51
  if (tail.startsWith(".local/") ||
45
- tail.startsWith(".cargo/bin/") ||
46
52
  tail.startsWith("bin/") ||
47
53
  tail.startsWith("Library/")) {
48
54
  return { source: "user-local" };
49
55
  }
50
56
  }
51
- // 4. system bins.
57
+ // 5. system bins.
52
58
  if (p.startsWith("/usr/") ||
53
59
  p.startsWith("/opt/") ||
54
60
  p.startsWith("/snap/")) {
@@ -1 +1 @@
1
- {"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AA+C9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
1
+ {"version":3,"file":"value_types.d.ts","sourceRoot":"","sources":["../../src/validator/value_types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AAG3D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAG1E;AAED,mDAAmD;AACnD,MAAM,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,KAAK,MAAM,GAAG,IAAI,CAAC;AAsD9E;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,QAAiB,CAAC"}
@@ -49,7 +49,12 @@ const validateEnum = (value, decl) => {
49
49
  const values = decl.values ?? [];
50
50
  if (values.includes(value))
51
51
  return null;
52
- return `value '${value}' is not in declared enum [${values.join(", ")}]`;
52
+ const base = `value '${value}' is not in declared enum [${values.join(", ")}]`;
53
+ // Case-only mismatch: the author most likely title/upper-cased a valid
54
+ // member (e.g. `Approved` → `approved`). Suggest the declared spelling
55
+ // (#215). A genuine unknown value falls through with no hint.
56
+ const match = values.find((v) => v.toLowerCase() === value.toLowerCase());
57
+ return match !== undefined ? `${base}; did you mean '${match}'?` : base;
53
58
  };
54
59
  // ---------------------------------------------------------------------------
55
60
  // Individual validators (Task 6.4 ID/URI types)