@tangle-network/agent-profile-materialize 0.19.1 → 0.19.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.
@@ -29,6 +29,43 @@ export function resolveInlineRef(ref) {
29
29
  }
30
30
  const FRONTMATTER_RE = /^---\n([\s\S]*?)\n---\n?([\s\S]*)$/;
31
31
  const collapse = (s) => s.replace(/\s+/g, " ").trim();
32
+ function frontmatterScalar(value) {
33
+ const trimmed = value.trim();
34
+ if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
35
+ try {
36
+ const parsed = JSON.parse(trimmed);
37
+ if (typeof parsed === "string")
38
+ return parsed;
39
+ }
40
+ catch {
41
+ return trimmed;
42
+ }
43
+ }
44
+ if (trimmed.startsWith("'") && trimmed.endsWith("'")) {
45
+ return trimmed.slice(1, -1).replaceAll("''", "'");
46
+ }
47
+ return trimmed;
48
+ }
49
+ function frontmatterValue(frontmatter, field) {
50
+ const lines = frontmatter.split("\n");
51
+ const index = lines.findIndex((line) => line.startsWith(`${field}:`));
52
+ if (index < 0)
53
+ return undefined;
54
+ const inline = (lines[index] ?? "").slice(field.length + 1).trim();
55
+ if (inline && ![">", "|", ">-", "|-"].includes(inline)) {
56
+ return frontmatterScalar(inline);
57
+ }
58
+ const block = [];
59
+ for (let offset = index + 1; offset < lines.length; offset += 1) {
60
+ const line = lines[offset] ?? "";
61
+ if (/^\s+\S/.test(line))
62
+ block.push(line.trim());
63
+ else if (line.trim() !== "")
64
+ break;
65
+ }
66
+ const value = collapse(block.join(" "));
67
+ return value || undefined;
68
+ }
32
69
  const DEFAULT_RESOURCE_FETCH_TIMEOUT_MS = 30_000;
33
70
  const MAX_RESOURCE_BYTES = 10 * 1024 * 1024;
34
71
  const MAX_PROFILE_RESOURCE_BYTES = 32 * 1024 * 1024;
@@ -210,30 +247,17 @@ export function normalizeSkillMd(name, raw) {
210
247
  const m = raw.match(FRONTMATTER_RE);
211
248
  const fm = m?.[1] ?? "";
212
249
  const body = (m?.[2] ?? raw).trim();
213
- let desc = `Skill ${name}. Use when the task matches its domain.`;
214
- if (fm) {
215
- const lines = fm.split("\n");
216
- const i = lines.findIndex((l) => /^description:/.test(l));
217
- if (i >= 0) {
218
- const inline = (lines[i] ?? "").replace(/^description:\s*/, "").trim();
219
- if (inline && ![">", "|", ">-", "|-"].includes(inline))
220
- desc = collapse(inline);
221
- else {
222
- const buf = [];
223
- for (let j = i + 1; j < lines.length; j++) {
224
- const ln = lines[j] ?? "";
225
- if (/^\s+\S/.test(ln))
226
- buf.push(ln.trim());
227
- else if (ln.trim() === "")
228
- continue;
229
- else
230
- break;
231
- }
232
- if (buf.length)
233
- desc = collapse(buf.join(" "));
234
- }
235
- }
250
+ if (fm &&
251
+ frontmatterValue(fm, "name") === name &&
252
+ (frontmatterValue(fm, "description")?.trim().length ?? 0) > 0) {
253
+ return raw;
236
254
  }
255
+ let desc = `Skill ${name}. Use when the task matches its domain.`;
256
+ const declaredDescription = fm
257
+ ? frontmatterValue(fm, "description")
258
+ : undefined;
259
+ if (declaredDescription)
260
+ desc = collapse(declaredDescription);
237
261
  return `---\nname: ${name}\ndescription: ${JSON.stringify(desc)}\n---\n\n${body}\n`;
238
262
  }
239
263
  import { basename } from "node:path";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-profile-materialize",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "description": "Materialize an AgentProfile into the native per-harness workspace files (the one shared materializer for cli-bridge, agent-dev-container, and VB).",
5
5
  "type": "module",
6
6
  "repository": {