@vibe-agent-toolkit/resources 0.1.13 → 0.1.15-rc.1
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/content-transform.d.ts +159 -0
- package/dist/content-transform.d.ts.map +1 -0
- package/dist/content-transform.js +321 -0
- package/dist/content-transform.js.map +1 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/link-parser.js +3 -0
- package/dist/link-parser.js.map +1 -1
- package/dist/resource-registry.d.ts +50 -20
- package/dist/resource-registry.d.ts.map +1 -1
- package/dist/resource-registry.js +88 -53
- package/dist/resource-registry.js.map +1 -1
- package/dist/schemas/resource-metadata.d.ts +17 -0
- package/dist/schemas/resource-metadata.d.ts.map +1 -1
- package/dist/schemas/resource-metadata.js +13 -0
- package/dist/schemas/resource-metadata.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
- package/src/content-transform.ts +499 -0
- package/src/index.ts +13 -1
- package/src/link-parser.ts +3 -0
- package/src/resource-registry.ts +102 -59
- package/src/schemas/resource-metadata.ts +16 -0
- package/src/types.ts +1 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content transform engine for rewriting markdown links.
|
|
3
|
+
*
|
|
4
|
+
* Provides a pure function for transforming markdown link references
|
|
5
|
+
* based on configurable rules. Used by both RAG (rewriting links before
|
|
6
|
+
* persistence) and agent-skills (rewriting links during skill packaging).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { transformContent, type LinkRewriteRule } from '@vibe-agent-toolkit/resources';
|
|
11
|
+
*
|
|
12
|
+
* const rules: LinkRewriteRule[] = [
|
|
13
|
+
* {
|
|
14
|
+
* match: { type: 'local_file' },
|
|
15
|
+
* template: '{{link.text}} (see: {{link.resource.id}})',
|
|
16
|
+
* },
|
|
17
|
+
* ];
|
|
18
|
+
*
|
|
19
|
+
* const result = transformContent(content, links, { linkRewriteRules: rules, resourceRegistry: registry });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import type { LinkType, ResourceLink, ResourceMetadata } from './schemas/resource-metadata.js';
|
|
23
|
+
/**
|
|
24
|
+
* Interface for looking up resources by ID.
|
|
25
|
+
*
|
|
26
|
+
* Intentionally minimal to avoid tight coupling to ResourceRegistry.
|
|
27
|
+
* Any object providing `getResourceById` satisfies this contract.
|
|
28
|
+
*/
|
|
29
|
+
export interface ResourceLookup {
|
|
30
|
+
/** Look up a resource by its unique ID */
|
|
31
|
+
getResourceById(id: string): ResourceMetadata | undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Match criteria for a link rewrite rule.
|
|
35
|
+
*
|
|
36
|
+
* A rule matches a link when ALL specified criteria are satisfied:
|
|
37
|
+
* - `type`: Link type matches (if specified)
|
|
38
|
+
* - `pattern`: Target resource's filePath matches a glob pattern (if specified)
|
|
39
|
+
* - `excludeResourceIds`: Target resource's ID is NOT in the exclusion list
|
|
40
|
+
*/
|
|
41
|
+
export interface LinkRewriteMatch {
|
|
42
|
+
/**
|
|
43
|
+
* Link type(s) to match. If omitted, matches any type.
|
|
44
|
+
* Can be a single LinkType or an array of LinkType values.
|
|
45
|
+
*/
|
|
46
|
+
type?: LinkType | LinkType[];
|
|
47
|
+
/**
|
|
48
|
+
* Glob pattern(s) to match against the target resource's filePath.
|
|
49
|
+
* If omitted, matches any path. Requires the link to have a resolvedId
|
|
50
|
+
* so the target resource can be looked up.
|
|
51
|
+
* Can be a single glob string or an array of glob strings.
|
|
52
|
+
*/
|
|
53
|
+
pattern?: string | string[];
|
|
54
|
+
/**
|
|
55
|
+
* Resource IDs to exclude from matching.
|
|
56
|
+
* If the link's resolvedId is in this list, the rule does not match.
|
|
57
|
+
*/
|
|
58
|
+
excludeResourceIds?: string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A rule for rewriting markdown links in content.
|
|
62
|
+
*
|
|
63
|
+
* Rules are evaluated in order; the first matching rule wins.
|
|
64
|
+
* Links that match no rule are left untouched.
|
|
65
|
+
*/
|
|
66
|
+
export interface LinkRewriteRule {
|
|
67
|
+
/**
|
|
68
|
+
* Match criteria. All specified criteria must be satisfied for the rule to match.
|
|
69
|
+
*/
|
|
70
|
+
match: LinkRewriteMatch;
|
|
71
|
+
/**
|
|
72
|
+
* Handlebars template for the replacement text.
|
|
73
|
+
*
|
|
74
|
+
* Available template variables:
|
|
75
|
+
* - `link.text` - Link display text
|
|
76
|
+
* - `link.href` - Original href (without fragment)
|
|
77
|
+
* - `link.fragment` - Fragment portion including `#` prefix (or empty string)
|
|
78
|
+
* - `link.type` - Link type (local_file, anchor, external, email, unknown)
|
|
79
|
+
* - `link.resource.id` - Target resource ID (if resolved)
|
|
80
|
+
* - `link.resource.filePath` - Target resource file path (if resolved)
|
|
81
|
+
* - `link.resource.fileName` - Target resource file name with extension (if resolved)
|
|
82
|
+
* - `link.resource.extension` - Target resource file extension (if resolved)
|
|
83
|
+
* - `link.resource.mimeType` - Inferred MIME type (if resolved)
|
|
84
|
+
* - `link.resource.frontmatter.*` - Target resource frontmatter fields (if resolved)
|
|
85
|
+
* - `link.resource.sizeBytes` - Target resource size in bytes (if resolved)
|
|
86
|
+
* - `link.resource.estimatedTokenCount` - Target resource estimated token count (if resolved)
|
|
87
|
+
* - `link.resource.relativePath` - Relative path from sourceFilePath to resource (if both available)
|
|
88
|
+
* - Plus any variables from `context`
|
|
89
|
+
*/
|
|
90
|
+
template: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Options for the `transformContent` function.
|
|
94
|
+
*/
|
|
95
|
+
export interface ContentTransformOptions {
|
|
96
|
+
/** Ordered list of link rewrite rules. First matching rule wins. */
|
|
97
|
+
linkRewriteRules: LinkRewriteRule[];
|
|
98
|
+
/**
|
|
99
|
+
* Resource lookup for resolving `link.resource.*` template variables.
|
|
100
|
+
* If not provided, `link.resource.*` variables will be undefined in templates.
|
|
101
|
+
*/
|
|
102
|
+
resourceRegistry?: ResourceLookup;
|
|
103
|
+
/**
|
|
104
|
+
* Additional context variables available in all templates.
|
|
105
|
+
* These are merged at the top level of the template context.
|
|
106
|
+
*/
|
|
107
|
+
context?: Record<string, unknown>;
|
|
108
|
+
/**
|
|
109
|
+
* Absolute file path of the source document being transformed.
|
|
110
|
+
* When provided, enables `link.resource.relativePath` computation:
|
|
111
|
+
* `relative(dirname(sourceFilePath), link.resource.filePath)` using forward slashes.
|
|
112
|
+
*/
|
|
113
|
+
sourceFilePath?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Fallback template for links that match no rule.
|
|
116
|
+
* Without this option, unmatched links are left untouched (original markdown preserved).
|
|
117
|
+
* With this option, unmatched links are rendered through this template.
|
|
118
|
+
*/
|
|
119
|
+
defaultTemplate?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Transform markdown content by rewriting links according to rules.
|
|
123
|
+
*
|
|
124
|
+
* This is a pure function that takes content, its parsed links, and transform options,
|
|
125
|
+
* and returns the content with matching links rewritten according to the first matching rule.
|
|
126
|
+
*
|
|
127
|
+
* Two passes are performed:
|
|
128
|
+
* 1. **Inline links** `[text](href)` — matched via rules, rendered through templates
|
|
129
|
+
* 2. **Definition lines** `[ref]: url` — matched via rules, rewritten in definition format
|
|
130
|
+
* or removed if orphaned (target not in registry)
|
|
131
|
+
*
|
|
132
|
+
* Links matching no rule are left untouched unless a `defaultTemplate` is provided.
|
|
133
|
+
*
|
|
134
|
+
* @param content - The markdown content to transform
|
|
135
|
+
* @param links - Parsed links from the content (from ResourceMetadata.links)
|
|
136
|
+
* @param options - Transform options including rules, registry, and context
|
|
137
|
+
* @returns The transformed content with rewritten links
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```typescript
|
|
141
|
+
* const rules: LinkRewriteRule[] = [
|
|
142
|
+
* {
|
|
143
|
+
* match: { type: 'local_file' },
|
|
144
|
+
* template: '{{link.text}} (ref: {{link.resource.id}})',
|
|
145
|
+
* },
|
|
146
|
+
* {
|
|
147
|
+
* match: { type: 'external' },
|
|
148
|
+
* template: '[{{link.text}}]({{link.href}})',
|
|
149
|
+
* },
|
|
150
|
+
* ];
|
|
151
|
+
*
|
|
152
|
+
* const result = transformContent(content, resource.links, {
|
|
153
|
+
* linkRewriteRules: rules,
|
|
154
|
+
* resourceRegistry: registry,
|
|
155
|
+
* });
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export declare function transformContent(content: string, links: ResourceLink[], options: ContentTransformOptions): string;
|
|
159
|
+
//# sourceMappingURL=content-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-transform.d.ts","sourceRoot":"","sources":["../src/content-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAmC/F;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,0CAA0C;IAC1C,eAAe,CAAC,EAAE,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAAC;CAC3D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAE7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAC;IAExB;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,oEAAoE;IACpE,gBAAgB,EAAE,eAAe,EAAE,CAAC;IAEpC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAElC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAElC;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AA0KD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,YAAY,EAAE,EACrB,OAAO,EAAE,uBAAuB,GAC/B,MAAM,CAuHR"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content transform engine for rewriting markdown links.
|
|
3
|
+
*
|
|
4
|
+
* Provides a pure function for transforming markdown link references
|
|
5
|
+
* based on configurable rules. Used by both RAG (rewriting links before
|
|
6
|
+
* persistence) and agent-skills (rewriting links during skill packaging).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { transformContent, type LinkRewriteRule } from '@vibe-agent-toolkit/resources';
|
|
11
|
+
*
|
|
12
|
+
* const rules: LinkRewriteRule[] = [
|
|
13
|
+
* {
|
|
14
|
+
* match: { type: 'local_file' },
|
|
15
|
+
* template: '{{link.text}} (see: {{link.resource.id}})',
|
|
16
|
+
* },
|
|
17
|
+
* ];
|
|
18
|
+
*
|
|
19
|
+
* const result = transformContent(content, links, { linkRewriteRules: rules, resourceRegistry: registry });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import { renderTemplate, toForwardSlash } from '@vibe-agent-toolkit/utils';
|
|
24
|
+
import { matchesGlobPattern, splitHrefAnchor } from './utils.js';
|
|
25
|
+
/**
|
|
26
|
+
* Extension-to-MIME-type mapping for common resource file types.
|
|
27
|
+
*/
|
|
28
|
+
const EXTENSION_MIME_MAP = {
|
|
29
|
+
'.md': 'text/markdown',
|
|
30
|
+
'.ts': 'text/typescript',
|
|
31
|
+
'.js': 'text/javascript',
|
|
32
|
+
'.json': 'application/json',
|
|
33
|
+
'.yaml': 'text/yaml',
|
|
34
|
+
'.yml': 'text/yaml',
|
|
35
|
+
'.xml': 'application/xml',
|
|
36
|
+
'.html': 'text/html',
|
|
37
|
+
'.css': 'text/css',
|
|
38
|
+
'.txt': 'text/plain',
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Default MIME type when the file extension is unknown.
|
|
42
|
+
*/
|
|
43
|
+
const DEFAULT_MIME_TYPE = 'application/octet-stream';
|
|
44
|
+
/**
|
|
45
|
+
* Infer MIME type from a file extension.
|
|
46
|
+
*
|
|
47
|
+
* @param filePath - File path to extract extension from
|
|
48
|
+
* @returns Inferred MIME type string
|
|
49
|
+
*/
|
|
50
|
+
function inferMimeType(filePath) {
|
|
51
|
+
const ext = path.extname(filePath).toLowerCase();
|
|
52
|
+
return EXTENSION_MIME_MAP[ext] ?? DEFAULT_MIME_TYPE;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Build the template context for a matched link.
|
|
56
|
+
*
|
|
57
|
+
* @param link - The ResourceLink being transformed
|
|
58
|
+
* @param hrefWithoutFragment - The href with fragment stripped
|
|
59
|
+
* @param fragment - The fragment string including '#' prefix, or empty string
|
|
60
|
+
* @param resource - The resolved target resource (if available)
|
|
61
|
+
* @param extraContext - Additional context variables
|
|
62
|
+
* @param sourceFilePath - Absolute path of the source document (for relativePath computation)
|
|
63
|
+
* @returns Template context object
|
|
64
|
+
*/
|
|
65
|
+
function buildTemplateContext(link, hrefWithoutFragment, fragment, resource, extraContext, sourceFilePath) {
|
|
66
|
+
const resourceContext = resource === undefined
|
|
67
|
+
? undefined
|
|
68
|
+
: {
|
|
69
|
+
id: resource.id,
|
|
70
|
+
filePath: resource.filePath,
|
|
71
|
+
fileName: path.basename(resource.filePath),
|
|
72
|
+
extension: path.extname(resource.filePath),
|
|
73
|
+
mimeType: inferMimeType(resource.filePath),
|
|
74
|
+
frontmatter: resource.frontmatter,
|
|
75
|
+
sizeBytes: resource.sizeBytes,
|
|
76
|
+
estimatedTokenCount: resource.estimatedTokenCount,
|
|
77
|
+
relativePath: sourceFilePath === undefined
|
|
78
|
+
? undefined
|
|
79
|
+
: toForwardSlash(path.relative(path.dirname(sourceFilePath), resource.filePath)),
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
...extraContext,
|
|
83
|
+
link: {
|
|
84
|
+
text: link.text,
|
|
85
|
+
href: hrefWithoutFragment,
|
|
86
|
+
fragment,
|
|
87
|
+
type: link.type,
|
|
88
|
+
resource: resourceContext,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Check if a link's type matches the rule's type criteria.
|
|
94
|
+
*
|
|
95
|
+
* @param linkType - The link's type
|
|
96
|
+
* @param matchType - The rule's type criteria (single or array, or undefined = match all)
|
|
97
|
+
* @returns True if the type matches
|
|
98
|
+
*/
|
|
99
|
+
function matchesType(linkType, matchType) {
|
|
100
|
+
if (matchType === undefined) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
if (Array.isArray(matchType)) {
|
|
104
|
+
return matchType.includes(linkType);
|
|
105
|
+
}
|
|
106
|
+
return linkType === matchType;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Check if a link's target resource matches the rule's pattern criteria.
|
|
110
|
+
*
|
|
111
|
+
* @param resource - The target resource (if resolved)
|
|
112
|
+
* @param patterns - The pattern(s) to match against (or undefined = match all)
|
|
113
|
+
* @returns True if the pattern matches or no pattern is specified
|
|
114
|
+
*/
|
|
115
|
+
function matchesPattern(resource, patterns) {
|
|
116
|
+
if (patterns === undefined) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
// Pattern matching requires a resolved resource
|
|
120
|
+
if (resource === undefined) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
const patternArray = Array.isArray(patterns) ? patterns : [patterns];
|
|
124
|
+
return patternArray.some((pattern) => matchesGlobPattern(resource.filePath, pattern));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Check if a link's resolvedId is excluded by the rule.
|
|
128
|
+
*
|
|
129
|
+
* @param resolvedId - The link's resolved resource ID (if any)
|
|
130
|
+
* @param excludeResourceIds - IDs to exclude (if any)
|
|
131
|
+
* @returns True if the link is excluded (should NOT match)
|
|
132
|
+
*/
|
|
133
|
+
function isExcluded(resolvedId, excludeResourceIds) {
|
|
134
|
+
if (excludeResourceIds === undefined || excludeResourceIds.length === 0) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (resolvedId === undefined) {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return excludeResourceIds.includes(resolvedId);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Find the first matching rule for a given link.
|
|
144
|
+
*
|
|
145
|
+
* @param link - The ResourceLink to match
|
|
146
|
+
* @param resource - The resolved target resource (if available)
|
|
147
|
+
* @param rules - Ordered list of rules
|
|
148
|
+
* @returns The first matching rule, or undefined if no rule matches
|
|
149
|
+
*/
|
|
150
|
+
function findMatchingRule(link, resource, rules) {
|
|
151
|
+
for (const rule of rules) {
|
|
152
|
+
const { match } = rule;
|
|
153
|
+
if (!matchesType(link.type, match.type)) {
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
if (!matchesPattern(resource, match.pattern)) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (isExcluded(link.resolvedId, match.excludeResourceIds)) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
return rule;
|
|
163
|
+
}
|
|
164
|
+
return undefined;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Regex pattern matching inline markdown links: `[text](href)`
|
|
168
|
+
*
|
|
169
|
+
* Captures:
|
|
170
|
+
* - Group 0: Full match including brackets and parentheses
|
|
171
|
+
* - Group 1: Link text
|
|
172
|
+
* - Group 2: Link href
|
|
173
|
+
*
|
|
174
|
+
* Does NOT handle nested brackets in link text — the negated character class
|
|
175
|
+
* `[^\]]*` excludes `]` characters, so `[text [with] brackets](href)` would
|
|
176
|
+
* not be matched as a single link.
|
|
177
|
+
*/
|
|
178
|
+
// eslint-disable-next-line sonarjs/slow-regex -- negated character classes [^\]] and [^)] are inherently non-backtracking
|
|
179
|
+
const MARKDOWN_LINK_REGEX = /\[([^\]]*)\]\(([^)]*)\)/g;
|
|
180
|
+
/**
|
|
181
|
+
* Regex pattern matching reference-style link definitions: `[ref]: url`
|
|
182
|
+
*
|
|
183
|
+
* Must appear at the start of a line (multiline flag).
|
|
184
|
+
* Captures:
|
|
185
|
+
* - Group 1: Reference identifier
|
|
186
|
+
* - Group 2: URL (may include trailing whitespace)
|
|
187
|
+
*/
|
|
188
|
+
// eslint-disable-next-line sonarjs/slow-regex -- Controlled markdown reference link definitions on line boundaries
|
|
189
|
+
const MARKDOWN_DEFINITION_REGEX = /^\[([^\]]*?)\]:\s*(.+)$/gm;
|
|
190
|
+
/**
|
|
191
|
+
* Transform markdown content by rewriting links according to rules.
|
|
192
|
+
*
|
|
193
|
+
* This is a pure function that takes content, its parsed links, and transform options,
|
|
194
|
+
* and returns the content with matching links rewritten according to the first matching rule.
|
|
195
|
+
*
|
|
196
|
+
* Two passes are performed:
|
|
197
|
+
* 1. **Inline links** `[text](href)` — matched via rules, rendered through templates
|
|
198
|
+
* 2. **Definition lines** `[ref]: url` — matched via rules, rewritten in definition format
|
|
199
|
+
* or removed if orphaned (target not in registry)
|
|
200
|
+
*
|
|
201
|
+
* Links matching no rule are left untouched unless a `defaultTemplate` is provided.
|
|
202
|
+
*
|
|
203
|
+
* @param content - The markdown content to transform
|
|
204
|
+
* @param links - Parsed links from the content (from ResourceMetadata.links)
|
|
205
|
+
* @param options - Transform options including rules, registry, and context
|
|
206
|
+
* @returns The transformed content with rewritten links
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* const rules: LinkRewriteRule[] = [
|
|
211
|
+
* {
|
|
212
|
+
* match: { type: 'local_file' },
|
|
213
|
+
* template: '{{link.text}} (ref: {{link.resource.id}})',
|
|
214
|
+
* },
|
|
215
|
+
* {
|
|
216
|
+
* match: { type: 'external' },
|
|
217
|
+
* template: '[{{link.text}}]({{link.href}})',
|
|
218
|
+
* },
|
|
219
|
+
* ];
|
|
220
|
+
*
|
|
221
|
+
* const result = transformContent(content, resource.links, {
|
|
222
|
+
* linkRewriteRules: rules,
|
|
223
|
+
* resourceRegistry: registry,
|
|
224
|
+
* });
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
export function transformContent(content, links, options) {
|
|
228
|
+
const { linkRewriteRules, resourceRegistry, context, sourceFilePath, defaultTemplate } = options;
|
|
229
|
+
// If there are no rules, no default template, or no links, return content unchanged
|
|
230
|
+
if ((linkRewriteRules.length === 0 && defaultTemplate === undefined) || links.length === 0) {
|
|
231
|
+
return content;
|
|
232
|
+
}
|
|
233
|
+
// === Pass 1: Inline links [text](href) ===
|
|
234
|
+
// Build a lookup map from "[text](href)" to the corresponding ResourceLink.
|
|
235
|
+
// Multiple links can share the same text+href combination; we process them all
|
|
236
|
+
// with the first matching ResourceLink (they are identical in terms of match criteria).
|
|
237
|
+
const linkBySignature = new Map();
|
|
238
|
+
for (const link of links) {
|
|
239
|
+
if (link.nodeType === 'definition') {
|
|
240
|
+
continue; // Definitions are handled in pass 2
|
|
241
|
+
}
|
|
242
|
+
const signature = `[${link.text}](${link.href})`;
|
|
243
|
+
if (!linkBySignature.has(signature)) {
|
|
244
|
+
linkBySignature.set(signature, link);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Replace inline markdown links in content
|
|
248
|
+
let result = content.replaceAll(MARKDOWN_LINK_REGEX, (fullMatch, text, href) => {
|
|
249
|
+
// Find the corresponding ResourceLink
|
|
250
|
+
const signature = `[${text}](${href})`;
|
|
251
|
+
const link = linkBySignature.get(signature);
|
|
252
|
+
if (!link) {
|
|
253
|
+
// Link not in the parsed links array - leave untouched
|
|
254
|
+
return fullMatch;
|
|
255
|
+
}
|
|
256
|
+
// Resolve the target resource if available
|
|
257
|
+
const resource = link.resolvedId === undefined || resourceRegistry === undefined
|
|
258
|
+
? undefined
|
|
259
|
+
: resourceRegistry.getResourceById(link.resolvedId);
|
|
260
|
+
// Find the first matching rule
|
|
261
|
+
const rule = findMatchingRule(link, resource, linkRewriteRules);
|
|
262
|
+
// Determine which template to use: matched rule, defaultTemplate, or leave untouched
|
|
263
|
+
const template = rule?.template ?? defaultTemplate;
|
|
264
|
+
if (template === undefined) {
|
|
265
|
+
// No rule matches and no default template - leave untouched
|
|
266
|
+
return fullMatch;
|
|
267
|
+
}
|
|
268
|
+
// Parse fragment from href
|
|
269
|
+
const [hrefWithoutFragment, anchor] = splitHrefAnchor(href);
|
|
270
|
+
const fragment = anchor === undefined ? '' : `#${anchor}`;
|
|
271
|
+
// Build template context and render
|
|
272
|
+
const templateContext = buildTemplateContext(link, hrefWithoutFragment, fragment, resource, context, sourceFilePath);
|
|
273
|
+
return renderTemplate(template, templateContext);
|
|
274
|
+
});
|
|
275
|
+
// === Pass 2: Reference-style definitions [ref]: url ===
|
|
276
|
+
// Build lookup map for definition links (keyed by "identifier\0href")
|
|
277
|
+
const definitionByKey = new Map();
|
|
278
|
+
for (const link of links) {
|
|
279
|
+
if (link.nodeType !== 'definition') {
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const key = `${link.text}\0${link.href}`;
|
|
283
|
+
if (!definitionByKey.has(key)) {
|
|
284
|
+
definitionByKey.set(key, link);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (definitionByKey.size > 0) {
|
|
288
|
+
result = result.replaceAll(MARKDOWN_DEFINITION_REGEX, (fullMatch, ref, href) => {
|
|
289
|
+
const trimmedHref = href.trim();
|
|
290
|
+
// Look up the corresponding definition ResourceLink
|
|
291
|
+
const key = `${ref}\0${trimmedHref}`;
|
|
292
|
+
const link = definitionByKey.get(key);
|
|
293
|
+
if (!link) {
|
|
294
|
+
return fullMatch;
|
|
295
|
+
}
|
|
296
|
+
// Resolve the target resource if available
|
|
297
|
+
const resource = link.resolvedId === undefined || resourceRegistry === undefined
|
|
298
|
+
? undefined
|
|
299
|
+
: resourceRegistry.getResourceById(link.resolvedId);
|
|
300
|
+
// Find matching rule (same rule set as inline links)
|
|
301
|
+
const rule = findMatchingRule(link, resource, linkRewriteRules);
|
|
302
|
+
const template = rule?.template ?? defaultTemplate;
|
|
303
|
+
if (template === undefined) {
|
|
304
|
+
return fullMatch;
|
|
305
|
+
}
|
|
306
|
+
// If resource is in registry and we have sourceFilePath: rewrite URL in definition format
|
|
307
|
+
if (resource !== undefined && sourceFilePath !== undefined) {
|
|
308
|
+
const [, anchor] = splitHrefAnchor(trimmedHref);
|
|
309
|
+
const fragment = anchor === undefined ? '' : `#${anchor}`;
|
|
310
|
+
const newRelPath = toForwardSlash(path.relative(path.dirname(sourceFilePath), resource.filePath));
|
|
311
|
+
return `[${ref}]: ${newRelPath}${fragment}`;
|
|
312
|
+
}
|
|
313
|
+
// Rule matched but no resource to rewrite to — remove orphaned definition
|
|
314
|
+
return '';
|
|
315
|
+
});
|
|
316
|
+
// Clean up excessive blank lines from removed definitions
|
|
317
|
+
result = result.replaceAll(/\n{3,}/g, '\n\n');
|
|
318
|
+
}
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=content-transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-transform.js","sourceRoot":"","sources":["../src/content-transform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;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AQ,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAC/D,CAAC;gBACF,OAAO,IAAI,GAAG,MAAM,UAAU,GAAG,QAAQ,EAAE,CAAC;YAC9C,CAAC;YAED,0EAA0E;YAC1E,OAAO,EAAE,CAAC;QACZ,CAAC,CACF,CAAC;QAEF,0DAA0D;QAC1D,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export { ResourceRegistry, type CrawlOptions, type ResourceRegistryOptions, type RegistryStats, type CollectionStats, type CollectionStat, } from './resource-registry.js';
|
|
28
|
+
export { ResourceRegistry, generateIdFromPath, type CrawlOptions, type ResourceRegistryOptions, type RegistryStats, type CollectionStats, type CollectionStat, } from './resource-registry.js';
|
|
29
29
|
export { ResourceQuery } from './resource-query.js';
|
|
30
30
|
export { ResourceCollection } from './resource-collection.js';
|
|
31
31
|
export type { ResourceCollectionInterface } from './resource-collection-interface.js';
|
|
32
|
-
export type { LinkType, HeadingNode, ResourceLink, ResourceMetadata, ValidationIssue, ValidationResult, ProjectConfig, ResourcesConfig, CollectionConfig, CollectionValidation, ValidationMode, } from './types.js';
|
|
33
|
-
export { LinkTypeSchema, HeadingNodeSchema, ResourceLinkSchema, ResourceMetadataSchema, } from './schemas/resource-metadata.js';
|
|
32
|
+
export type { LinkNodeType, LinkType, HeadingNode, ResourceLink, ResourceMetadata, ValidationIssue, ValidationResult, ProjectConfig, ResourcesConfig, CollectionConfig, CollectionValidation, ValidationMode, } from './types.js';
|
|
33
|
+
export { LinkNodeTypeSchema, LinkTypeSchema, HeadingNodeSchema, ResourceLinkSchema, ResourceMetadataSchema, } from './schemas/resource-metadata.js';
|
|
34
34
|
export { ValidationIssueSchema, ValidationResultSchema, } from './schemas/validation-result.js';
|
|
35
35
|
export { parseMarkdown, type ParseResult } from './link-parser.js';
|
|
36
36
|
export { validateFrontmatter } from './frontmatter-validator.js';
|
|
37
|
+
export { transformContent, type ContentTransformOptions, type LinkRewriteMatch, type LinkRewriteRule, type ResourceLookup, } from './content-transform.js';
|
|
37
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EACL,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,YAAY,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAGtF,YAAY,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,YAAY,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAGtF,YAAY,EACV,YAAY,EACZ,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,OAAO,EACL,gBAAgB,EAChB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -25,19 +25,21 @@
|
|
|
25
25
|
* }
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
// Export main ResourceRegistry class
|
|
29
|
-
export { ResourceRegistry, } from './resource-registry.js';
|
|
28
|
+
// Export main ResourceRegistry class and ID generation utility
|
|
29
|
+
export { ResourceRegistry, generateIdFromPath, } from './resource-registry.js';
|
|
30
30
|
// Export ResourceQuery for lazy evaluation and filtering
|
|
31
31
|
export { ResourceQuery } from './resource-query.js';
|
|
32
32
|
// Export ResourceCollection for immutable collections with lazy duplicate detection
|
|
33
33
|
export { ResourceCollection } from './resource-collection.js';
|
|
34
34
|
// Export schemas for external use (e.g., JSON Schema generation, runtime validation)
|
|
35
|
-
export { LinkTypeSchema, HeadingNodeSchema, ResourceLinkSchema, ResourceMetadataSchema, } from './schemas/resource-metadata.js';
|
|
35
|
+
export { LinkNodeTypeSchema, LinkTypeSchema, HeadingNodeSchema, ResourceLinkSchema, ResourceMetadataSchema, } from './schemas/resource-metadata.js';
|
|
36
36
|
export { ValidationIssueSchema, ValidationResultSchema, } from './schemas/validation-result.js';
|
|
37
37
|
// Export parser interface for advanced use cases
|
|
38
38
|
export { parseMarkdown } from './link-parser.js';
|
|
39
39
|
// Export frontmatter validation
|
|
40
40
|
export { validateFrontmatter } from './frontmatter-validator.js';
|
|
41
|
+
// Export content transform engine for link rewriting
|
|
42
|
+
export { transformContent, } from './content-transform.js';
|
|
41
43
|
// Note: link-parser and link-validator internals are NOT exported
|
|
42
44
|
// They are implementation details. Users should use ResourceRegistry API.
|
|
43
45
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,+DAA+D;AAC/D,OAAO,EACL,gBAAgB,EAChB,kBAAkB,GAMnB,MAAM,wBAAwB,CAAC;AAEhC,yDAAyD;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,oFAAoF;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAqB9D,qFAAqF;AACrF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAExC,iDAAiD;AACjD,OAAO,EAAE,aAAa,EAAoB,MAAM,kBAAkB,CAAC;AAEnE,gCAAgC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,qDAAqD;AACrD,OAAO,EACL,gBAAgB,GAKjB,MAAM,wBAAwB,CAAC;AAEhC,kEAAkE;AAClE,0EAA0E"}
|
package/dist/link-parser.js
CHANGED
|
@@ -83,6 +83,7 @@ function extractLinks(tree) {
|
|
|
83
83
|
href: node.url,
|
|
84
84
|
type: classifyLink(node.url),
|
|
85
85
|
line: node.position?.start.line,
|
|
86
|
+
nodeType: 'link',
|
|
86
87
|
};
|
|
87
88
|
links.push(link);
|
|
88
89
|
});
|
|
@@ -97,6 +98,7 @@ function extractLinks(tree) {
|
|
|
97
98
|
href,
|
|
98
99
|
type: 'unknown', // Reference links need definition resolution
|
|
99
100
|
line: node.position?.start.line,
|
|
101
|
+
nodeType: 'linkReference',
|
|
100
102
|
};
|
|
101
103
|
links.push(link);
|
|
102
104
|
});
|
|
@@ -108,6 +110,7 @@ function extractLinks(tree) {
|
|
|
108
110
|
href: node.url,
|
|
109
111
|
type: classifyLink(node.url),
|
|
110
112
|
line: node.position?.start.line,
|
|
113
|
+
nodeType: 'definition',
|
|
111
114
|
};
|
|
112
115
|
links.push(link);
|
|
113
116
|
});
|
package/dist/link-parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link-parser.js","sourceRoot":"","sources":["../src/link-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,QA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