MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / readFrontmatterField

Function readFrontmatterField

src/skill-manager.ts:158–182  ·  view source on GitHub ↗
(frontmatter: string, field: string)

Source from the content-addressed store, hash-verified

156}
157
158function readFrontmatterField(frontmatter: string, field: string): string | null {
159 const lines = frontmatter.split(/\r?\n/);
160
161 for (let index = 0; index < lines.length; index += 1) {
162 const match = lines[index].match(/^([A-Za-z0-9_-]+):(?:\s*(.*))?$/);
163 if (!match || match[1] !== field) {
164 continue;
165 }
166
167 const rawValue = (match[2] ?? "").trim();
168 if (isBlockScalar(rawValue)) {
169 const [value] = readBlockScalar(lines, index + 1, rawValue);
170 return value;
171 }
172
173 if (rawValue === "") {
174 const [value] = readIndentedScalar(lines, index + 1);
175 return value;
176 }
177
178 return stripWrappingQuotes(rawValue);
179 }
180
181 return null;
182}
183
184function isBlockScalar(value: string): boolean {
185 return /^[>|][0-9+-]*$/.test(value);

Callers 1

parseSkillMdFunction · 0.85

Calls 4

isBlockScalarFunction · 0.85
readBlockScalarFunction · 0.85
readIndentedScalarFunction · 0.85
stripWrappingQuotesFunction · 0.85

Tested by

no test coverage detected