@ai-ecoverse/slicc-agent 7.13.1 → 7.13.3
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/README.md +3 -1
- package/dist/roles/frontmatter.js +97 -9
- package/dist/roles/frontmatter.js.map +2 -2
- package/dist/roles/roles.js +5 -1
- package/dist/roles/roles.js.map +2 -2
- package/dist/skills/skills.js +1 -1
- package/dist/skills/skills.js.map +2 -2
- package/dist/types/roles/frontmatter.d.ts +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -288,7 +288,9 @@ Skills and prompt templates work as in pi's coding-agent. pi's loaders read with
|
|
|
288
288
|
On a name collision the first skill found wins: an agent's own skills shadow the global ones, a global skill shadows a built-in, and a built-in shadows a package's. A missing root is skipped.
|
|
289
289
|
- **The global folder.** On every start the worker, as root, creates `/usr/share/skills` if it's missing and sets it to 0755, so it's root's and readable by everyone; once kernel users give each cone its own user and the kernel checks file modes, only root (the worker, sudo or the human) writes there, and every cone and scoop reads it. Each skill's `source` is `user`, `global`, `package` or `builtin`, and the transcript service's `commands` carry it. A skill folder in `/usr/share/skills` whose real path lies in a package under root's global pnpm (`/usr/local/share/pnpm/`), as bios links a certified catalog package's `pi.skills`, reads `package` with that package's `name` and `version` from its nearest `package.json`; every other skill there, such as those imported from SLICC 6 or written by root, stays `global`. Only these links count: root's global pnpm isn't scanned, and loading and precedence don't change.
|
|
290
290
|
- **Inside a root.** Folders with `SKILL.md` are found at any depth, and a `SKILL.md` ends its branch. A `.md` file with a description directly in a root counts too. Folders starting with `.` and `node_modules` are skipped. Symbolic links are followed, but each folder is read once by its real path, so a link back up a tree can't loop. Scoops may `read` the folders of the loaded skills, even outside their own folders.
|
|
291
|
-
- **YAML.** Skills, roles and prompt templates use YAML 1.2 core scalars and folding through `yaml`. Custom tags and aliases are refused; nested fields remain unsupported except the role memory mapping. Duplicate keys keep their last value. On a YAML syntax error, the reader retries once with plain top-level text quoted and its continuation lines folded, so descriptions such as `Use when: foo` still load. A ` #` in an unquoted value starts a YAML comment, and `0x`/`0o` numbers parse as numbers; these differ from the old reader.
|
|
291
|
+
- **YAML.** Skills, roles and prompt templates use YAML 1.2 core scalars and folding through `yaml`. Custom tags are inert and aliases are refused; nested fields remain unsupported except the role memory mapping. Duplicate keys keep their last value. On a YAML syntax error or warning, the reader retries once with non-protected plain top-level text quoted and its continuation lines folded, so descriptions such as `Use when: foo` still load. A ` #` in an unquoted value starts a YAML comment, and `0x`/`0o` numbers parse as numbers; these differ from the old reader.
|
|
292
|
+
- **Bad lines.** Retry never rewrites protected entries (role behavior fields and skill invocation restrictions); their errors or warnings leave fields empty. Names and descriptions may still be quoted. Quote protected role values explicitly, for example `package: "@acme/tools"`; a value that needs recovery otherwise skips the role with a warning. Salvage runs only when no protected name appears anywhere in raw frontmatter as a case-insensitive substring. It accepts simple letter-start keys, blanks, comments and plain-text stray lines without YAML indicator prefixes; indented content must belong to a key. Other shapes, ambiguous line breaks, multiline or unclosed flows/quotes, and keep-chomping blocks fail closed with their problems. A single isolated plain-text stray followed by another key is dropped with one warning and its original line number. A stray as the last frontmatter line, or more than one consecutive stray, leaves fields empty with the problems, as before. Salvage only blanks whole entries or that isolated stray; it never joins, truncates or reinterprets retained values. Clean YAML is unchanged, and whole-document parsing is bounded to three attempts.
|
|
293
|
+
|
|
292
294
|
- **Problems.** A problem (a missing description, a bad name, a collision, a YAML error with its line number) becomes one lick with `severity="warn"` per distinct problem. A skill without a description is skipped; any other problem only warns.
|
|
293
295
|
- **Untrusted folders.** A project's `.pi/skills` and `.agents/skills` are read only in trusted folders, which come with PR 21.
|
|
294
296
|
|
|
@@ -33,11 +33,11 @@ function retryValue(raw, source) {
|
|
|
33
33
|
const typed = clean && isScalar(scalar.contents) && typeof scalar.contents.value !== "string";
|
|
34
34
|
return typed ? raw : JSON.stringify(raw);
|
|
35
35
|
}
|
|
36
|
-
function tolerantSource(source) {
|
|
36
|
+
function tolerantSource(source, protectedKeys) {
|
|
37
37
|
const lines = source.split("\n");
|
|
38
38
|
for (let index = 0; index < lines.length; index++) {
|
|
39
39
|
const found = /^([A-Za-z][\w-]*):[ \t]+(.*)$/.exec(lines[index]);
|
|
40
|
-
if (!found) continue;
|
|
40
|
+
if (!found || protectedKeys.includes(found[1])) continue;
|
|
41
41
|
const value = found[2].replace(/[ \t]+#.*$/, "").trim();
|
|
42
42
|
if (!value || value.startsWith("#") || /^["']/.test(value) || /^[|>](?:[1-9][+-]?|[+-][1-9]?)?$/.test(value))
|
|
43
43
|
continue;
|
|
@@ -68,7 +68,61 @@ function tolerantSource(source) {
|
|
|
68
68
|
}
|
|
69
69
|
return lines.join("\n");
|
|
70
70
|
}
|
|
71
|
-
function
|
|
71
|
+
function entryBoundaries(source) {
|
|
72
|
+
if (/[\r\u0085\u2028\u2029]/.test(source)) return void 0;
|
|
73
|
+
const lines = source.split("\n");
|
|
74
|
+
const owners = [0];
|
|
75
|
+
const ends = /* @__PURE__ */ new Map();
|
|
76
|
+
let owner = 0;
|
|
77
|
+
let keyOwner = false;
|
|
78
|
+
for (let index = 1; index < lines.length; index++) {
|
|
79
|
+
const line = lines[index];
|
|
80
|
+
if (line.startsWith(" ")) return void 0;
|
|
81
|
+
if (!/^ *$/.test(line) && !/^ *#/.test(line)) {
|
|
82
|
+
if (line.startsWith(" ")) {
|
|
83
|
+
if (!keyOwner) return void 0;
|
|
84
|
+
} else {
|
|
85
|
+
const key = /^[A-Za-z][\w-]*:(?:[ \t]|$)/.test(line);
|
|
86
|
+
if (!key && (/^\s/.test(line) || /:(?:[ \t]|$)/.test(line) || `?:-[]{}#&*!|>'"%@\``.includes(line[0])))
|
|
87
|
+
return void 0;
|
|
88
|
+
ends.set(owner, index);
|
|
89
|
+
owner = index;
|
|
90
|
+
keyOwner = key;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
owners.push(owner);
|
|
94
|
+
}
|
|
95
|
+
ends.set(owner, lines.length);
|
|
96
|
+
return { lines, owners, ends };
|
|
97
|
+
}
|
|
98
|
+
function salvageSource(source, retried, protectedKeys, issues, counter) {
|
|
99
|
+
const lower = source.toLowerCase();
|
|
100
|
+
if (protectedKeys.some((key) => lower.includes(key.toLowerCase()))) return void 0;
|
|
101
|
+
const boundaries = entryBoundaries(source);
|
|
102
|
+
if (!boundaries) return void 0;
|
|
103
|
+
const { lines, owners, ends } = boundaries;
|
|
104
|
+
const dropped = /* @__PURE__ */ new Map();
|
|
105
|
+
for (const issue of issues) {
|
|
106
|
+
if (issue.code === "MISSING_CHAR") return void 0;
|
|
107
|
+
const index = counter.linePos(issue.pos[0]).line - 1;
|
|
108
|
+
const line = lines[index];
|
|
109
|
+
if (!line?.trim() || index === 0) return void 0;
|
|
110
|
+
const start = owners[index];
|
|
111
|
+
if (dropped.has(start)) continue;
|
|
112
|
+
dropped.set(start, {
|
|
113
|
+
end: ends.get(start),
|
|
114
|
+
message: issue.message
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const removed = /* @__PURE__ */ new Set();
|
|
118
|
+
for (const [start, { end }] of dropped)
|
|
119
|
+
for (let index = start; index < end; index++) removed.add(index);
|
|
120
|
+
return {
|
|
121
|
+
source: retried.split("\n").map((line, index) => removed.has(index) ? "" : line).join("\n"),
|
|
122
|
+
problems: [...dropped.values()].map(({ message }) => message)
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function parseFrontmatter(text, mappings = [], protectedKeys = []) {
|
|
72
126
|
const normalized = text.replace(/\r\n/g, "\n");
|
|
73
127
|
const match = /^---\n([\s\S]*?)\n---(?:\n|$)/.exec(normalized);
|
|
74
128
|
if (!match)
|
|
@@ -86,12 +140,42 @@ function parseFrontmatter(text, mappings = []) {
|
|
|
86
140
|
${match[1]}
|
|
87
141
|
`;
|
|
88
142
|
let document = parseDocument(source, { ...options, lineCounter });
|
|
89
|
-
|
|
143
|
+
let retried = source;
|
|
144
|
+
if (document.errors.length || document.warnings.length) {
|
|
145
|
+
let ambiguous = false;
|
|
146
|
+
visit(document, (_, node) => {
|
|
147
|
+
if (!isCollection(node) && !isScalar(node) || !node.range) return;
|
|
148
|
+
const [start, end] = node.range;
|
|
149
|
+
if (isCollection(node) && node.flow && (lineCounter.linePos(start).line !== lineCounter.linePos(end - 1).line || source[end - 1] !== "}" && source[end - 1] !== "]") || isScalar(node) && ((node.type === "QUOTE_DOUBLE" || node.type === "QUOTE_SINGLE") && lineCounter.linePos(start).line !== lineCounter.linePos(end - 1).line || (node.type === "BLOCK_LITERAL" || node.type === "BLOCK_FOLDED") && /^[|>][^\n]*\+/.test(source.slice(start, end))))
|
|
150
|
+
ambiguous = true;
|
|
151
|
+
});
|
|
152
|
+
if (ambiguous)
|
|
153
|
+
return {
|
|
154
|
+
fields: {},
|
|
155
|
+
body,
|
|
156
|
+
problems: [...document.errors, ...document.warnings].map((issue) => issue.message)
|
|
157
|
+
};
|
|
158
|
+
retried = tolerantSource(source, protectedKeys);
|
|
159
|
+
lineCounter = new LineCounter();
|
|
160
|
+
document = parseDocument(retried, { ...options, lineCounter });
|
|
161
|
+
}
|
|
162
|
+
let issues = [...document.errors, ...document.warnings];
|
|
163
|
+
const problems = [];
|
|
164
|
+
if (issues.length) {
|
|
165
|
+
const salvaged = salvageSource(source, retried, protectedKeys, issues, lineCounter);
|
|
166
|
+
if (!salvaged) return { fields: {}, body, problems: issues.map((issue) => issue.message) };
|
|
167
|
+
problems.push(...salvaged.problems);
|
|
90
168
|
lineCounter = new LineCounter();
|
|
91
|
-
document = parseDocument(
|
|
169
|
+
document = parseDocument(salvaged.source, { ...options, lineCounter });
|
|
170
|
+
issues = [...document.errors, ...document.warnings];
|
|
171
|
+
if (issues.length) {
|
|
172
|
+
for (const issue of issues) {
|
|
173
|
+
const line = lineCounter.linePos(issue.pos[0]).line;
|
|
174
|
+
problems.push(`${issue.message.split(" at line ")[0]} at line ${line}`);
|
|
175
|
+
}
|
|
176
|
+
return { fields: {}, body, problems };
|
|
177
|
+
}
|
|
92
178
|
}
|
|
93
|
-
const problems = [...document.errors, ...document.warnings].map((error) => error.message);
|
|
94
|
-
if (problems.length) return { fields: {}, body, problems };
|
|
95
179
|
let aliasOffset = 0;
|
|
96
180
|
visit(document, (_, node) => {
|
|
97
181
|
if (!isAlias(node)) return;
|
|
@@ -102,8 +186,12 @@ ${match[1]}
|
|
|
102
186
|
try {
|
|
103
187
|
parsed = document.toJS({ mapAsMap: true, maxAliasCount: 0 });
|
|
104
188
|
} catch (error) {
|
|
105
|
-
const
|
|
106
|
-
return {
|
|
189
|
+
const line = lineCounter.linePos(aliasOffset).line;
|
|
190
|
+
return {
|
|
191
|
+
fields: {},
|
|
192
|
+
body,
|
|
193
|
+
problems: [...problems, `${error.message} at line ${line}`]
|
|
194
|
+
};
|
|
107
195
|
}
|
|
108
196
|
return { fields: fieldsFrom(parsed, mappings, problems), body, problems };
|
|
109
197
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/roles/frontmatter.ts"],
|
|
4
|
-
"sourcesContent": ["import { isAlias, isCollection, isScalar, LineCounter, parseDocument, visit } from 'yaml';\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport interface Frontmatter {\n fields: Record<string, FrontmatterValue>;\n body: string;\n problems: string[];\n}\n\nfunction primitive(value: unknown): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n\nfunction fieldsFrom(\n parsed: unknown,\n mappings: readonly string[],\n problems: string[]\n): Record<string, FrontmatterValue> {\n if (parsed === null) return {};\n if (!(parsed instanceof Map)) {\n problems.push('frontmatter must be a mapping');\n return {};\n }\n const fields = new Map<string, FrontmatterValue>();\n for (const [key, value] of parsed) {\n if (primitive(value)) fields.set(key, value);\n else if (value === null) fields.set(key, []);\n else if (Array.isArray(value) && value.every((item) => typeof item === 'string'))\n fields.set(key, value);\n else if (\n value instanceof Map &&\n mappings.includes(key) &&\n [...value].every(([name, item]) => typeof name === 'string' && primitive(item))\n )\n fields.set(key, `{ ${[...value].map(([name, item]) => `${name}: ${item}`).join(', ')} }`);\n else if (value instanceof Map)\n problems.push(`\"${key}\" has nested values, which SLICC doesn't read`);\n else problems.push(`\"${key}\" needs a scalar or a list of strings`);\n }\n return Object.fromEntries(fields);\n}\n\nfunction retryValue(raw: string, source: string): string | undefined {\n const scalar = parseDocument(source, {\n schema: 'core',\n customTags: [],\n resolveKnownTags: false,\n });\n const clean = !scalar.errors.length && !scalar.warnings.length;\n if (/^[[{]/.test(raw) && clean && isCollection(scalar.contents)) return undefined;\n const typed = clean && isScalar(scalar.contents) && typeof scalar.contents.value !== 'string';\n return typed ? raw : JSON.stringify(raw);\n}\n\nfunction tolerantSource(source: string): string {\n const lines = source.split('\\n');\n for (let index = 0; index < lines.length; index++) {\n const found = /^([A-Za-z][\\w-]*):[ \\t]+(.*)$/.exec(lines[index] as string);\n if (!found) continue;\n const value = (found[2] as string).replace(/[ \\t]+#.*$/, '').trim();\n if (\n !value ||\n value.startsWith('#') ||\n /^[\"']/.test(value) ||\n /^[|>](?:[1-9][+-]?|[+-][1-9]?)?$/.test(value)\n )\n continue;\n let raw = value;\n let blanks = 0;\n const continuation: string[] = [];\n for (let next = index + 1; next < lines.length; next++) {\n const line = lines[next] as string;\n if (!line.trim()) {\n continuation.push(line);\n blanks++;\n continue;\n }\n if (line.trimStart().startsWith('#')) {\n continuation.push(line);\n continue;\n }\n if (!/^[ \\t]/.test(line)) break;\n continuation.push(line);\n const continued = line.replace(/[ \\t]+#.*$/, '').trim();\n raw += `${blanks ? '\\n'.repeat(blanks) : ' '}${continued}`;\n blanks = 0;\n }\n const quoted = retryValue(raw, [found[2], ...continuation].join('\\n'));\n if (quoted === undefined) continue;\n for (let offset = 1; offset <= continuation.length; offset++) lines[index + offset] = '';\n lines[index] = `${found[1]}: ${quoted}`;\n }\n return lines.join('\\n');\n}\n\nexport function parseFrontmatter(text: string
|
|
5
|
-
"mappings": "AAAA,SAAS,SAAS,cAAc,UA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QAAQ,KAAK,GAAG,KAAK,SAAS,aAAa,OAAO,QAAQ,EAAG,QAAO;AACxE,QAAM,QAAQ,SAAS,SAAS,OAAO,QAAQ,KAAK,OAAO,OAAO,SAAS,UAAU;AACrF,SAAO,QAAQ,MAAM,KAAK,UAAU,GAAG;AACzC;AAEA,SAAS,eAAe,
|
|
4
|
+
"sourcesContent": ["import { isAlias, isCollection, isScalar, LineCounter, parseDocument, visit } from 'yaml';\n\nexport type FrontmatterValue = string | number | boolean | string[];\n\nexport interface Frontmatter {\n fields: Record<string, FrontmatterValue>;\n body: string;\n problems: string[];\n}\n\nfunction primitive(value: unknown): value is string | number | boolean {\n return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';\n}\n\nfunction fieldsFrom(\n parsed: unknown,\n mappings: readonly string[],\n problems: string[]\n): Record<string, FrontmatterValue> {\n if (parsed === null) return {};\n if (!(parsed instanceof Map)) {\n problems.push('frontmatter must be a mapping');\n return {};\n }\n const fields = new Map<string, FrontmatterValue>();\n for (const [key, value] of parsed) {\n if (primitive(value)) fields.set(key, value);\n else if (value === null) fields.set(key, []);\n else if (Array.isArray(value) && value.every((item) => typeof item === 'string'))\n fields.set(key, value);\n else if (\n value instanceof Map &&\n mappings.includes(key) &&\n [...value].every(([name, item]) => typeof name === 'string' && primitive(item))\n )\n fields.set(key, `{ ${[...value].map(([name, item]) => `${name}: ${item}`).join(', ')} }`);\n else if (value instanceof Map)\n problems.push(`\"${key}\" has nested values, which SLICC doesn't read`);\n else problems.push(`\"${key}\" needs a scalar or a list of strings`);\n }\n return Object.fromEntries(fields);\n}\n\nfunction retryValue(raw: string, source: string): string | undefined {\n const scalar = parseDocument(source, {\n schema: 'core',\n customTags: [],\n resolveKnownTags: false,\n });\n const clean = !scalar.errors.length && !scalar.warnings.length;\n if (/^[[{]/.test(raw) && clean && isCollection(scalar.contents)) return undefined;\n const typed = clean && isScalar(scalar.contents) && typeof scalar.contents.value !== 'string';\n return typed ? raw : JSON.stringify(raw);\n}\n\nfunction tolerantSource(source: string, protectedKeys: readonly string[]): string {\n const lines = source.split('\\n');\n for (let index = 0; index < lines.length; index++) {\n const found = /^([A-Za-z][\\w-]*):[ \\t]+(.*)$/.exec(lines[index] as string);\n if (!found || protectedKeys.includes(found[1] as string)) continue;\n const value = (found[2] as string).replace(/[ \\t]+#.*$/, '').trim();\n if (\n !value ||\n value.startsWith('#') ||\n /^[\"']/.test(value) ||\n /^[|>](?:[1-9][+-]?|[+-][1-9]?)?$/.test(value)\n )\n continue;\n let raw = value;\n let blanks = 0;\n const continuation: string[] = [];\n for (let next = index + 1; next < lines.length; next++) {\n const line = lines[next] as string;\n if (!line.trim()) {\n continuation.push(line);\n blanks++;\n continue;\n }\n if (line.trimStart().startsWith('#')) {\n continuation.push(line);\n continue;\n }\n if (!/^[ \\t]/.test(line)) break;\n continuation.push(line);\n const continued = line.replace(/[ \\t]+#.*$/, '').trim();\n raw += `${blanks ? '\\n'.repeat(blanks) : ' '}${continued}`;\n blanks = 0;\n }\n const quoted = retryValue(raw, [found[2], ...continuation].join('\\n'));\n if (quoted === undefined) continue;\n for (let offset = 1; offset <= continuation.length; offset++) lines[index + offset] = '';\n lines[index] = `${found[1]}: ${quoted}`;\n }\n return lines.join('\\n');\n}\n\nfunction entryBoundaries(source: string) {\n if (/[\\r\\u0085\\u2028\\u2029]/.test(source)) return undefined;\n const lines = source.split('\\n');\n const owners: number[] = [0];\n const ends = new Map<number, number>();\n let owner = 0;\n let keyOwner = false;\n for (let index = 1; index < lines.length; index++) {\n const line = lines[index] as string;\n if (line.startsWith('\\t')) return undefined;\n if (!/^ *$/.test(line) && !/^ *#/.test(line)) {\n if (line.startsWith(' ')) {\n if (!keyOwner) return undefined;\n } else {\n const key = /^[A-Za-z][\\w-]*:(?:[ \\t]|$)/.test(line);\n if (\n !key &&\n (/^\\s/.test(line) ||\n /:(?:[ \\t]|$)/.test(line) ||\n `?:-[]{}#&*!|>'\"%@\\``.includes(line[0] as string))\n )\n return undefined;\n ends.set(owner, index);\n owner = index;\n keyOwner = key;\n }\n }\n owners.push(owner);\n }\n ends.set(owner, lines.length);\n return { lines, owners, ends };\n}\n\nfunction salvageSource(\n source: string,\n retried: string,\n protectedKeys: readonly string[],\n issues: readonly { pos: [number, number]; message: string; code: string }[],\n counter: LineCounter\n) {\n const lower = source.toLowerCase();\n if (protectedKeys.some((key) => lower.includes(key.toLowerCase()))) return undefined;\n const boundaries = entryBoundaries(source);\n if (!boundaries) return undefined;\n const { lines, owners, ends } = boundaries;\n const dropped = new Map<number, { end: number; message: string }>();\n for (const issue of issues) {\n if (issue.code === 'MISSING_CHAR') return undefined;\n const index = counter.linePos(issue.pos[0]).line - 1;\n const line = lines[index];\n if (!line?.trim() || index === 0) return undefined;\n const start = owners[index] as number;\n if (dropped.has(start)) continue;\n dropped.set(start, {\n end: ends.get(start) as number,\n message: issue.message,\n });\n }\n const removed = new Set<number>();\n for (const [start, { end }] of dropped)\n for (let index = start; index < end; index++) removed.add(index);\n return {\n source: retried\n .split('\\n')\n .map((line, index) => (removed.has(index) ? '' : line))\n .join('\\n'),\n problems: [...dropped.values()].map(({ message }) => message),\n };\n}\n\nexport function parseFrontmatter(\n text: string,\n mappings: readonly string[] = [],\n protectedKeys: readonly string[] = []\n): Frontmatter {\n const normalized = text.replace(/\\r\\n/g, '\\n');\n const match = /^---\\n([\\s\\S]*?)\\n---(?:\\n|$)/.exec(normalized);\n if (!match)\n return { fields: {}, body: normalized.trim(), problems: ['no frontmatter between --- lines'] };\n const body = normalized.slice(match[0].length).trim();\n let lineCounter = new LineCounter();\n const options = {\n schema: 'core',\n customTags: [],\n resolveKnownTags: false,\n stringKeys: true,\n uniqueKeys: false,\n };\n const source = `---\\n${match[1]}\\n`;\n let document = parseDocument(source, { ...options, lineCounter });\n let retried = source;\n if (document.errors.length || document.warnings.length) {\n let ambiguous = false;\n visit(document, (_, node) => {\n if ((!isCollection(node) && !isScalar(node)) || !node.range) return;\n const [start, end] = node.range;\n if (\n (isCollection(node) &&\n node.flow &&\n (lineCounter.linePos(start).line !== lineCounter.linePos(end - 1).line ||\n (source[end - 1] !== '}' && source[end - 1] !== ']'))) ||\n (isScalar(node) &&\n (((node.type === 'QUOTE_DOUBLE' || node.type === 'QUOTE_SINGLE') &&\n lineCounter.linePos(start).line !== lineCounter.linePos(end - 1).line) ||\n ((node.type === 'BLOCK_LITERAL' || node.type === 'BLOCK_FOLDED') &&\n /^[|>][^\\n]*\\+/.test(source.slice(start, end)))))\n )\n ambiguous = true;\n });\n if (ambiguous)\n return {\n fields: {},\n body,\n problems: [...document.errors, ...document.warnings].map((issue) => issue.message),\n };\n retried = tolerantSource(source, protectedKeys);\n lineCounter = new LineCounter();\n document = parseDocument(retried, { ...options, lineCounter });\n }\n let issues = [...document.errors, ...document.warnings];\n const problems: string[] = [];\n if (issues.length) {\n const salvaged = salvageSource(source, retried, protectedKeys, issues, lineCounter);\n if (!salvaged) return { fields: {}, body, problems: issues.map((issue) => issue.message) };\n problems.push(...salvaged.problems);\n lineCounter = new LineCounter();\n document = parseDocument(salvaged.source, { ...options, lineCounter });\n issues = [...document.errors, ...document.warnings];\n if (issues.length) {\n for (const issue of issues) {\n const line = lineCounter.linePos(issue.pos[0]).line;\n problems.push(`${issue.message.split(' at line ')[0]} at line ${line}`);\n }\n return { fields: {}, body, problems };\n }\n }\n let aliasOffset = 0;\n visit(document, (_, node) => {\n if (!isAlias(node)) return;\n aliasOffset = node.range?.[0] ?? 0;\n return visit.BREAK;\n });\n let parsed: unknown;\n try {\n parsed = document.toJS({ mapAsMap: true, maxAliasCount: 0 });\n } catch (error) {\n const line = lineCounter.linePos(aliasOffset).line;\n return {\n fields: {},\n body,\n problems: [...problems, `${(error as Error).message} at line ${line}`],\n };\n }\n return { fields: fieldsFrom(parsed, mappings, problems), body, problems };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,SAAS,cAAc,UAAU,aAAa,eAAe,aAAa;AAUnF,SAAS,UAAU,OAAoD;AACrE,SAAO,OAAO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94,7 +94,11 @@ function memoryFields(fields, path, warnings) {
|
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
96
|
function parseRole(text, source, path, warnings) {
|
|
97
|
-
const { fields, body, problems } = parseFrontmatter(
|
|
97
|
+
const { fields, body, problems } = parseFrontmatter(
|
|
98
|
+
text,
|
|
99
|
+
["memory"],
|
|
100
|
+
[...APPLIED].filter((key) => key !== "name" && key !== "description")
|
|
101
|
+
);
|
|
98
102
|
for (const problem of problems) warnings.push(`${path}: ${problem}`);
|
|
99
103
|
const name = fields.name;
|
|
100
104
|
const description = fields.description;
|
package/dist/roles/roles.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/roles/roles.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport type { RoleMemory } from '../memory/store.ts';\nimport { type FrontmatterValue, parseFrontmatter } from './frontmatter.ts';\n\nexport type RoleSource = 'builtin' | 'package' | 'user' | 'project';\nexport type Thinking = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';\n\nexport interface Role {\n name: string;\n description: string;\n prompt: string;\n mode: 'replace' | 'append';\n tools?: string[];\n model?: string;\n thinking?: Thinking;\n aliases: string[];\n output?: string;\n memory?: RoleMemory;\n context?: { project: boolean; global: boolean };\n source: RoleSource;\n path: string;\n}\n\nexport interface Roles {\n roles: Role[];\n warnings: string[];\n limits: { maxLiveScoops: number; maxPerTurn: number };\n}\n\nexport const DEFAULT_LIMITS = { maxLiveScoops: 16, maxPerTurn: 64 };\n\nconst TOOLS: Record<string, string> = {\n read: 'read',\n write: 'write',\n edit: 'edit',\n bash: 'bash',\n grep: 'bash',\n find: 'bash',\n ls: 'bash',\n memory_write: 'memory_write',\n};\n\nconst WRITERS = new Set(['write', 'edit', 'bash']);\n\nconst PASSED = new Set([\n 'codemode',\n 'list_mcp_resources',\n 'list_mcp_resource_templates',\n 'read_mcp_resource',\n]);\n\nfunction passThrough(name: string): boolean {\n return PASSED.has(name) || /^mcp__[A-Za-z0-9_*]+$/.test(name);\n}\n\nconst THINKING = new Set<string>(['off', 'minimal', 'low', 'medium', 'high', 'xhigh']);\n\nconst APPLIED = new Set([\n 'name',\n 'description',\n 'tools',\n 'model',\n 'thinking',\n 'systemPromptMode',\n 'aliases',\n 'output',\n 'package',\n 'advertise',\n 'inheritProjectContext',\n 'inheritGlobalContext',\n 'inheritSkills',\n 'memory',\n 'skills',\n 'defaultReads',\n]);\n\nexport type RoleFiles = Pick<ExecutionEnv, 'readTextFile' | 'listDir'>;\n\nexport interface RoleSourceDir {\n source: RoleSource;\n dir: string;\n}\n\nfunction list(value: FrontmatterValue | undefined): string[] {\n if (Array.isArray(value)) return value;\n if (typeof value === 'string')\n return value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n return [];\n}\n\nfunction tools(names: string[], where: string, warnings: string[]): string[] {\n const mapped: string[] = [];\n for (const name of names) {\n const tool = TOOLS[name] ?? (passThrough(name) ? name : undefined);\n if (tool) {\n if (!mapped.includes(tool)) mapped.push(tool);\n } else warnings.push(`${where}: tool \"${name}\" isn't available in SLICC; it's left out`);\n }\n return mapped;\n}\n\nexport function roleMemory(value: FrontmatterValue): RoleMemory | undefined {\n if (typeof value !== 'string') return undefined;\n const inline = /^\\{(.*)\\}$/s.exec(value.trim());\n const pairs = new Map<string, string>();\n for (const part of (inline ? (inline[1] as string) : value).split(/[,\\n]/)) {\n const found = /^\\s*([\\w-]+)\\s*:\\s*(.*?)\\s*$/.exec(part);\n if (found) pairs.set(found[1] as string, (found[2] as string).replace(/^([\"'])(.*)\\1$/, '$2'));\n }\n const scope = pairs.get('scope');\n const path = pairs.get('path');\n if ((scope !== 'user' && scope !== 'project') || !path) return undefined;\n return { scope, path };\n}\n\nfunction withMemoryWrite(\n listed: string[] | undefined,\n memory: RoleMemory | undefined\n): string[] | undefined {\n if (memory && listed?.some((tool) => WRITERS.has(tool)) && !listed.includes('memory_write'))\n return [...listed, 'memory_write'];\n return listed;\n}\n\nfunction memoryFields(\n fields: Record<string, FrontmatterValue>,\n path: string,\n warnings: string[]\n): Pick<Role, 'memory' | 'context'> & { listed: string[] | undefined } {\n const memory = fields.memory === undefined ? undefined : roleMemory(fields.memory);\n if (fields.memory !== undefined && !memory)\n warnings.push(`${path}: memory needs a scope (user or project) and a path; ignored`);\n const listed = withMemoryWrite(\n fields.tools !== undefined ? tools(list(fields.tools), path, warnings) : undefined,\n memory\n );\n const inherits =\n fields.inheritProjectContext !== undefined || fields.inheritGlobalContext !== undefined;\n return {\n ...(memory ? { memory } : {}),\n listed,\n ...(inherits\n ? {\n context: {\n project: fields.inheritProjectContext !== false,\n global: fields.inheritGlobalContext === true,\n },\n }\n : {}),\n };\n}\n\nexport function parseRole(\n text: string,\n source: RoleSource,\n path: string,\n warnings: string[]\n): Role | undefined {\n const { fields, body, problems } = parseFrontmatter(text, ['memory']);\n for (const problem of problems) warnings.push(`${path}: ${problem}`);\n const name = fields.name;\n const description = fields.description;\n if (typeof name !== 'string' || typeof description !== 'string') {\n warnings.push(`${path}: an agent file needs a name and a description; skipped`);\n return undefined;\n }\n for (const key of Object.keys(fields))\n if (!APPLIED.has(key))\n warnings.push(`${path}: \"${key}\" isn't supported in SLICC; it's ignored`);\n const thinking =\n typeof fields.thinking === 'string' && THINKING.has(fields.thinking)\n ? (fields.thinking as Thinking)\n : undefined;\n if (fields.thinking !== undefined && !thinking)\n warnings.push(`${path}: thinking \"${String(fields.thinking)}\" is unknown; ignored`);\n const { memory, listed, context } = memoryFields(fields, path, warnings);\n const pkg = typeof fields.package === 'string' && fields.package ? `${fields.package}.` : '';\n return {\n name: `${pkg}${name}`,\n description,\n prompt: body,\n mode: fields.systemPromptMode === 'append' ? 'append' : 'replace',\n ...(listed ? { tools: listed } : {}),\n ...(typeof fields.model === 'string' ? { model: fields.model } : {}),\n ...(thinking ? { thinking } : {}),\n aliases: list(fields.aliases),\n ...(typeof fields.output === 'string' ? { output: fields.output } : {}),\n ...(memory ? { memory } : {}),\n ...(context ? { context } : {}),\n source,\n path,\n };\n}\n\nasync function markdown(\n files: RoleFiles,\n dir: string,\n context: Context,\n depth = 0\n): Promise<string[]> {\n if (dir.endsWith('.md')) return [dir];\n const listed = await files.listDir(dir, context);\n if (!listed.ok || depth > 4) return [];\n const out: string[] = [];\n for (const info of listed.value) {\n const path = `${dir}/${info.name}`;\n if (info.kind === 'directory') out.push(...(await markdown(files, path, context, depth + 1)));\n else if (info.name.endsWith('.md') && !info.name.endsWith('.chain.md')) out.push(path);\n }\n return out.sort();\n}\n\ntype Override = {\n model?: unknown;\n thinking?: unknown;\n tools?: unknown;\n systemPrompt?: unknown;\n description?: unknown;\n disabled?: unknown;\n};\n\ninterface Settings {\n overrides: Record<string, Override>;\n limits: Roles['limits'];\n}\n\nfunction positive(value: unknown, fallback: number): number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : fallback;\n}\n\nasync function settings(\n files: RoleFiles,\n path: string,\n context: Context,\n warnings: string[]\n): Promise<Settings> {\n const read = await files.readTextFile(path, context);\n const empty = { overrides: {}, limits: { ...DEFAULT_LIMITS } };\n if (!read.ok) return empty;\n let parsed: {\n subagents?: {\n agentOverrides?: Record<string, Override>;\n maxLiveScoops?: unknown;\n maxPerTurn?: unknown;\n };\n };\n try {\n parsed = JSON.parse(read.value);\n } catch (error) {\n warnings.push(`${path}: not valid JSON (${(error as Error).message}); overrides ignored`);\n return empty;\n }\n const subagents = parsed.subagents ?? {};\n return {\n overrides: subagents.agentOverrides ?? {},\n limits: {\n maxLiveScoops: positive(subagents.maxLiveScoops, DEFAULT_LIMITS.maxLiveScoops),\n maxPerTurn: positive(subagents.maxPerTurn, DEFAULT_LIMITS.maxPerTurn),\n },\n };\n}\n\nfunction apply(role: Role, override: Override | undefined, warnings: string[]): Role | undefined {\n if (!override) return role;\n if (override.disabled === true) return undefined;\n const next: Role = { ...role };\n if (typeof override.model === 'string') next.model = override.model;\n if (typeof override.thinking === 'string' && THINKING.has(override.thinking))\n next.thinking = override.thinking as Thinking;\n if (typeof override.description === 'string') next.description = override.description;\n if (typeof override.systemPrompt === 'string') next.prompt = override.systemPrompt;\n if (Array.isArray(override.tools))\n next.tools = withMemoryWrite(\n tools(override.tools.map(String), `override for ${role.name}`, warnings),\n role.memory\n );\n return next;\n}\n\nexport interface LoadOptions {\n files: RoleFiles;\n builtin: () => Promise<{ path: string; text: string }[]>;\n dirs: RoleSourceDir[];\n settingsPath: string;\n}\n\nconst ORDER: RoleSource[] = ['project', 'user', 'builtin', 'package'];\n\nexport async function loadRoles(options: LoadOptions, context: Context): Promise<Roles> {\n const warnings: string[] = [];\n const byName = new Map<string, Role>();\n const add = (role: Role | undefined) => {\n if (!role) return;\n const earlier = byName.get(role.name);\n if (!earlier) byName.set(role.name, role);\n else if (role.source === 'package')\n warnings.push(\n `${role.path}: role \"${role.name}\" is already provided by ${earlier.path}; ignored`\n );\n };\n const dirs = [...options.dirs].sort((a, b) => ORDER.indexOf(a.source) - ORDER.indexOf(b.source));\n const read = async (dir: RoleSourceDir) => {\n for (const path of await markdown(options.files, dir.dir, context)) {\n const text = await options.files.readTextFile(path, context);\n if (text.ok) add(parseRole(text.value, dir.source, path, warnings));\n }\n };\n for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) < 2)) await read(dir);\n for (const { path, text } of await options.builtin())\n add(parseRole(text, 'builtin', path, warnings));\n for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) >= 2)) await read(dir);\n const { overrides, limits } = await settings(\n options.files,\n options.settingsPath,\n context,\n warnings\n );\n const roles: Role[] = [];\n for (const role of byName.values()) {\n const applied = apply(role, overrides[role.name], warnings);\n if (applied) roles.push(applied);\n }\n return { roles, warnings, limits };\n}\n\nexport function findRole(roles: readonly Role[], name: string): Role | undefined {\n return (\n roles.find((role) => role.name === name) ?? roles.find((role) => role.aliases.includes(name))\n );\n}\n\nfunction folder(kind: string): boolean {\n return kind === 'directory' || kind === 'symlink';\n}\n\nexport async function manifestDirs(\n files: RoleFiles,\n root: string,\n context: Context\n): Promise<string[]> {\n const top = await files.listDir(root, context);\n if (!top.ok) return [];\n const out: string[] = [];\n for (const entry of top.value) {\n if (!folder(entry.kind) || entry.name.startsWith('.')) continue;\n if (!entry.name.startsWith('@')) {\n out.push(`${root}/${entry.name}`);\n continue;\n }\n const scoped = await files.listDir(`${root}/${entry.name}`, context);\n if (scoped.ok)\n for (const inner of scoped.value)\n if (folder(inner.kind)) out.push(`${root}/${entry.name}/${inner.name}`);\n }\n return out;\n}\n\ntype Manifest = {\n 'pi-subagents'?: { agents?: unknown };\n pi?: { subagents?: { agents?: unknown } };\n};\n\nexport function agentPaths(dir: string, text: string): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const agents = manifest['pi-subagents']?.agents ?? manifest.pi?.subagents?.agents;\n const listed = Array.isArray(agents) ? agents : typeof agents === 'string' ? [agents] : [];\n return listed\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nexport const PACKAGE_ROOTS = ['/node_modules', '/opt/user/node_modules'];\n\nexport interface PiPackage {\n dir: string;\n manifest: string;\n}\n\nexport interface PiPackages {\n packages: PiPackage[];\n skipped: { path: string; message: string }[];\n}\n\nfunction declaresPi(text: string): boolean {\n try {\n const manifest = JSON.parse(text) as Record<string, unknown>;\n return manifest.pi !== undefined || manifest['pi-subagents'] !== undefined;\n } catch {\n return false;\n }\n}\n\nexport async function piPackages(\n files: RoleFiles,\n roots: readonly string[],\n context: Context\n): Promise<PiPackages> {\n const out: PiPackages = { packages: [], skipped: [] };\n const seen = new Map<string, string>();\n for (const root of roots)\n for (const dir of await manifestDirs(files, root, context)) {\n const read = await files.readTextFile(`${dir}/package.json`, context);\n if (!read.ok) continue;\n const name = dir.slice(root.length + 1);\n const earlier = seen.get(name);\n if (earlier === undefined) {\n seen.set(name, dir);\n out.packages.push({ dir, manifest: read.value });\n } else if (declaresPi(read.value))\n out.skipped.push({\n path: dir,\n message: `package \"${name}\" is already installed at ${earlier}, so this copy's skills, prompts and roles are ignored`,\n });\n }\n return out;\n}\n\nexport async function packageDirs(\n files: RoleFiles,\n roots: readonly string[],\n context: Context\n): Promise<string[]> {\n const { packages } = await piPackages(files, roots, context);\n return packages.flatMap(({ dir, manifest }) => agentPaths(dir, manifest));\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAgC,wBAAwB;AA2BjD,MAAM,iBAAiB,EAAE,eAAe,IAAI,YAAY,GAAG;AAElE,MAAM,QAAgC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,cAAc;AAChB;AAEA,MAAM,UAAU,oBAAI,IAAI,CAAC,SAAS,QAAQ,MAAM,CAAC;AAEjD,MAAM,SAAS,oBAAI,IAAI;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,YAAY,MAAuB;AAC1C,SAAO,OAAO,IAAI,IAAI,KAAK,wBAAwB,KAAK,IAAI;AAC9D;AAEA,MAAM,WAAW,oBAAI,IAAY,CAAC,OAAO,WAAW,OAAO,UAAU,QAAQ,OAAO,CAAC;AAErF,MAAM,UAAU,oBAAI,IAAI;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASD,SAAS,KAAK,OAA+C;AAC3D,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO;AACjC,MAAI,OAAO,UAAU;AACnB,WAAO,MACJ,MAAM,GAAG,E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AAC;AAClC,aAAS,KAAK,GAAG,IAAI,8DAA8D;AACrF,QAAM,SAAS;AAAA,IACb,OAAO,UAAU,SAAY,MAAM,KAAK,OAAO,KAAK,GAAG,MAAM,QAAQ,IAAI;AAAA,IACzE;AAAA,EACF;AACA,QAAM,WACJ,OAAO,0BAA0B,UAAa,OAAO,yBAAyB;AAChF,SAAO;AAAA,IACL,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,IAC3B;AAAA,IACA,GAAI,WACA;AAAA,MACE,SAAS;AAAA,QACP,SAAS,OAAO,0BAA0B;AAAA,QAC1C,QAAQ,OAAO,yBAAyB;AAAA,MAC1C;AAAA,IACF,IACA,CAAC;AAAA,EACP;AACF;AAEO,SAAS,UACd,MACA,QACA,MACA,UACkB;AAClB,QAAM,EAAE,QAAQ,MAAM,SAAS,IAAI,
|
|
4
|
+
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport type { RoleMemory } from '../memory/store.ts';\nimport { type FrontmatterValue, parseFrontmatter } from './frontmatter.ts';\n\nexport type RoleSource = 'builtin' | 'package' | 'user' | 'project';\nexport type Thinking = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';\n\nexport interface Role {\n name: string;\n description: string;\n prompt: string;\n mode: 'replace' | 'append';\n tools?: string[];\n model?: string;\n thinking?: Thinking;\n aliases: string[];\n output?: string;\n memory?: RoleMemory;\n context?: { project: boolean; global: boolean };\n source: RoleSource;\n path: string;\n}\n\nexport interface Roles {\n roles: Role[];\n warnings: string[];\n limits: { maxLiveScoops: number; maxPerTurn: number };\n}\n\nexport const DEFAULT_LIMITS = { maxLiveScoops: 16, maxPerTurn: 64 };\n\nconst TOOLS: Record<string, string> = {\n read: 'read',\n write: 'write',\n edit: 'edit',\n bash: 'bash',\n grep: 'bash',\n find: 'bash',\n ls: 'bash',\n memory_write: 'memory_write',\n};\n\nconst WRITERS = new Set(['write', 'edit', 'bash']);\n\nconst PASSED = new Set([\n 'codemode',\n 'list_mcp_resources',\n 'list_mcp_resource_templates',\n 'read_mcp_resource',\n]);\n\nfunction passThrough(name: string): boolean {\n return PASSED.has(name) || /^mcp__[A-Za-z0-9_*]+$/.test(name);\n}\n\nconst THINKING = new Set<string>(['off', 'minimal', 'low', 'medium', 'high', 'xhigh']);\n\nconst APPLIED = new Set([\n 'name',\n 'description',\n 'tools',\n 'model',\n 'thinking',\n 'systemPromptMode',\n 'aliases',\n 'output',\n 'package',\n 'advertise',\n 'inheritProjectContext',\n 'inheritGlobalContext',\n 'inheritSkills',\n 'memory',\n 'skills',\n 'defaultReads',\n]);\n\nexport type RoleFiles = Pick<ExecutionEnv, 'readTextFile' | 'listDir'>;\n\nexport interface RoleSourceDir {\n source: RoleSource;\n dir: string;\n}\n\nfunction list(value: FrontmatterValue | undefined): string[] {\n if (Array.isArray(value)) return value;\n if (typeof value === 'string')\n return value\n .split(',')\n .map((item) => item.trim())\n .filter(Boolean);\n return [];\n}\n\nfunction tools(names: string[], where: string, warnings: string[]): string[] {\n const mapped: string[] = [];\n for (const name of names) {\n const tool = TOOLS[name] ?? (passThrough(name) ? name : undefined);\n if (tool) {\n if (!mapped.includes(tool)) mapped.push(tool);\n } else warnings.push(`${where}: tool \"${name}\" isn't available in SLICC; it's left out`);\n }\n return mapped;\n}\n\nexport function roleMemory(value: FrontmatterValue): RoleMemory | undefined {\n if (typeof value !== 'string') return undefined;\n const inline = /^\\{(.*)\\}$/s.exec(value.trim());\n const pairs = new Map<string, string>();\n for (const part of (inline ? (inline[1] as string) : value).split(/[,\\n]/)) {\n const found = /^\\s*([\\w-]+)\\s*:\\s*(.*?)\\s*$/.exec(part);\n if (found) pairs.set(found[1] as string, (found[2] as string).replace(/^([\"'])(.*)\\1$/, '$2'));\n }\n const scope = pairs.get('scope');\n const path = pairs.get('path');\n if ((scope !== 'user' && scope !== 'project') || !path) return undefined;\n return { scope, path };\n}\n\nfunction withMemoryWrite(\n listed: string[] | undefined,\n memory: RoleMemory | undefined\n): string[] | undefined {\n if (memory && listed?.some((tool) => WRITERS.has(tool)) && !listed.includes('memory_write'))\n return [...listed, 'memory_write'];\n return listed;\n}\n\nfunction memoryFields(\n fields: Record<string, FrontmatterValue>,\n path: string,\n warnings: string[]\n): Pick<Role, 'memory' | 'context'> & { listed: string[] | undefined } {\n const memory = fields.memory === undefined ? undefined : roleMemory(fields.memory);\n if (fields.memory !== undefined && !memory)\n warnings.push(`${path}: memory needs a scope (user or project) and a path; ignored`);\n const listed = withMemoryWrite(\n fields.tools !== undefined ? tools(list(fields.tools), path, warnings) : undefined,\n memory\n );\n const inherits =\n fields.inheritProjectContext !== undefined || fields.inheritGlobalContext !== undefined;\n return {\n ...(memory ? { memory } : {}),\n listed,\n ...(inherits\n ? {\n context: {\n project: fields.inheritProjectContext !== false,\n global: fields.inheritGlobalContext === true,\n },\n }\n : {}),\n };\n}\n\nexport function parseRole(\n text: string,\n source: RoleSource,\n path: string,\n warnings: string[]\n): Role | undefined {\n const { fields, body, problems } = parseFrontmatter(\n text,\n ['memory'],\n [...APPLIED].filter((key) => key !== 'name' && key !== 'description')\n );\n for (const problem of problems) warnings.push(`${path}: ${problem}`);\n const name = fields.name;\n const description = fields.description;\n if (typeof name !== 'string' || typeof description !== 'string') {\n warnings.push(`${path}: an agent file needs a name and a description; skipped`);\n return undefined;\n }\n for (const key of Object.keys(fields))\n if (!APPLIED.has(key))\n warnings.push(`${path}: \"${key}\" isn't supported in SLICC; it's ignored`);\n const thinking =\n typeof fields.thinking === 'string' && THINKING.has(fields.thinking)\n ? (fields.thinking as Thinking)\n : undefined;\n if (fields.thinking !== undefined && !thinking)\n warnings.push(`${path}: thinking \"${String(fields.thinking)}\" is unknown; ignored`);\n const { memory, listed, context } = memoryFields(fields, path, warnings);\n const pkg = typeof fields.package === 'string' && fields.package ? `${fields.package}.` : '';\n return {\n name: `${pkg}${name}`,\n description,\n prompt: body,\n mode: fields.systemPromptMode === 'append' ? 'append' : 'replace',\n ...(listed ? { tools: listed } : {}),\n ...(typeof fields.model === 'string' ? { model: fields.model } : {}),\n ...(thinking ? { thinking } : {}),\n aliases: list(fields.aliases),\n ...(typeof fields.output === 'string' ? { output: fields.output } : {}),\n ...(memory ? { memory } : {}),\n ...(context ? { context } : {}),\n source,\n path,\n };\n}\n\nasync function markdown(\n files: RoleFiles,\n dir: string,\n context: Context,\n depth = 0\n): Promise<string[]> {\n if (dir.endsWith('.md')) return [dir];\n const listed = await files.listDir(dir, context);\n if (!listed.ok || depth > 4) return [];\n const out: string[] = [];\n for (const info of listed.value) {\n const path = `${dir}/${info.name}`;\n if (info.kind === 'directory') out.push(...(await markdown(files, path, context, depth + 1)));\n else if (info.name.endsWith('.md') && !info.name.endsWith('.chain.md')) out.push(path);\n }\n return out.sort();\n}\n\ntype Override = {\n model?: unknown;\n thinking?: unknown;\n tools?: unknown;\n systemPrompt?: unknown;\n description?: unknown;\n disabled?: unknown;\n};\n\ninterface Settings {\n overrides: Record<string, Override>;\n limits: Roles['limits'];\n}\n\nfunction positive(value: unknown, fallback: number): number {\n return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : fallback;\n}\n\nasync function settings(\n files: RoleFiles,\n path: string,\n context: Context,\n warnings: string[]\n): Promise<Settings> {\n const read = await files.readTextFile(path, context);\n const empty = { overrides: {}, limits: { ...DEFAULT_LIMITS } };\n if (!read.ok) return empty;\n let parsed: {\n subagents?: {\n agentOverrides?: Record<string, Override>;\n maxLiveScoops?: unknown;\n maxPerTurn?: unknown;\n };\n };\n try {\n parsed = JSON.parse(read.value);\n } catch (error) {\n warnings.push(`${path}: not valid JSON (${(error as Error).message}); overrides ignored`);\n return empty;\n }\n const subagents = parsed.subagents ?? {};\n return {\n overrides: subagents.agentOverrides ?? {},\n limits: {\n maxLiveScoops: positive(subagents.maxLiveScoops, DEFAULT_LIMITS.maxLiveScoops),\n maxPerTurn: positive(subagents.maxPerTurn, DEFAULT_LIMITS.maxPerTurn),\n },\n };\n}\n\nfunction apply(role: Role, override: Override | undefined, warnings: string[]): Role | undefined {\n if (!override) return role;\n if (override.disabled === true) return undefined;\n const next: Role = { ...role };\n if (typeof override.model === 'string') next.model = override.model;\n if (typeof override.thinking === 'string' && THINKING.has(override.thinking))\n next.thinking = override.thinking as Thinking;\n if (typeof override.description === 'string') next.description = override.description;\n if (typeof override.systemPrompt === 'string') next.prompt = override.systemPrompt;\n if (Array.isArray(override.tools))\n next.tools = withMemoryWrite(\n tools(override.tools.map(String), `override for ${role.name}`, warnings),\n role.memory\n );\n return next;\n}\n\nexport interface LoadOptions {\n files: RoleFiles;\n builtin: () => Promise<{ path: string; text: string }[]>;\n dirs: RoleSourceDir[];\n settingsPath: string;\n}\n\nconst ORDER: RoleSource[] = ['project', 'user', 'builtin', 'package'];\n\nexport async function loadRoles(options: LoadOptions, context: Context): Promise<Roles> {\n const warnings: string[] = [];\n const byName = new Map<string, Role>();\n const add = (role: Role | undefined) => {\n if (!role) return;\n const earlier = byName.get(role.name);\n if (!earlier) byName.set(role.name, role);\n else if (role.source === 'package')\n warnings.push(\n `${role.path}: role \"${role.name}\" is already provided by ${earlier.path}; ignored`\n );\n };\n const dirs = [...options.dirs].sort((a, b) => ORDER.indexOf(a.source) - ORDER.indexOf(b.source));\n const read = async (dir: RoleSourceDir) => {\n for (const path of await markdown(options.files, dir.dir, context)) {\n const text = await options.files.readTextFile(path, context);\n if (text.ok) add(parseRole(text.value, dir.source, path, warnings));\n }\n };\n for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) < 2)) await read(dir);\n for (const { path, text } of await options.builtin())\n add(parseRole(text, 'builtin', path, warnings));\n for (const dir of dirs.filter((item) => ORDER.indexOf(item.source) >= 2)) await read(dir);\n const { overrides, limits } = await settings(\n options.files,\n options.settingsPath,\n context,\n warnings\n );\n const roles: Role[] = [];\n for (const role of byName.values()) {\n const applied = apply(role, overrides[role.name], warnings);\n if (applied) roles.push(applied);\n }\n return { roles, warnings, limits };\n}\n\nexport function findRole(roles: readonly Role[], name: string): Role | undefined {\n return (\n roles.find((role) => role.name === name) ?? roles.find((role) => role.aliases.includes(name))\n );\n}\n\nfunction folder(kind: string): boolean {\n return kind === 'directory' || kind === 'symlink';\n}\n\nexport async function manifestDirs(\n files: RoleFiles,\n root: string,\n context: Context\n): Promise<string[]> {\n const top = await files.listDir(root, context);\n if (!top.ok) return [];\n const out: string[] = [];\n for (const entry of top.value) {\n if (!folder(entry.kind) || entry.name.startsWith('.')) continue;\n if (!entry.name.startsWith('@')) {\n out.push(`${root}/${entry.name}`);\n continue;\n }\n const scoped = await files.listDir(`${root}/${entry.name}`, context);\n if (scoped.ok)\n for (const inner of scoped.value)\n if (folder(inner.kind)) out.push(`${root}/${entry.name}/${inner.name}`);\n }\n return out;\n}\n\ntype Manifest = {\n 'pi-subagents'?: { agents?: unknown };\n pi?: { subagents?: { agents?: unknown } };\n};\n\nexport function agentPaths(dir: string, text: string): string[] {\n let manifest: Manifest;\n try {\n manifest = JSON.parse(text) as Manifest;\n } catch {\n return [];\n }\n const agents = manifest['pi-subagents']?.agents ?? manifest.pi?.subagents?.agents;\n const listed = Array.isArray(agents) ? agents : typeof agents === 'string' ? [agents] : [];\n return listed\n .filter((path): path is string => typeof path === 'string')\n .map((path) => `${dir}/${path.replace(/^\\.\\//, '').replace(/\\/$/, '')}`);\n}\n\nexport const PACKAGE_ROOTS = ['/node_modules', '/opt/user/node_modules'];\n\nexport interface PiPackage {\n dir: string;\n manifest: string;\n}\n\nexport interface PiPackages {\n packages: PiPackage[];\n skipped: { path: string; message: string }[];\n}\n\nfunction declaresPi(text: string): boolean {\n try {\n const manifest = JSON.parse(text) as Record<string, unknown>;\n return manifest.pi !== undefined || manifest['pi-subagents'] !== undefined;\n } catch {\n return false;\n }\n}\n\nexport async function piPackages(\n files: RoleFiles,\n roots: readonly string[],\n context: Context\n): Promise<PiPackages> {\n const out: PiPackages = { packages: [], skipped: [] };\n const seen = new Map<string, string>();\n for (const root of roots)\n for (const dir of await manifestDirs(files, root, context)) {\n const read = await files.readTextFile(`${dir}/package.json`, context);\n if (!read.ok) continue;\n const name = dir.slice(root.length + 1);\n const earlier = seen.get(name);\n if (earlier === undefined) {\n seen.set(name, dir);\n out.packages.push({ dir, manifest: read.value });\n } else if (declaresPi(read.value))\n out.skipped.push({\n path: dir,\n message: `package \"${name}\" is already installed at ${earlier}, so this copy's skills, prompts and roles are ignored`,\n });\n }\n return out;\n}\n\nexport async function packageDirs(\n files: RoleFiles,\n roots: readonly string[],\n context: Context\n): Promise<string[]> {\n const { packages } = await piPackages(files, roots, context);\n return packages.flatMap(({ dir, manifest }) => agentPaths(dir, manifest));\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAgC,wBAAwB;AA2BjD,MAAM,iBAAiB,EAAE,eAAe,IAAI,YAAY,GAAG;AAElE,MAAM,QAAgC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,MAAM;AAAA,EACN,IAAI;AAAA,EACJ,cAAc;AAChB;AAEA,MAAM,UAAU,oBAAI,IAAI,CAAC,SAAS,QAAQ,MAAM,CAAC;AAEjD,MAAM,SAAS,oBAAI,IAAI;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,YAAY,MAAuB;AAC1C,SAAO,OAAO,IAAI,IAAI,KAAK,wBAAwB,KAAK,IAAI;AAC9D;AAEA,MAAM,WAAW,oBAAI,IAAY,CAAC,OAAO,WAAW,OAAO,UAAU,QAAQ,OAAO,CAAC;AAErF,MAAM,UAAU,oBAAI,IAAI;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AASD,SAAS,KAAK,OAA+C;AAC3D,MAAI,MAA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Y,IAAI,6BAA6B,OAAO;AAAA,QAC/D,CAAC;AAAA,IACL;AACF,SAAO;AACT;AAEA,eAAsB,YACpB,OACA,OACA,SACmB;AACnB,QAAM,EAAE,SAAS,IAAI,MAAM,WAAW,OAAO,OAAO,OAAO;AAC3D,SAAO,SAAS,QAAQ,CAAC,EAAE,KAAK,SAAS,MAAM,WAAW,KAAK,QAAQ,CAAC;AAC1E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/skills/skills.js
CHANGED
|
@@ -28,7 +28,7 @@ function validateDescription(description) {
|
|
|
28
28
|
}
|
|
29
29
|
function skillFromText(text, filePath, source) {
|
|
30
30
|
const declared = basename(filePath) === "SKILL.md";
|
|
31
|
-
const { fields, problems } = parseFrontmatter(text);
|
|
31
|
+
const { fields, problems } = parseFrontmatter(text, [], ["disable-model-invocation"]);
|
|
32
32
|
const diagnostics = [];
|
|
33
33
|
const description = typeof fields.description === "string" ? fields.description.trim() : "";
|
|
34
34
|
if (!declared && !description) return { skills: [], diagnostics };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/skills/skills.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { parseFrontmatter } from '../roles/frontmatter.ts';\n\nexport const MAX_NAME_LENGTH = 64;\nexport const MAX_DESCRIPTION_LENGTH = 1024;\n\nexport type SkillFiles = Pick<ExecutionEnv, 'readTextFile' | 'listDir' | 'canonicalPath'>;\n\nexport type SkillSource = 'user' | 'global' | 'package' | 'builtin';\n\nexport const PNPM_DIR = '/usr/local/share/pnpm/';\n\nexport interface SkillPackage {\n name: string;\n version?: string;\n}\n\nexport interface Skill {\n name: string;\n description: string;\n filePath: string;\n baseDir: string;\n source: SkillSource;\n disableModelInvocation: boolean;\n package?: SkillPackage;\n}\n\nexport interface Diagnostic {\n path: string;\n message: string;\n}\n\nexport interface Loaded {\n skills: Skill[];\n diagnostics: Diagnostic[];\n}\n\nexport interface SkillRoot {\n dir: string;\n source: SkillSource;\n}\n\nfunction dirname(path: string): string {\n return path.slice(0, path.lastIndexOf('/')) || '/';\n}\n\nfunction basename(path: string): string {\n return path.slice(path.lastIndexOf('/') + 1);\n}\n\nexport function validateName(name: string): string[] {\n const errors: string[] = [];\n if (name.length > MAX_NAME_LENGTH)\n errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n if (!/^[a-z0-9-]+$/.test(name))\n errors.push('name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)');\n if (name.startsWith('-') || name.endsWith('-'))\n errors.push('name must not start or end with a hyphen');\n if (name.includes('--')) errors.push('name must not contain consecutive hyphens');\n return errors;\n}\n\nfunction validateDescription(description: unknown): string[] {\n if (typeof description !== 'string' || description.trim() === '')\n return ['description is required'];\n if (description.length > MAX_DESCRIPTION_LENGTH)\n return [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];\n return [];\n}\n\nexport function skillFromText(text: string, filePath: string, source: SkillSource): Loaded {\n const declared = basename(filePath) === 'SKILL.md';\n const { fields, problems } = parseFrontmatter(text);\n const diagnostics: Diagnostic[] = [];\n const description = typeof fields.description === 'string' ? fields.description.trim() : '';\n if (!declared && !description) return { skills: [], diagnostics };\n for (const problem of problems.filter((item) => !item.includes('nested values')))\n diagnostics.push({ path: filePath, message: problem });\n for (const message of validateDescription(description))\n diagnostics.push({ path: filePath, message });\n const baseDir = dirname(filePath);\n const name = (typeof fields.name === 'string' && fields.name) || basename(baseDir);\n for (const message of validateName(name)) diagnostics.push({ path: filePath, message });\n if (!description) return { skills: [], diagnostics };\n const skill: Skill = {\n name,\n description,\n filePath,\n baseDir,\n source,\n disableModelInvocation: fields['disable-model-invocation'] === true,\n };\n return { skills: [skill], diagnostics };\n}\n\nasync function loadFile(\n files: SkillFiles,\n filePath: string,\n source: SkillSource,\n context: Context\n): Promise<Loaded> {\n const read = await files.readTextFile(filePath, context);\n if (!read.ok)\n return { skills: [], diagnostics: [{ path: filePath, message: read.error.message }] };\n return skillFromText(read.value, filePath, source);\n}\n\nexport async function loadSkillsFromDir(\n files: SkillFiles,\n dir: string,\n source: SkillSource,\n context: Context,\n root = true,\n visited = new Set<string>()\n): Promise<Loaded> {\n const out: Loaded = { skills: [], diagnostics: [] };\n const real = await files.canonicalPath(dir, context);\n const key = real.ok ? real.value : dir;\n if (visited.has(key)) return out;\n visited.add(key);\n const listed = await files.listDir(dir, context);\n if (!listed.ok) return out;\n const merge = (found: Loaded) => {\n out.skills.push(...found.skills);\n out.diagnostics.push(...found.diagnostics);\n };\n if (listed.value.some((entry) => entry.name === 'SKILL.md' && entry.kind !== 'directory')) {\n merge(await loadFile(files, `${dir}/SKILL.md`, source, context));\n return out;\n }\n const entries = [...listed.value].sort((a, b) => a.name.localeCompare(b.name));\n for (const entry of entries) {\n if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;\n const path = `${dir}/${entry.name}`;\n if (entry.kind === 'directory' || entry.kind === 'symlink')\n merge(await loadSkillsFromDir(files, path, source, context, false, visited));\n if (entry.kind !== 'directory' && root && entry.name.endsWith('.md'))\n merge(await loadFile(files, path, source, context));\n }\n return out;\n}\n\nexport async function loadSkills(\n files: SkillFiles,\n roots: readonly SkillRoot[],\n context: Context\n): Promise<Loaded> {\n const byName = new Map<string, Skill>();\n const seen = new Set<string>();\n const diagnostics: Diagnostic[] = [];\n const collisions: Diagnostic[] = [];\n for (const root of roots) {\n const found = await loadSkillsFromDir(files, root.dir, root.source, context);\n diagnostics.push(...found.diagnostics);\n for (const skill of found.skills) {\n if (seen.has(skill.filePath)) continue;\n const existing = byName.get(skill.name);\n if (existing)\n collisions.push({\n path: skill.filePath,\n message: `name \"${skill.name}\" collision; ${existing.filePath} is used`,\n });\n else {\n byName.set(skill.name, skill);\n seen.add(skill.filePath);\n }\n }\n }\n return { skills: [...byName.values()], diagnostics: [...diagnostics, ...collisions] };\n}\n\nasync function packageAt(\n files: SkillFiles,\n real: string,\n context: Context\n): Promise<SkillPackage | undefined> {\n for (let dir = real; dir.startsWith(PNPM_DIR); dir = dirname(dir)) {\n const read = await files.readTextFile(`${dir}/package.json`, context);\n if (!read.ok) continue;\n let manifest: { name?: unknown; version?: unknown };\n try {\n manifest = JSON.parse(read.value);\n } catch {\n continue;\n }\n if (typeof manifest.name !== 'string') continue;\n return {\n name: manifest.name,\n ...(typeof manifest.version === 'string' ? { version: manifest.version } : {}),\n };\n }\n return undefined;\n}\n\nexport async function labelPackages(\n files: SkillFiles,\n skills: readonly Skill[],\n context: Context\n): Promise<Skill[]> {\n return Promise.all(\n skills.map(async (skill) => {\n if (skill.source !== 'global') return skill;\n const real = await files.canonicalPath(skill.baseDir, context);\n const found = real.ok ? await packageAt(files, real.value, context) : undefined;\n return found ? { ...skill, source: 'package' as const, package: found } : skill;\n })\n );\n}\n\nfunction escapeXml(text: string): string {\n return text\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\nexport function formatSkillsForPrompt(skills: readonly Skill[]): string {\n const visible = skills.filter((skill) => !skill.disableModelInvocation);\n if (!visible.length) return '';\n const lines = [\n 'The following skills provide specialized instructions for specific tasks.',\n \"Use the read tool to load a skill's file when the task matches its description.\",\n 'When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.',\n '',\n '<available_skills>',\n ];\n for (const skill of visible)\n lines.push(\n ' <skill>',\n ` <name>${escapeXml(skill.name)}</name>`,\n ` <description>${escapeXml(skill.description)}</description>`,\n ` <location>${escapeXml(skill.filePath)}</location>`,\n ' </skill>'\n );\n lines.push('</available_skills>');\n return lines.join('\\n');\n}\n\nexport async function expandSkillCommand(\n text: string,\n skills: readonly Skill[],\n files: SkillFiles,\n context: Context\n): Promise<string> {\n if (!text.startsWith('/skill:')) return text;\n const space = text.indexOf(' ');\n const name = space === -1 ? text.slice(7) : text.slice(7, space);\n const args = space === -1 ? '' : text.slice(space + 1).trim();\n const skill = skills.find((candidate) => candidate.name === name);\n if (!skill) return text;\n const read = await files.readTextFile(skill.filePath, context);\n if (!read.ok) return text;\n const body = parseFrontmatter(read.value).body.trim();\n const block = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n return args ? `${block}\\n\\n${args}` : block;\n}\n"],
|
|
5
|
-
"mappings": "AAEA,SAAS,wBAAwB;AAE1B,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;AAM/B,MAAM,WAAW;AAgCxB,SAAS,QAAQ,MAAsB;AACrC,SAAO,KAAK,MAAM,GAAG,KAAK,YAAY,GAAG,CAAC,KAAK;AACjD;AAEA,SAAS,SAAS,MAAsB;AACtC,SAAO,KAAK,MAAM,KAAK,YAAY,GAAG,IAAI,CAAC;AAC7C;AAEO,SAAS,aAAa,MAAwB;AACnD,QAAM,SAAmB,CAAC;AAC1B,MAAI,KAAK,SAAS;AAChB,WAAO,KAAK,gBAAgB,eAAe,gBAAgB,KAAK,MAAM,GAAG;AAC3E,MAAI,CAAC,eAAe,KAAK,IAAI;AAC3B,WAAO,KAAK,6EAA6E;AAC3F,MAAI,KAAK,WAAW,GAAG,KAAK,KAAK,SAAS,GAAG;AAC3C,WAAO,KAAK,0CAA0C;AACxD,MAAI,KAAK,SAAS,IAAI,EAAG,QAAO,KAAK,2CAA2C;AAChF,SAAO;AACT;AAEA,SAAS,oBAAoB,aAAgC;AAC3D,MAAI,OAAO,gBAAgB,YAAY,YAAY,KAAK,MAAM;AAC5D,WAAO,CAAC,yBAAyB;AACnC,MAAI,YAAY,SAAS;AACvB,WAAO,CAAC,uBAAuB,sBAAsB,gBAAgB,YAAY,MAAM,GAAG;AAC5F,SAAO,CAAC;AACV;AAEO,SAAS,cAAc,MAAc,UAAkB,QAA6B;AACzF,QAAM,WAAW,SAAS,QAAQ,MAAM;AACxC,QAAM,EAAE,QAAQ,SAAS,IAAI,iBAAiB,
|
|
4
|
+
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { parseFrontmatter } from '../roles/frontmatter.ts';\n\nexport const MAX_NAME_LENGTH = 64;\nexport const MAX_DESCRIPTION_LENGTH = 1024;\n\nexport type SkillFiles = Pick<ExecutionEnv, 'readTextFile' | 'listDir' | 'canonicalPath'>;\n\nexport type SkillSource = 'user' | 'global' | 'package' | 'builtin';\n\nexport const PNPM_DIR = '/usr/local/share/pnpm/';\n\nexport interface SkillPackage {\n name: string;\n version?: string;\n}\n\nexport interface Skill {\n name: string;\n description: string;\n filePath: string;\n baseDir: string;\n source: SkillSource;\n disableModelInvocation: boolean;\n package?: SkillPackage;\n}\n\nexport interface Diagnostic {\n path: string;\n message: string;\n}\n\nexport interface Loaded {\n skills: Skill[];\n diagnostics: Diagnostic[];\n}\n\nexport interface SkillRoot {\n dir: string;\n source: SkillSource;\n}\n\nfunction dirname(path: string): string {\n return path.slice(0, path.lastIndexOf('/')) || '/';\n}\n\nfunction basename(path: string): string {\n return path.slice(path.lastIndexOf('/') + 1);\n}\n\nexport function validateName(name: string): string[] {\n const errors: string[] = [];\n if (name.length > MAX_NAME_LENGTH)\n errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n if (!/^[a-z0-9-]+$/.test(name))\n errors.push('name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)');\n if (name.startsWith('-') || name.endsWith('-'))\n errors.push('name must not start or end with a hyphen');\n if (name.includes('--')) errors.push('name must not contain consecutive hyphens');\n return errors;\n}\n\nfunction validateDescription(description: unknown): string[] {\n if (typeof description !== 'string' || description.trim() === '')\n return ['description is required'];\n if (description.length > MAX_DESCRIPTION_LENGTH)\n return [`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`];\n return [];\n}\n\nexport function skillFromText(text: string, filePath: string, source: SkillSource): Loaded {\n const declared = basename(filePath) === 'SKILL.md';\n const { fields, problems } = parseFrontmatter(text, [], ['disable-model-invocation']);\n const diagnostics: Diagnostic[] = [];\n const description = typeof fields.description === 'string' ? fields.description.trim() : '';\n if (!declared && !description) return { skills: [], diagnostics };\n for (const problem of problems.filter((item) => !item.includes('nested values')))\n diagnostics.push({ path: filePath, message: problem });\n for (const message of validateDescription(description))\n diagnostics.push({ path: filePath, message });\n const baseDir = dirname(filePath);\n const name = (typeof fields.name === 'string' && fields.name) || basename(baseDir);\n for (const message of validateName(name)) diagnostics.push({ path: filePath, message });\n if (!description) return { skills: [], diagnostics };\n const skill: Skill = {\n name,\n description,\n filePath,\n baseDir,\n source,\n disableModelInvocation: fields['disable-model-invocation'] === true,\n };\n return { skills: [skill], diagnostics };\n}\n\nasync function loadFile(\n files: SkillFiles,\n filePath: string,\n source: SkillSource,\n context: Context\n): Promise<Loaded> {\n const read = await files.readTextFile(filePath, context);\n if (!read.ok)\n return { skills: [], diagnostics: [{ path: filePath, message: read.error.message }] };\n return skillFromText(read.value, filePath, source);\n}\n\nexport async function loadSkillsFromDir(\n files: SkillFiles,\n dir: string,\n source: SkillSource,\n context: Context,\n root = true,\n visited = new Set<string>()\n): Promise<Loaded> {\n const out: Loaded = { skills: [], diagnostics: [] };\n const real = await files.canonicalPath(dir, context);\n const key = real.ok ? real.value : dir;\n if (visited.has(key)) return out;\n visited.add(key);\n const listed = await files.listDir(dir, context);\n if (!listed.ok) return out;\n const merge = (found: Loaded) => {\n out.skills.push(...found.skills);\n out.diagnostics.push(...found.diagnostics);\n };\n if (listed.value.some((entry) => entry.name === 'SKILL.md' && entry.kind !== 'directory')) {\n merge(await loadFile(files, `${dir}/SKILL.md`, source, context));\n return out;\n }\n const entries = [...listed.value].sort((a, b) => a.name.localeCompare(b.name));\n for (const entry of entries) {\n if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;\n const path = `${dir}/${entry.name}`;\n if (entry.kind === 'directory' || entry.kind === 'symlink')\n merge(await loadSkillsFromDir(files, path, source, context, false, visited));\n if (entry.kind !== 'directory' && root && entry.name.endsWith('.md'))\n merge(await loadFile(files, path, source, context));\n }\n return out;\n}\n\nexport async function loadSkills(\n files: SkillFiles,\n roots: readonly SkillRoot[],\n context: Context\n): Promise<Loaded> {\n const byName = new Map<string, Skill>();\n const seen = new Set<string>();\n const diagnostics: Diagnostic[] = [];\n const collisions: Diagnostic[] = [];\n for (const root of roots) {\n const found = await loadSkillsFromDir(files, root.dir, root.source, context);\n diagnostics.push(...found.diagnostics);\n for (const skill of found.skills) {\n if (seen.has(skill.filePath)) continue;\n const existing = byName.get(skill.name);\n if (existing)\n collisions.push({\n path: skill.filePath,\n message: `name \"${skill.name}\" collision; ${existing.filePath} is used`,\n });\n else {\n byName.set(skill.name, skill);\n seen.add(skill.filePath);\n }\n }\n }\n return { skills: [...byName.values()], diagnostics: [...diagnostics, ...collisions] };\n}\n\nasync function packageAt(\n files: SkillFiles,\n real: string,\n context: Context\n): Promise<SkillPackage | undefined> {\n for (let dir = real; dir.startsWith(PNPM_DIR); dir = dirname(dir)) {\n const read = await files.readTextFile(`${dir}/package.json`, context);\n if (!read.ok) continue;\n let manifest: { name?: unknown; version?: unknown };\n try {\n manifest = JSON.parse(read.value);\n } catch {\n continue;\n }\n if (typeof manifest.name !== 'string') continue;\n return {\n name: manifest.name,\n ...(typeof manifest.version === 'string' ? { version: manifest.version } : {}),\n };\n }\n return undefined;\n}\n\nexport async function labelPackages(\n files: SkillFiles,\n skills: readonly Skill[],\n context: Context\n): Promise<Skill[]> {\n return Promise.all(\n skills.map(async (skill) => {\n if (skill.source !== 'global') return skill;\n const real = await files.canonicalPath(skill.baseDir, context);\n const found = real.ok ? await packageAt(files, real.value, context) : undefined;\n return found ? { ...skill, source: 'package' as const, package: found } : skill;\n })\n );\n}\n\nfunction escapeXml(text: string): string {\n return text\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n .replace(/'/g, ''');\n}\n\nexport function formatSkillsForPrompt(skills: readonly Skill[]): string {\n const visible = skills.filter((skill) => !skill.disableModelInvocation);\n if (!visible.length) return '';\n const lines = [\n 'The following skills provide specialized instructions for specific tasks.',\n \"Use the read tool to load a skill's file when the task matches its description.\",\n 'When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.',\n '',\n '<available_skills>',\n ];\n for (const skill of visible)\n lines.push(\n ' <skill>',\n ` <name>${escapeXml(skill.name)}</name>`,\n ` <description>${escapeXml(skill.description)}</description>`,\n ` <location>${escapeXml(skill.filePath)}</location>`,\n ' </skill>'\n );\n lines.push('</available_skills>');\n return lines.join('\\n');\n}\n\nexport async function expandSkillCommand(\n text: string,\n skills: readonly Skill[],\n files: SkillFiles,\n context: Context\n): Promise<string> {\n if (!text.startsWith('/skill:')) return text;\n const space = text.indexOf(' ');\n const name = space === -1 ? text.slice(7) : text.slice(7, space);\n const args = space === -1 ? '' : text.slice(space + 1).trim();\n const skill = skills.find((candidate) => candidate.name === name);\n if (!skill) return text;\n const read = await files.readTextFile(skill.filePath, context);\n if (!read.ok) return text;\n const body = parseFrontmatter(read.value).body.trim();\n const block = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${skill.baseDir}.\\n\\n${body}\\n</skill>`;\n return args ? `${block}\\n\\n${args}` : block;\n}\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,wBAAwB;AAE1B,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;AAM/B,MAAM,WAAW;AAgCxB,SAAS,QAAQ,MAAsB;AACrC,SAAO,KAAK,MAAM,GAAG,KAAK,YAAY,GAAG,CAAC,KAAK;AACjD;AAEA,SAAS,SAAS,MAAsB;AACtC,SAAO,KAAK,MAAM,KAAK,YAAY,GAAG,IAAI,CAAC;AAC7C;AAEO,SAAS,aAAa,MAAwB;AACnD,QAAM,SAAmB,CAAC;AAC1B,MAAI,KAAK,SAAS;AAChB,WAAO,KAAK,gBA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,UAAU,MAAM,IAAI,CAAC;AAAA,MAClC,oBAAoB,UAAU,MAAM,WAAW,CAAC;AAAA,MAChD,iBAAiB,UAAU,MAAM,QAAQ,CAAC;AAAA,MAC1C;AAAA,IACF;AACF,QAAM,KAAK,qBAAqB;AAChC,SAAO,MAAM,KAAK,IAAI;AACxB;AAEA,eAAsB,mBACpB,MACA,QACA,OACA,SACiB;AACjB,MAAI,CAAC,KAAK,WAAW,SAAS,EAAG,QAAO;AACxC,QAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,QAAM,OAAO,UAAU,KAAK,KAAK,MAAM,CAAC,IAAI,KAAK,MAAM,GAAG,KAAK;AAC/D,QAAM,OAAO,UAAU,KAAK,KAAK,KAAK,MAAM,QAAQ,CAAC,EAAE,KAAK;AAC5D,QAAM,QAAQ,OAAO,KAAK,CAAC,cAAc,UAAU,SAAS,IAAI;AAChE,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,OAAO,MAAM,MAAM,aAAa,MAAM,UAAU,OAAO;AAC7D,MAAI,CAAC,KAAK,GAAI,QAAO;AACrB,QAAM,OAAO,iBAAiB,KAAK,KAAK,EAAE,KAAK,KAAK;AACpD,QAAM,QAAQ,gBAAgB,MAAM,IAAI,eAAe,MAAM,QAAQ;AAAA,6BAAkC,MAAM,OAAO;AAAA;AAAA,EAAQ,IAAI;AAAA;AAChI,SAAO,OAAO,GAAG,KAAK;AAAA;AAAA,EAAO,IAAI,KAAK;AACxC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,4 +4,4 @@ export interface Frontmatter {
|
|
|
4
4
|
body: string;
|
|
5
5
|
problems: string[];
|
|
6
6
|
}
|
|
7
|
-
export declare function parseFrontmatter(text: string, mappings?: readonly string[]): Frontmatter;
|
|
7
|
+
export declare function parseFrontmatter(text: string, mappings?: readonly string[], protectedKeys?: readonly string[]): Frontmatter;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-agent",
|
|
3
|
-
"version": "7.13.
|
|
3
|
+
"version": "7.13.3",
|
|
4
4
|
"description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@ai-ecoverse/slicc-kernel": "1.171.0",
|
|
76
76
|
"@ai-ecoverse/slicc-scrub": "1.1.0",
|
|
77
|
-
"@ai-ecoverse/slicc-shared-web": "2.13.
|
|
77
|
+
"@ai-ecoverse/slicc-shared-web": "2.13.9",
|
|
78
78
|
"@ai-ecoverse/slicc-spectrum": "1.108.3",
|
|
79
79
|
"@ai-ecoverse/wasi-fnox": "1.42.1-1",
|
|
80
80
|
"@ai-ecoverse/wasm-bash": "5.3.0-23",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"typescript": "7.0.2"
|
|
93
93
|
},
|
|
94
94
|
"dependencies": {
|
|
95
|
-
"@ai-ecoverse/slicc-browsers": "1.18.
|
|
95
|
+
"@ai-ecoverse/slicc-browsers": "1.18.22",
|
|
96
96
|
"@ai-ecoverse/slicc-vault": "1.21.2",
|
|
97
97
|
"@aws-sdk/middleware-websocket": "^3.972.54",
|
|
98
98
|
"@earendil-works/chord": "1.5.0",
|