@driftsys/markspec 0.10.1 → 0.10.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.
- package/esm/collect/mod.d.ts +34 -0
- package/esm/collect/mod.d.ts.map +1 -0
- package/esm/collect/mod.js +37 -0
- package/esm/formatter/mod.d.ts.map +1 -1
- package/esm/formatter/mod.js +29 -1
- package/esm/gates/mod.d.ts +82 -0
- package/esm/gates/mod.d.ts.map +1 -0
- package/esm/gates/mod.js +139 -0
- package/esm/lint/runner.d.ts +26 -3
- package/esm/lint/runner.d.ts.map +1 -1
- package/esm/lint/runner.js +39 -9
- package/esm/lock/edge_drift.d.ts +31 -0
- package/esm/lock/edge_drift.d.ts.map +1 -0
- package/esm/lock/edge_drift.js +29 -0
- package/esm/lock/mod.d.ts +2 -0
- package/esm/lock/mod.d.ts.map +1 -1
- package/esm/lock/mod.js +1 -0
- package/esm/mod.d.ts +11 -6
- package/esm/mod.d.ts.map +1 -1
- package/esm/mod.js +10 -4
- package/esm/model/mod.d.ts +8 -0
- package/esm/model/mod.d.ts.map +1 -1
- package/esm/model/mod.js +10 -0
- package/esm/model/profile.d.ts +8 -0
- package/esm/model/profile.d.ts.map +1 -1
- package/esm/parser/markdown.d.ts.map +1 -1
- package/esm/parser/markdown.js +38 -11
- package/esm/profile/delivered.d.ts +22 -1
- package/esm/profile/delivered.d.ts.map +1 -1
- package/esm/profile/delivered.js +44 -1
- package/esm/profile/merge.js +1 -0
- package/esm/reporter/mod.d.ts.map +1 -1
- package/esm/reporter/mod.js +2 -3
- package/esm/util/fence.d.ts +8 -0
- package/esm/util/fence.d.ts.map +1 -1
- package/esm/util/fence.js +22 -0
- package/esm/validator/corpus.d.ts.map +1 -1
- package/esm/validator/corpus.js +14 -12
- package/package.json +1 -1
- package/script/collect/mod.d.ts +34 -0
- package/script/collect/mod.d.ts.map +1 -0
- package/script/collect/mod.js +40 -0
- package/script/formatter/mod.d.ts.map +1 -1
- package/script/formatter/mod.js +29 -1
- package/script/gates/mod.d.ts +82 -0
- package/script/gates/mod.d.ts.map +1 -0
- package/script/gates/mod.js +144 -0
- package/script/lint/runner.d.ts +26 -3
- package/script/lint/runner.d.ts.map +1 -1
- package/script/lint/runner.js +39 -9
- package/script/lock/edge_drift.d.ts +31 -0
- package/script/lock/edge_drift.d.ts.map +1 -0
- package/script/lock/edge_drift.js +32 -0
- package/script/lock/mod.d.ts +2 -0
- package/script/lock/mod.d.ts.map +1 -1
- package/script/lock/mod.js +3 -1
- package/script/mod.d.ts +11 -6
- package/script/mod.d.ts.map +1 -1
- package/script/mod.js +45 -29
- package/script/model/mod.d.ts +8 -0
- package/script/model/mod.d.ts.map +1 -1
- package/script/model/mod.js +11 -0
- package/script/model/profile.d.ts +8 -0
- package/script/model/profile.d.ts.map +1 -1
- package/script/parser/markdown.d.ts.map +1 -1
- package/script/parser/markdown.js +38 -11
- package/script/profile/delivered.d.ts +22 -1
- package/script/profile/delivered.d.ts.map +1 -1
- package/script/profile/delivered.js +45 -1
- package/script/profile/merge.js +1 -0
- package/script/reporter/mod.d.ts.map +1 -1
- package/script/reporter/mod.js +2 -3
- package/script/util/fence.d.ts +8 -0
- package/script/util/fence.d.ts.map +1 -1
- package/script/util/fence.js +23 -0
- package/script/validator/corpus.d.ts.map +1 -1
- package/script/validator/corpus.js +14 -12
|
@@ -11,6 +11,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
11
11
|
exports.corpusOriginLabel = corpusOriginLabel;
|
|
12
12
|
exports.buildCorpusIndex = buildCorpusIndex;
|
|
13
13
|
exports.loadDeliveredCorpus = loadDeliveredCorpus;
|
|
14
|
+
exports.deliveredPathIsContained = deliveredPathIsContained;
|
|
15
|
+
const path_1 = require("@std/path");
|
|
14
16
|
const mod_js_1 = require("../parser/mod.js");
|
|
15
17
|
/** Human-facing label of a delivered document's providing tier. */
|
|
16
18
|
function corpusOriginLabel(doc) {
|
|
@@ -29,10 +31,21 @@ function buildCorpusIndex(delivers) {
|
|
|
29
31
|
* `delivers` in order (parent-first + manifest order — the deterministic
|
|
30
32
|
* injection order), so the returned entry order is stable across runs.
|
|
31
33
|
*/
|
|
32
|
-
async function loadDeliveredCorpus(delivers, readFile) {
|
|
34
|
+
async function loadDeliveredCorpus(delivers, readFile, realPath) {
|
|
33
35
|
const entries = [];
|
|
34
36
|
const diagnostics = [];
|
|
35
37
|
for (const doc of delivers) {
|
|
38
|
+
if (realPath && !(await deliveredPathIsContained(doc, realPath))) {
|
|
39
|
+
diagnostics.push({
|
|
40
|
+
code: "PROFILE-DELIVERS-005",
|
|
41
|
+
severity: "error",
|
|
42
|
+
message: `delivered ${doc.corpus ? "corpus" : "document"} file ` +
|
|
43
|
+
`'${doc.path}' declared by ${corpusOriginLabel(doc)} resolves ` +
|
|
44
|
+
`outside the profile package (symlink escape) and was not read`,
|
|
45
|
+
location: { file: doc.absPath, line: 1, column: 1 },
|
|
46
|
+
});
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
36
49
|
const content = await readFile(doc.absPath);
|
|
37
50
|
if (content === undefined) {
|
|
38
51
|
diagnostics.push({
|
|
@@ -63,3 +76,34 @@ async function loadDeliveredCorpus(delivers, readFile) {
|
|
|
63
76
|
}
|
|
64
77
|
return { entries, diagnostics };
|
|
65
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* True when `doc`'s real (symlink-resolved) path stays within its profile's
|
|
81
|
+
* `baseDir` — the delivered-path containment guard (#699). A malicious profile
|
|
82
|
+
* (pulled via `extends: git+…`, which preserves symlinks) can deliver a `.md`
|
|
83
|
+
* that is actually a symlink to an arbitrary local file (`~/.ssh/id_rsa`); the
|
|
84
|
+
* string-level path checks (PROFILE-DELIVERS-003/004) validate the declared
|
|
85
|
+
* path, not the symlink target, so a real-path containment check is the only
|
|
86
|
+
* thing that stops the read.
|
|
87
|
+
*
|
|
88
|
+
* Degrades to `true` (allow) when the doc carries no `baseDir` or when the
|
|
89
|
+
* paths cannot be canonicalised (e.g. the file is missing) — a missing file is
|
|
90
|
+
* left to the existing PROFILE-DELIVERS-001/002 checks. Shared by the MCP
|
|
91
|
+
* `readDeliveredDocument` read path, which faces the same vector.
|
|
92
|
+
*/
|
|
93
|
+
async function deliveredPathIsContained(doc, realPath) {
|
|
94
|
+
if (doc.baseDir === undefined)
|
|
95
|
+
return true;
|
|
96
|
+
let realBase;
|
|
97
|
+
let realTarget;
|
|
98
|
+
try {
|
|
99
|
+
realBase = await realPath(doc.baseDir);
|
|
100
|
+
realTarget = await realPath(doc.absPath);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return true; // unresolvable (e.g. missing) — handled by 001/002 downstream
|
|
104
|
+
}
|
|
105
|
+
if (realTarget === realBase)
|
|
106
|
+
return true;
|
|
107
|
+
const prefix = realBase.endsWith(path_1.SEPARATOR) ? realBase : realBase + path_1.SEPARATOR;
|
|
108
|
+
return realTarget.startsWith(prefix);
|
|
109
|
+
}
|
package/script/profile/merge.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/reporter/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../src/reporter/mod.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG,UAAU,CAAC;AAErD,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,MAAM,GAAG,KAAK,CAAC;AAEjD,sCAAsC;AACtC,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,qBAAqB;IACrB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,2DAA2D;IAC3D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,qCAAqC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,CAO5E"}
|
package/script/reporter/mod.js
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.report = report;
|
|
10
|
+
const mod_js_1 = require("../model/mod.js");
|
|
10
11
|
/**
|
|
11
12
|
* Generate a report from compiled traceability graph.
|
|
12
13
|
*
|
|
@@ -52,9 +53,7 @@ function filterEntries(result, scope, label) {
|
|
|
52
53
|
* Markdown, and JSON rows all agree on the same value.
|
|
53
54
|
*/
|
|
54
55
|
function originCell(entry) {
|
|
55
|
-
return entry.origin
|
|
56
|
-
? `${entry.origin.profileId}@${entry.origin.profileVersion}`
|
|
57
|
-
: "project";
|
|
56
|
+
return entry.origin ? (0, mod_js_1.formatEntryOrigin)(entry.origin) : "project";
|
|
58
57
|
}
|
|
59
58
|
function buildTraceRows(result, entries) {
|
|
60
59
|
return entries.map((entry) => {
|
package/script/util/fence.d.ts
CHANGED
|
@@ -27,4 +27,12 @@ export type ProseLineCallback = (line: string, index: number) => void;
|
|
|
27
27
|
* skipped (they're structural, not prose).
|
|
28
28
|
*/
|
|
29
29
|
export declare function walkProseLines(body: string, cb: ProseLineCallback): void;
|
|
30
|
+
/**
|
|
31
|
+
* Return whether `lineIndex` (0-based) is a line {@linkcode walkProseLines}
|
|
32
|
+
* would skip — either a fence-marker line itself, or content inside a
|
|
33
|
+
* fenced block. Single-line-membership counterpart to `walkProseLines`'s
|
|
34
|
+
* full-body callback walk, for callers that only need a yes/no answer for
|
|
35
|
+
* one position (e.g. an LSP request gating a cursor position, #680).
|
|
36
|
+
*/
|
|
37
|
+
export declare function isLineFenced(body: string, lineIndex: number): boolean;
|
|
30
38
|
//# sourceMappingURL=fence.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/util/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,QAAQ,QAAkB,CAAC;AAExC,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAYxE"}
|
|
1
|
+
{"version":3,"file":"fence.d.ts","sourceRoot":"","sources":["../../src/util/fence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,gEAAgE;AAChE,eAAO,MAAM,QAAQ,QAAkB,CAAC;AAExC,sFAAsF;AACtF,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,iBAAiB,GAAG,IAAI,CAYxE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAYrE"}
|
package/script/util/fence.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.FENCE_RE = void 0;
|
|
22
22
|
exports.walkProseLines = walkProseLines;
|
|
23
|
+
exports.isLineFenced = isLineFenced;
|
|
23
24
|
/** Three or more backticks or tildes at the start of a line. */
|
|
24
25
|
exports.FENCE_RE = /^\s*(```|~~~)/;
|
|
25
26
|
/**
|
|
@@ -42,3 +43,25 @@ function walkProseLines(body, cb) {
|
|
|
42
43
|
cb(line, i);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Return whether `lineIndex` (0-based) is a line {@linkcode walkProseLines}
|
|
48
|
+
* would skip — either a fence-marker line itself, or content inside a
|
|
49
|
+
* fenced block. Single-line-membership counterpart to `walkProseLines`'s
|
|
50
|
+
* full-body callback walk, for callers that only need a yes/no answer for
|
|
51
|
+
* one position (e.g. an LSP request gating a cursor position, #680).
|
|
52
|
+
*/
|
|
53
|
+
function isLineFenced(body, lineIndex) {
|
|
54
|
+
const lines = body.split("\n");
|
|
55
|
+
let inFence = false;
|
|
56
|
+
for (let i = 0; i <= lineIndex && i < lines.length; i++) {
|
|
57
|
+
if (exports.FENCE_RE.test(lines[i])) {
|
|
58
|
+
inFence = !inFence;
|
|
59
|
+
if (i === lineIndex)
|
|
60
|
+
return true;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (i === lineIndex)
|
|
64
|
+
return inFence;
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/validator/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"corpus.d.ts","sourceRoot":"","sources":["../../src/validator/corpus.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAWzD,oDAAoD;AACpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAC;IAC5C,qEAAqE;IACrE,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9C;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,SAAS,KAAK,EAAE,GAC3B,qBAAqB,CAoFvB;AAED,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,SAAS,UAAU,EAAE,EAClC,UAAU,EAAE,SAAS,KAAK,EAAE,EAC5B,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAClC,UAAU,EAAE,CAmCd"}
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.detectCorpusCollisions = detectCorpusCollisions;
|
|
19
19
|
exports.attributeCorpusDiagnostics = attributeCorpusDiagnostics;
|
|
20
|
+
const mod_js_1 = require("../model/mod.js");
|
|
20
21
|
/** Generic duplicate detectors superseded by MSL-R014 for corpus collisions. */
|
|
21
22
|
const GENERIC_DUP_CODES = new Set([
|
|
22
23
|
"MSL-R005",
|
|
@@ -50,8 +51,7 @@ function detectCorpusCollisions(allEntries) {
|
|
|
50
51
|
code: "MSL-R014",
|
|
51
52
|
severity: "error",
|
|
52
53
|
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
53
|
-
`${displayOwner.origin
|
|
54
|
-
`${displayOwner.origin.profileVersion}; rename this entry — ` +
|
|
54
|
+
`${(0, mod_js_1.formatEntryOrigin)(displayOwner.origin)}; rename this entry — ` +
|
|
55
55
|
`delivered corpus entries are read-only`,
|
|
56
56
|
location: e.location,
|
|
57
57
|
});
|
|
@@ -64,8 +64,7 @@ function detectCorpusCollisions(allEntries) {
|
|
|
64
64
|
code: "MSL-R014",
|
|
65
65
|
severity: "error",
|
|
66
66
|
message: `Id '${e.id}' is already delivered by ` +
|
|
67
|
-
`${idOwner.origin
|
|
68
|
-
`${idOwner.origin.profileVersion}; rename this entry — ` +
|
|
67
|
+
`${(0, mod_js_1.formatEntryOrigin)(idOwner.origin)}; rename this entry — ` +
|
|
69
68
|
`delivered corpus entries are read-only`,
|
|
70
69
|
location: e.location,
|
|
71
70
|
});
|
|
@@ -86,8 +85,7 @@ function detectCorpusCollisions(allEntries) {
|
|
|
86
85
|
code: "MSL-R014",
|
|
87
86
|
severity: "error",
|
|
88
87
|
message: `display ID '${e.displayId}' is already delivered by ` +
|
|
89
|
-
`${displayOwner.origin
|
|
90
|
-
`${displayOwner.origin.profileVersion}; delivered corpus ` +
|
|
88
|
+
`${(0, mod_js_1.formatEntryOrigin)(displayOwner.origin)}; delivered corpus ` +
|
|
91
89
|
`entries are read-only`,
|
|
92
90
|
location: e.location,
|
|
93
91
|
});
|
|
@@ -101,8 +99,7 @@ function detectCorpusCollisions(allEntries) {
|
|
|
101
99
|
code: "MSL-R014",
|
|
102
100
|
severity: "error",
|
|
103
101
|
message: `Id '${e.id}' is already delivered by ` +
|
|
104
|
-
`${idOwner.origin
|
|
105
|
-
`${idOwner.origin.profileVersion}; delivered corpus entries ` +
|
|
102
|
+
`${(0, mod_js_1.formatEntryOrigin)(idOwner.origin)}; delivered corpus entries ` +
|
|
106
103
|
`are read-only`,
|
|
107
104
|
location: e.location,
|
|
108
105
|
});
|
|
@@ -115,14 +112,19 @@ function attributeCorpusDiagnostics(diagnostics, allEntries, collidedTokens) {
|
|
|
115
112
|
const corpusFiles = new Map();
|
|
116
113
|
for (const e of allEntries) {
|
|
117
114
|
if (e.origin) {
|
|
118
|
-
corpusFiles.set(e.location.file,
|
|
115
|
+
corpusFiles.set(e.location.file, (0, mod_js_1.formatEntryOrigin)(e.origin));
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
const out = [];
|
|
122
119
|
for (const d of diagnostics) {
|
|
123
|
-
// Suppress the generic duplicate codes for corpus
|
|
124
|
-
//
|
|
125
|
-
//
|
|
120
|
+
// Suppress the generic duplicate codes for a corpus collision (MSL-R014
|
|
121
|
+
// has already replaced them). This is a load-bearing coupling with the
|
|
122
|
+
// duplicate validators' message format: MSL-R005/R006/I007/I008 all embed
|
|
123
|
+
// the offending token wrapped in single quotes (`'<token>'`), and the
|
|
124
|
+
// containment check below keys on that exact `'${t}'` shape. If any of
|
|
125
|
+
// those producers stops single-quoting the token, the generic duplicate
|
|
126
|
+
// would leak through alongside the MSL-R014 — `corpus_test.ts` pins all
|
|
127
|
+
// four codes to this contract.
|
|
126
128
|
if (GENERIC_DUP_CODES.has(d.code) &&
|
|
127
129
|
[...collidedTokens].some((t) => d.message.includes(`'${t}'`))) {
|
|
128
130
|
continue;
|