@commentray/core 0.0.1 → 0.0.4
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/dist/anchors.d.ts +6 -0
- package/dist/anchors.d.ts.map +1 -1
- package/dist/anchors.js +11 -0
- package/dist/anchors.js.map +1 -1
- package/dist/angles-toml.d.ts +18 -0
- package/dist/angles-toml.d.ts.map +1 -0
- package/dist/angles-toml.js +62 -0
- package/dist/angles-toml.js.map +1 -0
- package/dist/angles.d.ts +6 -0
- package/dist/angles.d.ts.map +1 -0
- package/dist/angles.js +14 -0
- package/dist/angles.js.map +1 -0
- package/dist/block-scroll-pickers.d.ts +22 -0
- package/dist/block-scroll-pickers.d.ts.map +1 -0
- package/dist/block-scroll-pickers.js +41 -0
- package/dist/block-scroll-pickers.js.map +1 -0
- package/dist/block-snippet.d.ts +13 -0
- package/dist/block-snippet.d.ts.map +1 -0
- package/dist/block-snippet.js +30 -0
- package/dist/block-snippet.js.map +1 -0
- package/dist/blocks.d.ts +66 -0
- package/dist/blocks.d.ts.map +1 -0
- package/dist/blocks.js +101 -0
- package/dist/blocks.js.map +1 -0
- package/dist/commentray-index-renames.d.ts +21 -0
- package/dist/commentray-index-renames.d.ts.map +1 -0
- package/dist/commentray-index-renames.js +85 -0
- package/dist/commentray-index-renames.js.map +1 -0
- package/dist/commentray-path-resolution.d.ts +20 -0
- package/dist/commentray-path-resolution.d.ts.map +1 -0
- package/dist/commentray-path-resolution.js +38 -0
- package/dist/commentray-path-resolution.js.map +1 -0
- package/dist/config.d.ts +48 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +72 -6
- package/dist/config.js.map +1 -1
- package/dist/github-url.d.ts +14 -0
- package/dist/github-url.d.ts.map +1 -0
- package/dist/github-url.js +25 -0
- package/dist/github-url.js.map +1 -0
- package/dist/index-normalize.d.ts +10 -0
- package/dist/index-normalize.d.ts.map +1 -0
- package/dist/index-normalize.js +60 -0
- package/dist/index-normalize.js.map +1 -0
- package/dist/index-schema-messages.d.ts +6 -0
- package/dist/index-schema-messages.d.ts.map +1 -0
- package/dist/index-schema-messages.js +26 -0
- package/dist/index-schema-messages.js.map +1 -0
- package/dist/index.d.ts +25 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -4
- package/dist/index.js.map +1 -1
- package/dist/marker-ids.d.ts +19 -0
- package/dist/marker-ids.d.ts.map +1 -0
- package/dist/marker-ids.js +38 -0
- package/dist/marker-ids.js.map +1 -0
- package/dist/marker-validation.d.ts +22 -0
- package/dist/marker-validation.d.ts.map +1 -0
- package/dist/marker-validation.js +138 -0
- package/dist/marker-validation.js.map +1 -0
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +84 -29
- package/dist/metadata.js.map +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +52 -14
- package/dist/migrate.js.map +1 -1
- package/dist/model.d.ts +24 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +17 -1
- package/dist/model.js.map +1 -1
- package/dist/paths.d.ts +18 -2
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +34 -3
- package/dist/paths.js.map +1 -1
- package/dist/region-marker-convert.d.ts +27 -0
- package/dist/region-marker-convert.d.ts.map +1 -0
- package/dist/region-marker-convert.js +78 -0
- package/dist/region-marker-convert.js.map +1 -0
- package/dist/scm/git-scm-provider.d.ts +7 -1
- package/dist/scm/git-scm-provider.d.ts.map +1 -1
- package/dist/scm/git-scm-provider.js +42 -0
- package/dist/scm/git-scm-provider.js.map +1 -1
- package/dist/scm/scm-provider.d.ts +10 -0
- package/dist/scm/scm-provider.d.ts.map +1 -1
- package/dist/scroll-sync.d.ts +12 -0
- package/dist/scroll-sync.d.ts.map +1 -0
- package/dist/scroll-sync.js +59 -0
- package/dist/scroll-sync.js.map +1 -0
- package/dist/source-markers.d.ts +28 -0
- package/dist/source-markers.d.ts.map +1 -0
- package/dist/source-markers.js +241 -0
- package/dist/source-markers.js.map +1 -0
- package/dist/validate-project.d.ts +15 -1
- package/dist/validate-project.d.ts.map +1 -1
- package/dist/validate-project.js +87 -14
- package/dist/validate-project.js.map +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker / block ids used in `marker:<id>` anchors, `markerId` in the index, and
|
|
3
|
+
* `commentray:<id>` / `commentray:start id=<id>` in source. Designed so authors
|
|
4
|
+
* can type **short slugs** (`intro`, `auth-flow`, `todo_1`) while tooling stays strict.
|
|
5
|
+
*/
|
|
6
|
+
/** Body: 1–64 chars, ASCII letters, digits, hyphen, underscore; must not be empty after trim. */
|
|
7
|
+
export const MARKER_ID_BODY = "[a-z0-9][a-z0-9_-]{0,63}";
|
|
8
|
+
const MARKER_ID_RE = new RegExp(`^${MARKER_ID_BODY}$`, "i");
|
|
9
|
+
/**
|
|
10
|
+
* Validates and returns the normalised (lower-case) marker id, or throws with a
|
|
11
|
+
* message suitable for CLI / editor output.
|
|
12
|
+
*/
|
|
13
|
+
export function assertValidMarkerId(raw) {
|
|
14
|
+
const id = raw.trim().toLowerCase();
|
|
15
|
+
if (!MARKER_ID_RE.test(id)) {
|
|
16
|
+
throw new Error(`Invalid marker id "${raw}". Use 1–64 characters: a–z, 0–9, hyphen (-), underscore (_); ` +
|
|
17
|
+
`must start with a letter or digit. Examples: intro, auth-flow, block_01, a3f9k2`);
|
|
18
|
+
}
|
|
19
|
+
return id;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Turns free-form author input into a valid marker id when possible: lower-case,
|
|
23
|
+
* spaces → hyphens, strips other punctuation. Throws if the result is empty or
|
|
24
|
+
* still invalid — callers may fall back to {@link generateBlockId} from `blocks.js`.
|
|
25
|
+
*/
|
|
26
|
+
export function normaliseMarkerSlugOrThrow(raw) {
|
|
27
|
+
const slug = raw
|
|
28
|
+
.trim()
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/\s+/g, "-")
|
|
31
|
+
.replace(/[^a-z0-9_-]+/g, "")
|
|
32
|
+
.replace(/-+/g, "-")
|
|
33
|
+
.replace(/_+/g, "_")
|
|
34
|
+
.replace(/^-+|-+$/g, "")
|
|
35
|
+
.replace(/^_|_$/g, "");
|
|
36
|
+
return assertValidMarkerId(slug);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=marker-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-ids.js","sourceRoot":"","sources":["../src/marker-ids.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iGAAiG;AACjG,MAAM,CAAC,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAEzD,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,IAAI,cAAc,GAAG,EAAE,GAAG,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACpC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,sBAAsB,GAAG,gEAAgE;YACvF,iFAAiF,CACpF,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,GAAW;IACpD,MAAM,IAAI,GAAG,GAAG;SACb,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC5B,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACzB,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CommentrayIndex } from "./model.js";
|
|
2
|
+
export type MarkerValidationIssue = {
|
|
3
|
+
level: "error" | "warn";
|
|
4
|
+
message: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Scans a single source file for Commentray region / marker boundaries and reports:
|
|
8
|
+
* - invalid ids (syntax that matched but fails `assertValidMarkerId` — rare),
|
|
9
|
+
* - duplicate **start** for the same id before its `end`,
|
|
10
|
+
* - orphan **end** lines,
|
|
11
|
+
* - **start** without a matching **end** (unclosed region).
|
|
12
|
+
*/
|
|
13
|
+
export declare function validateMarkerBoundariesInSource(sourceText: string, sourcePath: string): MarkerValidationIssue[];
|
|
14
|
+
/**
|
|
15
|
+
* Index-level rules for stable cross-references:
|
|
16
|
+
* - **Error** if the same `(sourcePath, marker id)` is claimed by **different** block `id`s
|
|
17
|
+
* (e.g. two Angle files disagree).
|
|
18
|
+
* - **Warn** if the same marker id string is reused across **different** source files
|
|
19
|
+
* (repo-wide ambiguity for links and search — allowed, but noisy).
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateIndexMarkerSemantics(index: CommentrayIndex): MarkerValidationIssue[];
|
|
22
|
+
//# sourceMappingURL=marker-validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-validation.d.ts","sourceRoot":"","sources":["../src/marker-validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,MAAM,qBAAqB,GAAG;IAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,qBAAqB,EAAE,CAkDzB;AAmBD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,eAAe,GAAG,qBAAqB,EAAE,CAuD5F"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { parseAnchor } from "./anchors.js";
|
|
2
|
+
import { assertValidMarkerId } from "./marker-ids.js";
|
|
3
|
+
import { parseCommentrayRegionBoundary } from "./source-markers.js";
|
|
4
|
+
/**
|
|
5
|
+
* Scans a single source file for Commentray region / marker boundaries and reports:
|
|
6
|
+
* - invalid ids (syntax that matched but fails `assertValidMarkerId` — rare),
|
|
7
|
+
* - duplicate **start** for the same id before its `end`,
|
|
8
|
+
* - orphan **end** lines,
|
|
9
|
+
* - **start** without a matching **end** (unclosed region).
|
|
10
|
+
*/
|
|
11
|
+
export function validateMarkerBoundariesInSource(sourceText, sourcePath) {
|
|
12
|
+
const issues = [];
|
|
13
|
+
const lines = sourceText.replaceAll("\r\n", "\n").split("\n");
|
|
14
|
+
const pendingStartLine = new Map();
|
|
15
|
+
for (let line0 = 0; line0 < lines.length; line0++) {
|
|
16
|
+
const hit = parseCommentrayRegionBoundary(lines[line0] ?? "");
|
|
17
|
+
if (!hit)
|
|
18
|
+
continue;
|
|
19
|
+
try {
|
|
20
|
+
assertValidMarkerId(hit.id);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
issues.push({
|
|
24
|
+
level: "error",
|
|
25
|
+
message: `${sourcePath}:${line0 + 1}: ${e instanceof Error ? e.message : String(e)}`,
|
|
26
|
+
});
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
const loc = `${sourcePath}:${line0 + 1}`;
|
|
30
|
+
if (hit.kind === "start") {
|
|
31
|
+
const priorStart = pendingStartLine.get(hit.id);
|
|
32
|
+
if (priorStart !== undefined) {
|
|
33
|
+
const prev = priorStart + 1;
|
|
34
|
+
issues.push({
|
|
35
|
+
level: "error",
|
|
36
|
+
message: `${loc}: duplicate commentray start for id "${hit.id}" (also opened at line ${prev}). Close the previous region first, or use a unique id per region.`,
|
|
37
|
+
});
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
pendingStartLine.set(hit.id, line0);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const start0 = pendingStartLine.get(hit.id);
|
|
44
|
+
if (start0 === undefined) {
|
|
45
|
+
issues.push({
|
|
46
|
+
level: "error",
|
|
47
|
+
message: `${loc}: commentray end for id "${hit.id}" has no matching start in this file.`,
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
pendingStartLine.delete(hit.id);
|
|
52
|
+
}
|
|
53
|
+
for (const [id, line0] of pendingStartLine) {
|
|
54
|
+
issues.push({
|
|
55
|
+
level: "error",
|
|
56
|
+
message: `${sourcePath}:${line0 + 1}: commentray start for id "${id}" has no matching end in this file.`,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return issues;
|
|
60
|
+
}
|
|
61
|
+
function markerIdFromBlock(block) {
|
|
62
|
+
try {
|
|
63
|
+
const a = parseAnchor(block.anchor);
|
|
64
|
+
if (a.kind === "marker")
|
|
65
|
+
return a.id;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (typeof block.markerId === "string" && block.markerId.trim() !== "") {
|
|
71
|
+
try {
|
|
72
|
+
return assertValidMarkerId(block.markerId);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Index-level rules for stable cross-references:
|
|
82
|
+
* - **Error** if the same `(sourcePath, marker id)` is claimed by **different** block `id`s
|
|
83
|
+
* (e.g. two Angle files disagree).
|
|
84
|
+
* - **Warn** if the same marker id string is reused across **different** source files
|
|
85
|
+
* (repo-wide ambiguity for links and search — allowed, but noisy).
|
|
86
|
+
*/
|
|
87
|
+
export function validateIndexMarkerSemantics(index) {
|
|
88
|
+
const issues = [];
|
|
89
|
+
const bySourceAndMarker = new Map();
|
|
90
|
+
const byMarkerRepoWide = new Map();
|
|
91
|
+
for (const [commentrayPath, entry] of Object.entries(index.byCommentrayPath)) {
|
|
92
|
+
for (const block of entry.blocks) {
|
|
93
|
+
const mid = markerIdFromBlock(block);
|
|
94
|
+
if (mid === null)
|
|
95
|
+
continue;
|
|
96
|
+
const key = `${entry.sourcePath}\0${mid}`;
|
|
97
|
+
const loc = {
|
|
98
|
+
sourcePath: entry.sourcePath,
|
|
99
|
+
commentrayPath,
|
|
100
|
+
blockId: block.id,
|
|
101
|
+
};
|
|
102
|
+
const list = bySourceAndMarker.get(key) ?? [];
|
|
103
|
+
list.push(loc);
|
|
104
|
+
bySourceAndMarker.set(key, list);
|
|
105
|
+
const sources = byMarkerRepoWide.get(mid) ?? new Set();
|
|
106
|
+
sources.add(entry.sourcePath);
|
|
107
|
+
byMarkerRepoWide.set(mid, sources);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
for (const [composite, locs] of bySourceAndMarker) {
|
|
111
|
+
if (locs.length < 2)
|
|
112
|
+
continue;
|
|
113
|
+
const sep = composite.indexOf("\0");
|
|
114
|
+
const sourcePath = composite.slice(0, sep);
|
|
115
|
+
const mid = composite.slice(sep + 1);
|
|
116
|
+
const blockIds = new Set(locs.map((l) => l.blockId));
|
|
117
|
+
if (blockIds.size > 1) {
|
|
118
|
+
const detail = locs.map((l) => `${l.blockId} (${l.commentrayPath})`).join(", ");
|
|
119
|
+
issues.push({
|
|
120
|
+
level: "error",
|
|
121
|
+
message: `Marker id "${mid}" for source "${sourcePath}" is indexed with different block ids: ${detail}. ` +
|
|
122
|
+
`One physical region should map to one block id (e.g. align Angle files or deduplicate).`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const [mid, sources] of byMarkerRepoWide) {
|
|
127
|
+
if (sources.size <= 1)
|
|
128
|
+
continue;
|
|
129
|
+
const paths = [...sources].sort((a, b) => a.localeCompare(b)).join(", ");
|
|
130
|
+
issues.push({
|
|
131
|
+
level: "warn",
|
|
132
|
+
message: `Marker id "${mid}" is reused across different source files (${paths}). ` +
|
|
133
|
+
`That is valid for independent regions, but ambiguous for repo-wide links — consider namespaced ids (e.g. "${mid}--dashboard", "${mid}--api").`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return issues;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=marker-validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marker-validation.js","sourceRoot":"","sources":["../src/marker-validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AAIpE;;;;;;GAMG;AACH,MAAM,UAAU,gCAAgC,CAC9C,UAAkB,EAClB,UAAkB;IAElB,MAAM,MAAM,GAA4B,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAkB,CAAC;IAEnD,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QAClD,MAAM,GAAG,GAAG,6BAA6B,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAC9D,IAAI,CAAC,GAAG;YAAE,SAAS;QACnB,IAAI,CAAC;YACH,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK,EAAE,OAAO;gBACd,OAAO,EAAE,GAAG,UAAU,I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c,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChF,MAAM,CAAC,IAAI,CAAC;gBACV,KAAK,EAAE,OAAO;gBACd,OAAO,EACL,cAAc,GAAG,iBAAiB,UAAU,0CAA0C,MAAM,IAAI;oBAChG,yFAAyF;aAC5F,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,gBAAgB,EAAE,CAAC;QAC9C,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC;YAAE,SAAS;QAChC,MAAM,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzE,MAAM,CAAC,IAAI,CAAC;YACV,KAAK,EAAE,MAAM;YACb,OAAO,EACL,cAAc,GAAG,8CAA8C,KAAK,KAAK;gBACzE,6GAA6G,GAAG,kBAAkB,GAAG,UAAU;SAClJ,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/metadata.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAoD,MAAM,YAAY,CAAC;AAEpG,wBAAgB,UAAU,IAAI,eAAe,CAE5C;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAwBhE"}
|
package/dist/metadata.js
CHANGED
|
@@ -1,55 +1,110 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseAnchor } from "./anchors.js";
|
|
2
|
+
import { describeIndexSchemaRemediation } from "./index-schema-messages.js";
|
|
3
|
+
import { assertValidMarkerId } from "./marker-ids.js";
|
|
4
|
+
import { coerceIndexSchemaVersion, CURRENT_SCHEMA_VERSION } from "./model.js";
|
|
2
5
|
export function emptyIndex() {
|
|
3
|
-
return { schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
6
|
+
return { schemaVersion: CURRENT_SCHEMA_VERSION, byCommentrayPath: {} };
|
|
4
7
|
}
|
|
5
8
|
export function assertValidIndex(value) {
|
|
6
9
|
if (typeof value !== "object" || value === null) {
|
|
7
|
-
throw new
|
|
10
|
+
throw new TypeError("index.json must be a JSON object");
|
|
8
11
|
}
|
|
9
12
|
const obj = value;
|
|
10
|
-
const schemaVersion = obj.schemaVersion;
|
|
13
|
+
const schemaVersion = coerceIndexSchemaVersion(obj.schemaVersion);
|
|
14
|
+
if (schemaVersion === null) {
|
|
15
|
+
throw new TypeError(`index.json schemaVersion must be an integer (got ${String(obj.schemaVersion)})`);
|
|
16
|
+
}
|
|
11
17
|
if (schemaVersion !== CURRENT_SCHEMA_VERSION) {
|
|
12
|
-
throw new Error(`
|
|
18
|
+
throw new Error(`index.json schemaVersion mismatch. ${describeIndexSchemaRemediation(obj.schemaVersion)}`);
|
|
13
19
|
}
|
|
14
|
-
const
|
|
15
|
-
if (typeof
|
|
16
|
-
throw new
|
|
20
|
+
const byCommentrayPath = obj.byCommentrayPath;
|
|
21
|
+
if (typeof byCommentrayPath !== "object" || byCommentrayPath === null) {
|
|
22
|
+
throw new TypeError("index.json.byCommentrayPath must be an object");
|
|
17
23
|
}
|
|
18
|
-
for (const [key, entry] of Object.entries(
|
|
19
|
-
|
|
24
|
+
for (const [key, entry] of Object.entries(byCommentrayPath)) {
|
|
25
|
+
validateCommentrayEntry(key, entry);
|
|
20
26
|
}
|
|
21
|
-
return obj;
|
|
27
|
+
return { ...obj, schemaVersion: CURRENT_SCHEMA_VERSION };
|
|
22
28
|
}
|
|
23
|
-
function
|
|
29
|
+
function validateCommentrayEntry(commentrayPathKey, entry) {
|
|
24
30
|
if (typeof entry !== "object" || entry === null) {
|
|
25
|
-
throw new
|
|
31
|
+
throw new TypeError(`Invalid index entry for ${commentrayPathKey}`);
|
|
26
32
|
}
|
|
27
33
|
const e = entry;
|
|
28
|
-
if (typeof e.sourcePath !== "string")
|
|
29
|
-
throw new
|
|
34
|
+
if (typeof e.sourcePath !== "string") {
|
|
35
|
+
throw new TypeError(`Missing sourcePath for ${commentrayPathKey}`);
|
|
36
|
+
}
|
|
30
37
|
if (typeof e.commentrayPath !== "string") {
|
|
31
|
-
throw new
|
|
38
|
+
throw new TypeError(`Missing commentrayPath for ${commentrayPathKey}`);
|
|
39
|
+
}
|
|
40
|
+
if (e.commentrayPath !== commentrayPathKey) {
|
|
41
|
+
throw new TypeError(`index key must equal entry.commentrayPath (key=${commentrayPathKey}, entry=${e.commentrayPath})`);
|
|
42
|
+
}
|
|
43
|
+
if (!Array.isArray(e.blocks)) {
|
|
44
|
+
throw new TypeError(`blocks must be an array for ${commentrayPathKey}`);
|
|
32
45
|
}
|
|
33
|
-
if (!Array.isArray(e.blocks))
|
|
34
|
-
throw new Error(`blocks must be an array for ${sourcePath}`);
|
|
35
46
|
for (const block of e.blocks)
|
|
36
|
-
validateBlock(
|
|
47
|
+
validateBlock(commentrayPathKey, block);
|
|
37
48
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
function parseValidatedMarkerId(commentrayPathKey, raw) {
|
|
50
|
+
try {
|
|
51
|
+
return assertValidMarkerId(raw);
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
catch (e) {
|
|
54
|
+
throw new TypeError(`block.id invalid under ${commentrayPathKey}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function parseValidatedAnchor(commentrayPathKey, raw) {
|
|
58
|
+
try {
|
|
59
|
+
return parseAnchor(raw);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
throw new TypeError(`Invalid block.anchor under ${commentrayPathKey}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function assertBlockMarkerAnchorConsistency(commentrayPathKey, b, bid, parsedAnchor) {
|
|
66
|
+
if (parsedAnchor.kind === "marker" && parsedAnchor.id !== bid) {
|
|
67
|
+
throw new TypeError(`block.id must match marker anchor id (got id=${b.id}, anchor=${b.anchor}) under ${commentrayPathKey}`);
|
|
47
68
|
}
|
|
69
|
+
if (parsedAnchor.kind === "marker" &&
|
|
70
|
+
b.markerId !== undefined &&
|
|
71
|
+
typeof b.markerId === "string" &&
|
|
72
|
+
b.markerId.trim() !== "" &&
|
|
73
|
+
assertValidMarkerId(b.markerId) !== parsedAnchor.id) {
|
|
74
|
+
throw new TypeError(`block.markerId must match marker anchor id under ${commentrayPathKey} (block ${b.id})`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function validateBlockOptionalFields(commentrayPathKey, b) {
|
|
48
78
|
if (b.lastVerifiedCommit !== undefined && typeof b.lastVerifiedCommit !== "string") {
|
|
49
|
-
throw new
|
|
79
|
+
throw new TypeError(`block.lastVerifiedCommit must be a string when present under ${commentrayPathKey}`);
|
|
50
80
|
}
|
|
51
81
|
if (b.lastVerifiedBlob !== undefined && typeof b.lastVerifiedBlob !== "string") {
|
|
52
|
-
throw new
|
|
82
|
+
throw new TypeError(`block.lastVerifiedBlob must be a string when present under ${commentrayPathKey}`);
|
|
83
|
+
}
|
|
84
|
+
if (b.markerId !== undefined && typeof b.markerId !== "string") {
|
|
85
|
+
throw new TypeError(`block.markerId must be a string when present under ${commentrayPathKey}`);
|
|
86
|
+
}
|
|
87
|
+
if (b.snippet !== undefined && typeof b.snippet !== "string") {
|
|
88
|
+
throw new TypeError(`block.snippet must be a string when present under ${commentrayPathKey}`);
|
|
89
|
+
}
|
|
90
|
+
if (b.fingerprint !== undefined) {
|
|
91
|
+
throw new TypeError(`block.fingerprint is no longer supported under ${commentrayPathKey}; re-open the repo to migrate index.json`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function validateBlock(commentrayPathKey, block) {
|
|
95
|
+
if (typeof block !== "object" || block === null) {
|
|
96
|
+
throw new TypeError(`Invalid block under ${commentrayPathKey}`);
|
|
97
|
+
}
|
|
98
|
+
const b = block;
|
|
99
|
+
if (typeof b.id !== "string") {
|
|
100
|
+
throw new TypeError(`block.id must be a string under ${commentrayPathKey}`);
|
|
101
|
+
}
|
|
102
|
+
const bid = parseValidatedMarkerId(commentrayPathKey, b.id);
|
|
103
|
+
if (typeof b.anchor !== "string") {
|
|
104
|
+
throw new TypeError(`block.anchor must be a string under ${commentrayPathKey}`);
|
|
53
105
|
}
|
|
106
|
+
const parsedAnchor = parseValidatedAnchor(commentrayPathKey, b.anchor);
|
|
107
|
+
assertBlockMarkerAnchorConsistency(commentrayPathKey, b, bid, parsedAnchor);
|
|
108
|
+
validateBlockOptionalFields(commentrayPathKey, b);
|
|
54
109
|
}
|
|
55
110
|
//# sourceMappingURL=metadata.js.map
|
package/dist/metadata.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,sBAAsB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAqB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAwB,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpG,MAAM,UAAU,UAAU;IACxB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CAAC;IAClF,CAAC;IACD,MAAM,YAAY,GAAG,oBAAoB,CAAC,iBAAiB,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IACvE,kCAAkC,CAAC,iBAAiB,EAAE,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAC5E,2BAA2B,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
package/dist/migrate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,YAAY,CAAC;AAIpB,uEAAuE;AACvE,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAuDvF"}
|
package/dist/migrate.js
CHANGED
|
@@ -1,39 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { describeIndexSchemaRemediation } from "./index-schema-messages.js";
|
|
2
|
+
import { coerceIndexSchemaVersion, CURRENT_SCHEMA_VERSION, } from "./model.js";
|
|
3
|
+
const LEGACY_SCHEMA_VERSION = 2;
|
|
2
4
|
/** Returns migrated index and whether the file should be rewritten. */
|
|
3
5
|
export function migrateIndex(raw) {
|
|
4
6
|
if (typeof raw !== "object" || raw === null) {
|
|
5
7
|
return {
|
|
6
|
-
index: { schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
8
|
+
index: { schemaVersion: CURRENT_SCHEMA_VERSION, byCommentrayPath: {} },
|
|
7
9
|
changed: true,
|
|
8
10
|
};
|
|
9
11
|
}
|
|
10
12
|
const obj = raw;
|
|
11
|
-
const version = obj.schemaVersion;
|
|
13
|
+
const version = coerceIndexSchemaVersion(obj.schemaVersion);
|
|
14
|
+
if (version === null && obj.schemaVersion !== undefined) {
|
|
15
|
+
throw new TypeError(`Invalid index schemaVersion: ${String(obj.schemaVersion)}`);
|
|
16
|
+
}
|
|
12
17
|
if (version === CURRENT_SCHEMA_VERSION) {
|
|
13
|
-
|
|
18
|
+
const index = obj;
|
|
19
|
+
return { index, changed: false };
|
|
14
20
|
}
|
|
15
|
-
if (version ===
|
|
16
|
-
|
|
21
|
+
if (version === LEGACY_SCHEMA_VERSION ||
|
|
22
|
+
version === undefined ||
|
|
23
|
+
version === 0 ||
|
|
24
|
+
version === 1) {
|
|
25
|
+
const byCommentrayPath = toByCommentrayPath(obj);
|
|
17
26
|
const next = {
|
|
18
27
|
schemaVersion: CURRENT_SCHEMA_VERSION,
|
|
19
|
-
|
|
28
|
+
byCommentrayPath,
|
|
20
29
|
};
|
|
21
30
|
const before = JSON.stringify({
|
|
22
|
-
schemaVersion: version
|
|
31
|
+
schemaVersion: version === undefined ? 0 : version,
|
|
23
32
|
bySourceFile: obj.bySourceFile ?? {},
|
|
33
|
+
byCommentrayPath: obj.byCommentrayPath ?? {},
|
|
24
34
|
});
|
|
25
35
|
const after = JSON.stringify(next);
|
|
26
36
|
const changed = before !== after;
|
|
27
37
|
return { index: next, changed };
|
|
28
38
|
}
|
|
29
|
-
|
|
39
|
+
if (typeof version === "number" && version > CURRENT_SCHEMA_VERSION) {
|
|
40
|
+
/**
|
|
41
|
+
* Future CLI may bump `schemaVersion` before every consumer updates. Prefer opening
|
|
42
|
+
* the repo over hard failure: keep `byCommentrayPath` as parsed, stamp this build’s
|
|
43
|
+
* schema, and let `assertValidIndex` reject only truly incompatible shapes.
|
|
44
|
+
*/
|
|
45
|
+
const byCommentrayPath = toByCommentrayPath(obj);
|
|
46
|
+
return {
|
|
47
|
+
index: { schemaVersion: CURRENT_SCHEMA_VERSION, byCommentrayPath },
|
|
48
|
+
changed: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
throw new Error(`Cannot migrate index.json from schemaVersion ${String(obj.schemaVersion)}. ${describeIndexSchemaRemediation(obj.schemaVersion)}`);
|
|
30
52
|
}
|
|
31
|
-
function
|
|
32
|
-
if (
|
|
33
|
-
|
|
53
|
+
function toByCommentrayPath(obj) {
|
|
54
|
+
if (obj.byCommentrayPath &&
|
|
55
|
+
typeof obj.byCommentrayPath === "object" &&
|
|
56
|
+
obj.byCommentrayPath !== null) {
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [k, entry] of Object.entries(obj.byCommentrayPath)) {
|
|
59
|
+
out[k] = normalizeEntry(entry);
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
const bySourceFile = obj.bySourceFile;
|
|
34
64
|
const out = {};
|
|
35
|
-
|
|
36
|
-
out
|
|
65
|
+
if (typeof bySourceFile !== "object" || bySourceFile === null) {
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
for (const [, entry] of Object.entries(bySourceFile)) {
|
|
69
|
+
const norm = normalizeEntry(entry);
|
|
70
|
+
const cp = norm.commentrayPath;
|
|
71
|
+
if (out[cp]) {
|
|
72
|
+
throw new Error(`Duplicate commentrayPath in legacy index: ${cp}`);
|
|
73
|
+
}
|
|
74
|
+
out[cp] = norm;
|
|
37
75
|
}
|
|
38
76
|
return out;
|
|
39
77
|
}
|
package/dist/migrate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,sBAAsB,GACvB,MAAM,YAAY,CAAC;AAEpB,uEAAuE;AACvE,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,OAAO;YACL,KAAK,EAAE,EAAE,aAAa,EAAE,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts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
|
anchor: string;
|
|
7
|
+
/**
|
|
8
|
+
* Optional unified-diff–style capture of the anchored source lines (see
|
|
9
|
+
* `block-snippet.ts`). Self-contained string in index.json — not a nested
|
|
10
|
+
* JSON region object.
|
|
11
|
+
*/
|
|
12
|
+
snippet?: string;
|
|
13
|
+
/**
|
|
14
|
+
* When the anchor is `marker:<id>`, the same id appears in source as the
|
|
15
|
+
* region name `commentray:<id>` (e.g. `//#region` / `//#endregion` in
|
|
16
|
+
* TypeScript, aligned with the Region Marker extension), or in legacy
|
|
17
|
+
* `commentray:start id=…` / `commentray:end id=…` line comments.
|
|
18
|
+
*/
|
|
19
|
+
markerId?: string;
|
|
7
20
|
/** Last human-verified commit (full SHA) when this block was considered accurate. */
|
|
8
21
|
lastVerifiedCommit?: string;
|
|
9
22
|
/** Git blob id at verification time for the primary file (when known). */
|
|
@@ -21,7 +34,16 @@ export type SourceFileIndexEntry = {
|
|
|
21
34
|
/** Root metadata document stored as JSON under `.commentray/metadata/`. */
|
|
22
35
|
export type CommentrayIndex = {
|
|
23
36
|
schemaVersion: number;
|
|
24
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Blocks grouped by repo-relative commentray Markdown path so multiple **Angles**
|
|
39
|
+
* for the same `sourcePath` each keep their own block lists (schema v3+).
|
|
40
|
+
*/
|
|
41
|
+
byCommentrayPath: Record<string, SourceFileIndexEntry>;
|
|
25
42
|
};
|
|
26
|
-
export declare const CURRENT_SCHEMA_VERSION:
|
|
43
|
+
export declare const CURRENT_SCHEMA_VERSION: 3;
|
|
44
|
+
/**
|
|
45
|
+
* Normalizes `index.json` `schemaVersion` after `JSON.parse` (integer, or
|
|
46
|
+
* rare string forms like `"3"`).
|
|
47
|
+
*/
|
|
48
|
+
export declare function coerceIndexSchemaVersion(raw: unknown): number | undefined | null;
|
|
27
49
|
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,MAAM,eAAe,GAAG;IAC5B,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,MAAM,eAAe,GAAG;IAC5B,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,yEAAyE;IACzE,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,EAAE,CAAC;CAC3B,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAG,CAAU,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAQhF"}
|
package/dist/model.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
export const CURRENT_SCHEMA_VERSION =
|
|
1
|
+
export const CURRENT_SCHEMA_VERSION = 3;
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes `index.json` `schemaVersion` after `JSON.parse` (integer, or
|
|
4
|
+
* rare string forms like `"3"`).
|
|
5
|
+
*/
|
|
6
|
+
export function coerceIndexSchemaVersion(raw) {
|
|
7
|
+
if (raw === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
if (typeof raw === "number" && Number.isInteger(raw))
|
|
10
|
+
return raw;
|
|
11
|
+
if (typeof raw === "string") {
|
|
12
|
+
const t = raw.trim();
|
|
13
|
+
if (/^\d+$/.test(t))
|
|
14
|
+
return Number.parseInt(t, 10);
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
2
18
|
//# sourceMappingURL=model.js.map
|
package/dist/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AA6CA,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAU,CAAC;AAEjD;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACjE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;QACrB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/paths.d.ts
CHANGED
|
@@ -11,8 +11,24 @@
|
|
|
11
11
|
* `..` segments are traversal.
|
|
12
12
|
*/
|
|
13
13
|
export declare function normalizeRepoRelativePath(relativePath: string): string;
|
|
14
|
-
/** Commentray Markdown path for a repo-relative source file. */
|
|
15
|
-
export declare function commentrayMarkdownPath(sourceRepoRelativePath: string): string;
|
|
14
|
+
/** Commentray Markdown path for a repo-relative source file (implicit default angle, flat layout). */
|
|
15
|
+
export declare function commentrayMarkdownPath(sourceRepoRelativePath: string, storageDir?: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Repo-relative path to the **Angles sentinel**: if this path exists as a file or directory under
|
|
18
|
+
* the storage root, the repository opts into per-source **Angles** layout (see `docs/spec/storage.md`).
|
|
19
|
+
* When absent, the flat `{storage}/source/{P}.md` layout is the only supported shape.
|
|
20
|
+
*/
|
|
21
|
+
export declare function commentrayAnglesSentinelPath(storageDir?: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Returns true when the repository opts into **Angles** layout: `{storage}/source/.default` exists
|
|
24
|
+
* (file or directory). When false, only the flat `{storage}/source/{P}.md` mapping applies.
|
|
25
|
+
*/
|
|
26
|
+
export declare function commentrayAnglesLayoutEnabled(repoRoot: string, storageDir?: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Repo-relative path to commentray for `sourceRepoRelativePath` at a named **Angle** (multi-angle layout).
|
|
29
|
+
* Example: `README.md` + `architecture` → `.commentray/source/README.md/architecture.md` (with default storage dir).
|
|
30
|
+
*/
|
|
31
|
+
export declare function commentrayMarkdownPathForAngle(sourceRepoRelativePath: string, angleId: string, storageDir?: string): string;
|
|
16
32
|
/** Default metadata index location (repo-relative). */
|
|
17
33
|
export declare function defaultMetadataIndexPath(): string;
|
|
18
34
|
//# sourceMappingURL=paths.d.ts.map
|
package/dist/paths.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAWtE;AAED,sGAAsG;AACtG,wBAAgB,sBAAsB,CACpC,sBAAsB,EAAE,MAAM,EAC9B,UAAU,SAAgB,GACzB,MAAM,CAIR;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,UAAU,SAAgB,GAAG,MAAM,CAG/E;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAChB,UAAU,SAAgB,GACzB,OAAO,CAIT;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,sBAAsB,EAAE,MAAM,EAC9B,OAAO,EAAE,MAAM,EACf,UAAU,SAAgB,GACzB,MAAM,CAKR;AAED,uDAAuD;AACvD,wBAAgB,wBAAwB,IAAI,MAAM,CAEjD"}
|