@eminent337/aery-core 0.67.120 → 0.67.122
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 +14 -0
- package/dist/agent-loop.d.ts.map +1 -1
- package/dist/agent-loop.js +31 -1
- package/dist/agent-loop.js.map +1 -1
- package/dist/agent.d.ts +4 -3
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +7 -3
- package/dist/agent.js.map +1 -1
- package/dist/harness/agent-harness.d.ts +103 -0
- package/dist/harness/agent-harness.d.ts.map +1 -0
- package/dist/harness/agent-harness.js +788 -0
- package/dist/harness/agent-harness.js.map +1 -0
- package/dist/harness/compaction/branch-summarization.d.ts +88 -0
- package/dist/harness/compaction/branch-summarization.d.ts.map +1 -0
- package/dist/harness/compaction/branch-summarization.js +243 -0
- package/dist/harness/compaction/branch-summarization.js.map +1 -0
- package/dist/harness/compaction/compaction.d.ts +122 -0
- package/dist/harness/compaction/compaction.d.ts.map +1 -0
- package/dist/harness/compaction/compaction.js +631 -0
- package/dist/harness/compaction/compaction.js.map +1 -0
- package/dist/harness/compaction/utils.d.ts +38 -0
- package/dist/harness/compaction/utils.d.ts.map +1 -0
- package/dist/harness/compaction/utils.js +153 -0
- package/dist/harness/compaction/utils.js.map +1 -0
- package/dist/harness/env/nodejs.d.ts +50 -0
- package/dist/harness/env/nodejs.d.ts.map +1 -0
- package/dist/harness/env/nodejs.js +487 -0
- package/dist/harness/env/nodejs.js.map +1 -0
- package/dist/harness/execution-env.d.ts +4 -0
- package/dist/harness/execution-env.d.ts.map +1 -0
- package/dist/harness/execution-env.js +3 -0
- package/dist/harness/execution-env.js.map +1 -0
- package/dist/harness/factory.d.ts +6 -0
- package/dist/harness/factory.d.ts.map +1 -0
- package/dist/harness/factory.js +9 -0
- package/dist/harness/factory.js.map +1 -0
- package/dist/harness/messages.d.ts +51 -0
- package/dist/harness/messages.d.ts.map +1 -0
- package/dist/harness/messages.js +102 -0
- package/dist/harness/messages.js.map +1 -0
- package/dist/harness/prompt-templates.d.ts +47 -0
- package/dist/harness/prompt-templates.d.ts.map +1 -0
- package/dist/harness/prompt-templates.js +201 -0
- package/dist/harness/prompt-templates.js.map +1 -0
- package/dist/harness/session/jsonl-repo.d.ts +26 -0
- package/dist/harness/session/jsonl-repo.d.ts.map +1 -0
- package/dist/harness/session/jsonl-repo.js +97 -0
- package/dist/harness/session/jsonl-repo.js.map +1 -0
- package/dist/harness/session/jsonl-storage.d.ts +33 -0
- package/dist/harness/session/jsonl-storage.d.ts.map +1 -0
- package/dist/harness/session/jsonl-storage.js +159 -0
- package/dist/harness/session/jsonl-storage.js.map +1 -0
- package/dist/harness/session/memory-repo.d.ts +18 -0
- package/dist/harness/session/memory-repo.d.ts.map +1 -0
- package/dist/harness/session/memory-repo.js +42 -0
- package/dist/harness/session/memory-repo.js.map +1 -0
- package/dist/harness/session/memory-storage.d.ts +26 -0
- package/dist/harness/session/memory-storage.d.ts.map +1 -0
- package/dist/harness/session/memory-storage.js +89 -0
- package/dist/harness/session/memory-storage.js.map +1 -0
- package/dist/harness/session/repo/jsonl.d.ts +20 -0
- package/dist/harness/session/repo/jsonl.d.ts.map +1 -0
- package/dist/harness/session/repo/jsonl.js +92 -0
- package/dist/harness/session/repo/jsonl.js.map +1 -0
- package/dist/harness/session/repo/memory.d.ts +18 -0
- package/dist/harness/session/repo/memory.d.ts.map +1 -0
- package/dist/harness/session/repo/memory.js +42 -0
- package/dist/harness/session/repo/memory.js.map +1 -0
- package/dist/harness/session/repo/shared.d.ts +10 -0
- package/dist/harness/session/repo/shared.d.ts.map +1 -0
- package/dist/harness/session/repo/shared.js +31 -0
- package/dist/harness/session/repo/shared.js.map +1 -0
- package/dist/harness/session/repo-utils.d.ts +10 -0
- package/dist/harness/session/repo-utils.d.ts.map +1 -0
- package/dist/harness/session/repo-utils.js +31 -0
- package/dist/harness/session/repo-utils.js.map +1 -0
- package/dist/harness/session/session.d.ts +32 -0
- package/dist/harness/session/session.d.ts.map +1 -0
- package/dist/harness/session/session.js +196 -0
- package/dist/harness/session/session.js.map +1 -0
- package/dist/harness/session/storage/jsonl.d.ts +30 -0
- package/dist/harness/session/storage/jsonl.d.ts.map +1 -0
- package/dist/harness/session/storage/jsonl.js +170 -0
- package/dist/harness/session/storage/jsonl.js.map +1 -0
- package/dist/harness/session/storage/memory.d.ts +26 -0
- package/dist/harness/session/storage/memory.d.ts.map +1 -0
- package/dist/harness/session/storage/memory.js +90 -0
- package/dist/harness/session/storage/memory.js.map +1 -0
- package/dist/harness/session/uuid.d.ts +2 -0
- package/dist/harness/session/uuid.d.ts.map +1 -0
- package/dist/harness/session/uuid.js +50 -0
- package/dist/harness/session/uuid.js.map +1 -0
- package/dist/harness/skills.d.ts +43 -0
- package/dist/harness/skills.d.ts.map +1 -0
- package/dist/harness/skills.js +255 -0
- package/dist/harness/skills.js.map +1 -0
- package/dist/harness/system-prompt.d.ts +3 -0
- package/dist/harness/system-prompt.d.ts.map +1 -0
- package/dist/harness/system-prompt.js +30 -0
- package/dist/harness/system-prompt.js.map +1 -0
- package/dist/harness/types.d.ts +578 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +56 -0
- package/dist/harness/types.js.map +1 -0
- package/dist/harness/utils/shell-output.d.ts +14 -0
- package/dist/harness/utils/shell-output.d.ts.map +1 -0
- package/dist/harness/utils/shell-output.js +125 -0
- package/dist/harness/utils/shell-output.js.map +1 -0
- package/dist/harness/utils/truncate.d.ts +70 -0
- package/dist/harness/utils/truncate.d.ts.map +1 -0
- package/dist/harness/utils/truncate.js +288 -0
- package/dist/harness/utils/truncate.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -1
- package/dist/node.d.ts +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +3 -0
- package/dist/node.js.map +1 -0
- package/dist/proxy.d.ts.map +1 -1
- package/dist/proxy.js +5 -2
- package/dist/proxy.js.map +1 -1
- package/dist/types.d.ts +50 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +19 -2
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import ignore from "ignore";
|
|
2
|
+
import { parse } from "yaml";
|
|
3
|
+
import { getOrUndefined } from "./types.js";
|
|
4
|
+
const MAX_NAME_LENGTH = 64;
|
|
5
|
+
const MAX_DESCRIPTION_LENGTH = 1024;
|
|
6
|
+
const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
|
|
7
|
+
/** Format a skill invocation prompt, optionally appending additional user instructions. */
|
|
8
|
+
export function formatSkillInvocation(skill, additionalInstructions) {
|
|
9
|
+
const skillBlock = `<skill name="${skill.name}" location="${skill.filePath}">\nReferences are relative to ${dirnameEnvPath(skill.filePath)}.\n\n${skill.content}\n</skill>`;
|
|
10
|
+
return additionalInstructions ? `${skillBlock}\n\n${additionalInstructions}` : skillBlock;
|
|
11
|
+
}
|
|
12
|
+
/** Compatibility alias for older harness consumers. */
|
|
13
|
+
export const expandSkillCommand = formatSkillInvocation;
|
|
14
|
+
/**
|
|
15
|
+
* Load skills from one or more directories.
|
|
16
|
+
*
|
|
17
|
+
* Traverses directories recursively, loads `SKILL.md` files, loads direct root `.md` files as skills, honors ignore files,
|
|
18
|
+
* and returns diagnostics for invalid skill files. Missing input directories are skipped.
|
|
19
|
+
*/
|
|
20
|
+
export async function loadSkills(env, dirs) {
|
|
21
|
+
const skills = [];
|
|
22
|
+
const diagnostics = [];
|
|
23
|
+
for (const dir of Array.isArray(dirs) ? dirs : [dirs]) {
|
|
24
|
+
const rootInfo = getOrUndefined(await env.fileInfo(dir));
|
|
25
|
+
if (!rootInfo || (await resolveKind(env, rootInfo)) !== "directory")
|
|
26
|
+
continue;
|
|
27
|
+
const result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path);
|
|
28
|
+
skills.push(...result.skills);
|
|
29
|
+
diagnostics.push(...result.diagnostics);
|
|
30
|
+
}
|
|
31
|
+
return { skills, diagnostics };
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Load skills from source-tagged directories.
|
|
35
|
+
*
|
|
36
|
+
* Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not
|
|
37
|
+
* interpret source values; applications define their own provenance shape.
|
|
38
|
+
*/
|
|
39
|
+
export async function loadSourcedSkills(env, inputs, mapSkill) {
|
|
40
|
+
const skills = [];
|
|
41
|
+
const diagnostics = [];
|
|
42
|
+
for (const input of inputs) {
|
|
43
|
+
const result = await loadSkills(env, input.path);
|
|
44
|
+
for (const skill of result.skills) {
|
|
45
|
+
skills.push({ skill: mapSkill ? mapSkill(skill, input.source) : skill, source: input.source });
|
|
46
|
+
}
|
|
47
|
+
for (const diagnostic of result.diagnostics)
|
|
48
|
+
diagnostics.push({ ...diagnostic, source: input.source });
|
|
49
|
+
}
|
|
50
|
+
return { skills, diagnostics };
|
|
51
|
+
}
|
|
52
|
+
async function loadSkillsFromDirInternal(env, dir, includeRootFiles, ignoreMatcher, rootDir) {
|
|
53
|
+
const skills = [];
|
|
54
|
+
const diagnostics = [];
|
|
55
|
+
const dirInfo = getOrUndefined(await env.fileInfo(dir));
|
|
56
|
+
if (!dirInfo || (await resolveKind(env, dirInfo)) !== "directory")
|
|
57
|
+
return { skills, diagnostics };
|
|
58
|
+
await addIgnoreRules(env, ignoreMatcher, dir, rootDir);
|
|
59
|
+
const entries = getOrUndefined(await env.listDir(dir));
|
|
60
|
+
if (!entries)
|
|
61
|
+
return { skills, diagnostics };
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (entry.name !== "SKILL.md")
|
|
64
|
+
continue;
|
|
65
|
+
const fullPath = entry.path;
|
|
66
|
+
const kind = await resolveKind(env, entry);
|
|
67
|
+
if (kind !== "file")
|
|
68
|
+
continue;
|
|
69
|
+
const relPath = relativeEnvPath(rootDir, fullPath);
|
|
70
|
+
if (ignoreMatcher.ignores(relPath))
|
|
71
|
+
continue;
|
|
72
|
+
const result = await loadSkillFromFile(env, fullPath);
|
|
73
|
+
if (result.skill)
|
|
74
|
+
skills.push(result.skill);
|
|
75
|
+
diagnostics.push(...result.diagnostics);
|
|
76
|
+
return { skills, diagnostics };
|
|
77
|
+
}
|
|
78
|
+
for (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
79
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules")
|
|
80
|
+
continue;
|
|
81
|
+
const fullPath = entry.path;
|
|
82
|
+
const kind = await resolveKind(env, entry);
|
|
83
|
+
if (!kind)
|
|
84
|
+
continue;
|
|
85
|
+
const relPath = relativeEnvPath(rootDir, fullPath);
|
|
86
|
+
const ignorePath = kind === "directory" ? `${relPath}/` : relPath;
|
|
87
|
+
if (ignoreMatcher.ignores(ignorePath))
|
|
88
|
+
continue;
|
|
89
|
+
if (kind === "directory") {
|
|
90
|
+
const result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir);
|
|
91
|
+
skills.push(...result.skills);
|
|
92
|
+
diagnostics.push(...result.diagnostics);
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (kind !== "file" || !includeRootFiles || !entry.name.endsWith(".md"))
|
|
96
|
+
continue;
|
|
97
|
+
const result = await loadSkillFromFile(env, fullPath);
|
|
98
|
+
if (result.skill)
|
|
99
|
+
skills.push(result.skill);
|
|
100
|
+
diagnostics.push(...result.diagnostics);
|
|
101
|
+
}
|
|
102
|
+
return { skills, diagnostics };
|
|
103
|
+
}
|
|
104
|
+
async function addIgnoreRules(env, ig, dir, rootDir) {
|
|
105
|
+
const relativeDir = relativeEnvPath(rootDir, dir);
|
|
106
|
+
const prefix = relativeDir ? `${relativeDir}/` : "";
|
|
107
|
+
for (const filename of IGNORE_FILE_NAMES) {
|
|
108
|
+
const ignorePath = joinEnvPath(dir, filename);
|
|
109
|
+
const info = getOrUndefined(await env.fileInfo(ignorePath));
|
|
110
|
+
if (info?.kind !== "file")
|
|
111
|
+
continue;
|
|
112
|
+
const content = await env.readTextFile(ignorePath);
|
|
113
|
+
if (!content.ok)
|
|
114
|
+
continue;
|
|
115
|
+
const patterns = content.value
|
|
116
|
+
.split(/\r?\n/)
|
|
117
|
+
.map((line) => prefixIgnorePattern(line, prefix))
|
|
118
|
+
.filter((line) => Boolean(line));
|
|
119
|
+
if (patterns.length > 0)
|
|
120
|
+
ig.add(patterns);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function prefixIgnorePattern(line, prefix) {
|
|
124
|
+
const trimmed = line.trim();
|
|
125
|
+
if (!trimmed)
|
|
126
|
+
return null;
|
|
127
|
+
if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
|
|
128
|
+
return null;
|
|
129
|
+
let pattern = line;
|
|
130
|
+
let negated = false;
|
|
131
|
+
if (pattern.startsWith("!")) {
|
|
132
|
+
negated = true;
|
|
133
|
+
pattern = pattern.slice(1);
|
|
134
|
+
}
|
|
135
|
+
else if (pattern.startsWith("\\!")) {
|
|
136
|
+
pattern = pattern.slice(1);
|
|
137
|
+
}
|
|
138
|
+
if (pattern.startsWith("/"))
|
|
139
|
+
pattern = pattern.slice(1);
|
|
140
|
+
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
141
|
+
return negated ? `!${prefixed}` : prefixed;
|
|
142
|
+
}
|
|
143
|
+
async function loadSkillFromFile(env, filePath) {
|
|
144
|
+
const diagnostics = [];
|
|
145
|
+
const rawContent = await env.readTextFile(filePath);
|
|
146
|
+
if (!rawContent.ok) {
|
|
147
|
+
diagnostics.push({ type: "warning", message: rawContent.error.message, path: filePath });
|
|
148
|
+
return { skill: null, diagnostics };
|
|
149
|
+
}
|
|
150
|
+
const parsed = parseFrontmatter(rawContent.value);
|
|
151
|
+
if (!parsed.ok) {
|
|
152
|
+
diagnostics.push({ type: "warning", message: parsed.error.message, path: filePath });
|
|
153
|
+
return { skill: null, diagnostics };
|
|
154
|
+
}
|
|
155
|
+
const { frontmatter, body } = parsed.value;
|
|
156
|
+
const skillDir = dirnameEnvPath(filePath);
|
|
157
|
+
const parentDirName = basenameEnvPath(skillDir);
|
|
158
|
+
const description = typeof frontmatter.description === "string" ? frontmatter.description : undefined;
|
|
159
|
+
for (const error of validateDescription(description)) {
|
|
160
|
+
diagnostics.push({ type: "warning", message: error, path: filePath });
|
|
161
|
+
}
|
|
162
|
+
const frontmatterName = typeof frontmatter.name === "string" ? frontmatter.name : undefined;
|
|
163
|
+
const name = frontmatterName || parentDirName;
|
|
164
|
+
for (const error of validateName(name, parentDirName)) {
|
|
165
|
+
diagnostics.push({ type: "warning", message: error, path: filePath });
|
|
166
|
+
}
|
|
167
|
+
if (!description || description.trim() === "") {
|
|
168
|
+
return { skill: null, diagnostics };
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
skill: {
|
|
172
|
+
name,
|
|
173
|
+
description,
|
|
174
|
+
content: body,
|
|
175
|
+
filePath,
|
|
176
|
+
disableModelInvocation: frontmatter["disable-model-invocation"] === true,
|
|
177
|
+
},
|
|
178
|
+
diagnostics,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function validateName(name, parentDirName) {
|
|
182
|
+
const errors = [];
|
|
183
|
+
if (name !== parentDirName)
|
|
184
|
+
errors.push(`name "${name}" does not match parent directory "${parentDirName}"`);
|
|
185
|
+
if (name.length > MAX_NAME_LENGTH)
|
|
186
|
+
errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);
|
|
187
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
188
|
+
errors.push("name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)");
|
|
189
|
+
}
|
|
190
|
+
if (name.startsWith("-") || name.endsWith("-"))
|
|
191
|
+
errors.push("name must not start or end with a hyphen");
|
|
192
|
+
if (name.includes("--"))
|
|
193
|
+
errors.push("name must not contain consecutive hyphens");
|
|
194
|
+
return errors;
|
|
195
|
+
}
|
|
196
|
+
function validateDescription(description) {
|
|
197
|
+
const errors = [];
|
|
198
|
+
if (!description || description.trim() === "") {
|
|
199
|
+
errors.push("description is required");
|
|
200
|
+
}
|
|
201
|
+
else if (description.length > MAX_DESCRIPTION_LENGTH) {
|
|
202
|
+
errors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);
|
|
203
|
+
}
|
|
204
|
+
return errors;
|
|
205
|
+
}
|
|
206
|
+
function parseFrontmatter(content) {
|
|
207
|
+
try {
|
|
208
|
+
const normalized = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
209
|
+
if (!normalized.startsWith("---"))
|
|
210
|
+
return { ok: true, value: { frontmatter: {}, body: normalized } };
|
|
211
|
+
const endIndex = normalized.indexOf("\n---", 3);
|
|
212
|
+
if (endIndex === -1)
|
|
213
|
+
return { ok: true, value: { frontmatter: {}, body: normalized } };
|
|
214
|
+
const yamlString = normalized.slice(4, endIndex);
|
|
215
|
+
const body = normalized.slice(endIndex + 4).trim();
|
|
216
|
+
return { ok: true, value: { frontmatter: (parse(yamlString) ?? {}), body } };
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
return { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
async function resolveKind(env, info) {
|
|
223
|
+
if (info.kind === "file" || info.kind === "directory")
|
|
224
|
+
return info.kind;
|
|
225
|
+
const canonicalPath = await env.canonicalPath(info.path);
|
|
226
|
+
if (!canonicalPath.ok)
|
|
227
|
+
return undefined;
|
|
228
|
+
const target = getOrUndefined(await env.fileInfo(canonicalPath.value));
|
|
229
|
+
if (!target)
|
|
230
|
+
return undefined;
|
|
231
|
+
return target.kind === "file" || target.kind === "directory" ? target.kind : undefined;
|
|
232
|
+
}
|
|
233
|
+
function joinEnvPath(base, child) {
|
|
234
|
+
return `${base.replace(/\/+$/, "")}/${child.replace(/^\/+/, "")}`;
|
|
235
|
+
}
|
|
236
|
+
function dirnameEnvPath(path) {
|
|
237
|
+
const normalized = path.replace(/\/+$/, "");
|
|
238
|
+
const slashIndex = normalized.lastIndexOf("/");
|
|
239
|
+
return slashIndex <= 0 ? "/" : normalized.slice(0, slashIndex);
|
|
240
|
+
}
|
|
241
|
+
function basenameEnvPath(path) {
|
|
242
|
+
const normalized = path.replace(/\/+$/, "");
|
|
243
|
+
const slashIndex = normalized.lastIndexOf("/");
|
|
244
|
+
return slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);
|
|
245
|
+
}
|
|
246
|
+
function relativeEnvPath(root, path) {
|
|
247
|
+
const normalizedRoot = root.replace(/\/+$/, "");
|
|
248
|
+
const normalizedPath = path.replace(/\/+$/, "");
|
|
249
|
+
if (normalizedPath === normalizedRoot)
|
|
250
|
+
return "";
|
|
251
|
+
return normalizedPath.startsWith(`${normalizedRoot}/`)
|
|
252
|
+
? normalizedPath.slice(normalizedRoot.length + 1)
|
|
253
|
+
: normalizedPath.replace(/^\/+/, "");
|
|
254
|
+
}
|
|
255
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/harness/skills.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAoC,cAAc,EAA2B,MAAM,YAAY,CAAC;AAEvG,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAqBjE,2FAA2F;AAC3F,MAAM,UAAU,qBAAqB,CAAC,KAAY,EAAE,sBAA+B,EAAU;IAC5F,MAAM,UAAU,GAAG,gBAAgB,KAAK,CAAC,IAAI,eAAe,KAAK,CAAC,QAAQ,kCAAkC,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,QA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AAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC;AAAA,CACzE;AAED,SAAS,eAAe,CAAC,IAAY,EAAE,IAAY,EAAU;IAC5D,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAChD,IAAI,cAAc,KAAK,cAAc;QAAE,OAAO,EAAE,CAAC;IACjD,OAAO,cAAc,CAAC,UAAU,CAAC,GAAG,cAAc,GAAG,CAAC;QACrD,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;QACjD,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAAA,CACtC","sourcesContent":["import ignore from \"ignore\";\nimport { parse } from \"yaml\";\nimport { type ExecutionEnv, type FileInfo, getOrUndefined, type Result, type Skill } from \"./types.js\";\n\nconst MAX_NAME_LENGTH = 64;\nconst MAX_DESCRIPTION_LENGTH = 1024;\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\n/** Warning produced while loading skills. */\nexport interface SkillDiagnostic {\n\t/** Diagnostic severity. Currently only warnings are emitted. */\n\ttype: \"warning\";\n\t/** Human-readable diagnostic message. */\n\tmessage: string;\n\t/** Path associated with the diagnostic. */\n\tpath: string;\n}\n\ninterface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t[key: string]: unknown;\n}\n\n/** Format a skill invocation prompt, optionally appending additional user instructions. */\nexport function formatSkillInvocation(skill: Skill, additionalInstructions?: string): string {\n\tconst skillBlock = `<skill name=\"${skill.name}\" location=\"${skill.filePath}\">\\nReferences are relative to ${dirnameEnvPath(skill.filePath)}.\\n\\n${skill.content}\\n</skill>`;\n\treturn additionalInstructions ? `${skillBlock}\\n\\n${additionalInstructions}` : skillBlock;\n}\n\n/** Compatibility alias for older harness consumers. */\nexport const expandSkillCommand = formatSkillInvocation;\n\n/**\n * Load skills from one or more directories.\n *\n * Traverses directories recursively, loads `SKILL.md` files, loads direct root `.md` files as skills, honors ignore files,\n * and returns diagnostics for invalid skill files. Missing input directories are skipped.\n */\nexport async function loadSkills(\n\tenv: ExecutionEnv,\n\tdirs: string | string[],\n): Promise<{ skills: Skill[]; diagnostics: SkillDiagnostic[] }> {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: SkillDiagnostic[] = [];\n\tfor (const dir of Array.isArray(dirs) ? dirs : [dirs]) {\n\t\tconst rootInfo = getOrUndefined(await env.fileInfo(dir));\n\t\tif (!rootInfo || (await resolveKind(env, rootInfo)) !== \"directory\") continue;\n\t\tconst result = await loadSkillsFromDirInternal(env, rootInfo.path, true, ignore(), rootInfo.path);\n\t\tskills.push(...result.skills);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\treturn { skills, diagnostics };\n}\n\n/**\n * Load skills from source-tagged directories.\n *\n * Source values are preserved exactly and attached to every loaded skill and diagnostic. The agent package does not\n * interpret source values; applications define their own provenance shape.\n */\nexport async function loadSourcedSkills<TSource, TSkill extends Skill = Skill>(\n\tenv: ExecutionEnv,\n\tinputs: Array<{ path: string; source: TSource }>,\n\tmapSkill?: (skill: Skill, source: TSource) => TSkill,\n): Promise<{\n\tskills: Array<{ skill: TSkill; source: TSource }>;\n\tdiagnostics: Array<SkillDiagnostic & { source: TSource }>;\n}> {\n\tconst skills: Array<{ skill: TSkill; source: TSource }> = [];\n\tconst diagnostics: Array<SkillDiagnostic & { source: TSource }> = [];\n\tfor (const input of inputs) {\n\t\tconst result = await loadSkills(env, input.path);\n\t\tfor (const skill of result.skills) {\n\t\t\tskills.push({ skill: mapSkill ? mapSkill(skill, input.source) : (skill as TSkill), source: input.source });\n\t\t}\n\t\tfor (const diagnostic of result.diagnostics) diagnostics.push({ ...diagnostic, source: input.source });\n\t}\n\treturn { skills, diagnostics };\n}\n\nasync function loadSkillsFromDirInternal(\n\tenv: ExecutionEnv,\n\tdir: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher: IgnoreMatcher,\n\trootDir: string,\n): Promise<{ skills: Skill[]; diagnostics: SkillDiagnostic[] }> {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: SkillDiagnostic[] = [];\n\n\tconst dirInfo = getOrUndefined(await env.fileInfo(dir));\n\tif (!dirInfo || (await resolveKind(env, dirInfo)) !== \"directory\") return { skills, diagnostics };\n\n\tawait addIgnoreRules(env, ignoreMatcher, dir, rootDir);\n\n\tconst entries = getOrUndefined(await env.listDir(dir));\n\tif (!entries) return { skills, diagnostics };\n\n\tfor (const entry of entries) {\n\t\tif (entry.name !== \"SKILL.md\") continue;\n\t\tconst fullPath = entry.path;\n\t\tconst kind = await resolveKind(env, entry);\n\t\tif (kind !== \"file\") continue;\n\t\tconst relPath = relativeEnvPath(rootDir, fullPath);\n\t\tif (ignoreMatcher.ignores(relPath)) continue;\n\n\t\tconst result = await loadSkillFromFile(env, fullPath);\n\t\tif (result.skill) skills.push(result.skill);\n\t\tdiagnostics.push(...result.diagnostics);\n\t\treturn { skills, diagnostics };\n\t}\n\n\tfor (const entry of entries.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\tif (entry.name.startsWith(\".\") || entry.name === \"node_modules\") continue;\n\t\tconst fullPath = entry.path;\n\t\tconst kind = await resolveKind(env, entry);\n\t\tif (!kind) continue;\n\n\t\tconst relPath = relativeEnvPath(rootDir, fullPath);\n\t\tconst ignorePath = kind === \"directory\" ? `${relPath}/` : relPath;\n\t\tif (ignoreMatcher.ignores(ignorePath)) continue;\n\n\t\tif (kind === \"directory\") {\n\t\t\tconst result = await loadSkillsFromDirInternal(env, fullPath, false, ignoreMatcher, rootDir);\n\t\t\tskills.push(...result.skills);\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (kind !== \"file\" || !includeRootFiles || !entry.name.endsWith(\".md\")) continue;\n\t\tconst result = await loadSkillFromFile(env, fullPath);\n\t\tif (result.skill) skills.push(result.skill);\n\t\tdiagnostics.push(...result.diagnostics);\n\t}\n\n\treturn { skills, diagnostics };\n}\n\nasync function addIgnoreRules(env: ExecutionEnv, ig: IgnoreMatcher, dir: string, rootDir: string): Promise<void> {\n\tconst relativeDir = relativeEnvPath(rootDir, dir);\n\tconst prefix = relativeDir ? `${relativeDir}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = joinEnvPath(dir, filename);\n\t\tconst info = getOrUndefined(await env.fileInfo(ignorePath));\n\t\tif (info?.kind !== \"file\") continue;\n\t\tconst content = await env.readTextFile(ignorePath);\n\t\tif (!content.ok) continue;\n\t\tconst patterns = content.value\n\t\t\t.split(/\\r?\\n/)\n\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t.filter((line): line is string => Boolean(line));\n\t\tif (patterns.length > 0) ig.add(patterns);\n\t}\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\tif (pattern.startsWith(\"/\")) pattern = pattern.slice(1);\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nasync function loadSkillFromFile(\n\tenv: ExecutionEnv,\n\tfilePath: string,\n): Promise<{ skill: Skill | null; diagnostics: SkillDiagnostic[] }> {\n\tconst diagnostics: SkillDiagnostic[] = [];\n\tconst rawContent = await env.readTextFile(filePath);\n\tif (!rawContent.ok) {\n\t\tdiagnostics.push({ type: \"warning\", message: rawContent.error.message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tconst parsed = parseFrontmatter<SkillFrontmatter>(rawContent.value);\n\tif (!parsed.ok) {\n\t\tdiagnostics.push({ type: \"warning\", message: parsed.error.message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\tconst { frontmatter, body } = parsed.value;\n\tconst skillDir = dirnameEnvPath(filePath);\n\tconst parentDirName = basenameEnvPath(skillDir);\n\tconst description = typeof frontmatter.description === \"string\" ? frontmatter.description : undefined;\n\n\tfor (const error of validateDescription(description)) {\n\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t}\n\n\tconst frontmatterName = typeof frontmatter.name === \"string\" ? frontmatter.name : undefined;\n\tconst name = frontmatterName || parentDirName;\n\tfor (const error of validateName(name, parentDirName)) {\n\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t}\n\n\tif (!description || description.trim() === \"\") {\n\t\treturn { skill: null, diagnostics };\n\t}\n\n\treturn {\n\t\tskill: {\n\t\t\tname,\n\t\t\tdescription,\n\t\t\tcontent: body,\n\t\t\tfilePath,\n\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t},\n\t\tdiagnostics,\n\t};\n}\n\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\tif (name !== parentDirName) errors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\tif (name.length > MAX_NAME_LENGTH) errors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(\"name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)\");\n\t}\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) errors.push(\"name must not start or end with a hyphen\");\n\tif (name.includes(\"--\")) errors.push(\"name must not contain consecutive hyphens\");\n\treturn errors;\n}\n\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\treturn errors;\n}\n\nfunction parseFrontmatter<T extends Record<string, unknown>>(\n\tcontent: string,\n): Result<{ frontmatter: T; body: string }, Error> {\n\ttry {\n\t\tconst normalized = content.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\t\tif (!normalized.startsWith(\"---\")) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\t\tif (endIndex === -1) return { ok: true, value: { frontmatter: {} as T, body: normalized } };\n\t\tconst yamlString = normalized.slice(4, endIndex);\n\t\tconst body = normalized.slice(endIndex + 4).trim();\n\t\treturn { ok: true, value: { frontmatter: (parse(yamlString) ?? {}) as T, body } };\n\t} catch (error) {\n\t\treturn { ok: false, error: error instanceof Error ? error : new Error(String(error)) };\n\t}\n}\n\nasync function resolveKind(env: ExecutionEnv, info: FileInfo): Promise<\"file\" | \"directory\" | undefined> {\n\tif (info.kind === \"file\" || info.kind === \"directory\") return info.kind;\n\tconst canonicalPath = await env.canonicalPath(info.path);\n\tif (!canonicalPath.ok) return undefined;\n\tconst target = getOrUndefined(await env.fileInfo(canonicalPath.value));\n\tif (!target) return undefined;\n\treturn target.kind === \"file\" || target.kind === \"directory\" ? target.kind : undefined;\n}\n\nfunction joinEnvPath(base: string, child: string): string {\n\treturn `${base.replace(/\\/+$/, \"\")}/${child.replace(/^\\/+/, \"\")}`;\n}\n\nfunction dirnameEnvPath(path: string): string {\n\tconst normalized = path.replace(/\\/+$/, \"\");\n\tconst slashIndex = normalized.lastIndexOf(\"/\");\n\treturn slashIndex <= 0 ? \"/\" : normalized.slice(0, slashIndex);\n}\n\nfunction basenameEnvPath(path: string): string {\n\tconst normalized = path.replace(/\\/+$/, \"\");\n\tconst slashIndex = normalized.lastIndexOf(\"/\");\n\treturn slashIndex === -1 ? normalized : normalized.slice(slashIndex + 1);\n}\n\nfunction relativeEnvPath(root: string, path: string): string {\n\tconst normalizedRoot = root.replace(/\\/+$/, \"\");\n\tconst normalizedPath = path.replace(/\\/+$/, \"\");\n\tif (normalizedPath === normalizedRoot) return \"\";\n\treturn normalizedPath.startsWith(`${normalizedRoot}/`)\n\t\t? normalizedPath.slice(normalizedRoot.length + 1)\n\t\t: normalizedPath.replace(/^\\/+/, \"\");\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../src/harness/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAsBnE","sourcesContent":["import type { Skill } from \"./types.js\";\n\nexport function formatSkillsForSystemPrompt(skills: Skill[]): string {\n\tconst visibleSkills = skills.filter((skill) => !skill.disableModelInvocation);\n\tif (visibleSkills.length === 0) return \"\";\n\n\tconst lines = [\n\t\t\"The following skills provide specialized instructions for specific tasks.\",\n\t\t\"Read the full skill file when the task matches its description.\",\n\t\t\"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\t\t\"\",\n\t\t\"<available_skills>\",\n\t];\n\n\tfor (const skill of visibleSkills) {\n\t\tlines.push(\" <skill>\");\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n\t\tlines.push(\" </skill>\");\n\t}\n\n\tlines.push(\"</available_skills>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function formatSkillsForSystemPrompt(skills) {
|
|
2
|
+
const visibleSkills = skills.filter((skill) => !skill.disableModelInvocation);
|
|
3
|
+
if (visibleSkills.length === 0)
|
|
4
|
+
return "";
|
|
5
|
+
const lines = [
|
|
6
|
+
"The following skills provide specialized instructions for specific tasks.",
|
|
7
|
+
"Read the full skill file when the task matches its description.",
|
|
8
|
+
"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.",
|
|
9
|
+
"",
|
|
10
|
+
"<available_skills>",
|
|
11
|
+
];
|
|
12
|
+
for (const skill of visibleSkills) {
|
|
13
|
+
lines.push(" <skill>");
|
|
14
|
+
lines.push(` <name>${escapeXml(skill.name)}</name>`);
|
|
15
|
+
lines.push(` <description>${escapeXml(skill.description)}</description>`);
|
|
16
|
+
lines.push(` <location>${escapeXml(skill.filePath)}</location>`);
|
|
17
|
+
lines.push(" </skill>");
|
|
18
|
+
}
|
|
19
|
+
lines.push("</available_skills>");
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
22
|
+
function escapeXml(value) {
|
|
23
|
+
return value
|
|
24
|
+
.replace(/&/g, "&")
|
|
25
|
+
.replace(/</g, "<")
|
|
26
|
+
.replace(/>/g, ">")
|
|
27
|
+
.replace(/"/g, """)
|
|
28
|
+
.replace(/'/g, "'");
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=system-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.js","sourceRoot":"","sources":["../../src/harness/system-prompt.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,2BAA2B,CAAC,MAAe,EAAU;IACpE,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC9E,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAE1C,MAAM,KAAK,GAAG;QACb,2EAA2E;QAC3E,iEAAiE;QACjE,8KAA8K;QAC9K,EAAE;QACF,oBAAoB;KACpB,CAAC;IAEF,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;QACnC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxB,KAAK,CAAC,IAAI,CAAC,aAAa,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,oBAAoB,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QAC7E,KAAK,CAAC,IAAI,CAAC,iBAAiB,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QACpE,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAAA,CACxB;AAED,SAAS,SAAS,CAAC,KAAa,EAAU;IACzC,OAAO,KAAK;SACV,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAAA,CAC1B","sourcesContent":["import type { Skill } from \"./types.js\";\n\nexport function formatSkillsForSystemPrompt(skills: Skill[]): string {\n\tconst visibleSkills = skills.filter((skill) => !skill.disableModelInvocation);\n\tif (visibleSkills.length === 0) return \"\";\n\n\tconst lines = [\n\t\t\"The following skills provide specialized instructions for specific tasks.\",\n\t\t\"Read the full skill file when the task matches its description.\",\n\t\t\"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\t\t\"\",\n\t\t\"<available_skills>\",\n\t];\n\n\tfor (const skill of visibleSkills) {\n\t\tlines.push(\" <skill>\");\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n\t\tlines.push(\" </skill>\");\n\t}\n\n\tlines.push(\"</available_skills>\");\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(value: string): string {\n\treturn value\n\t\t.replace(/&/g, \"&\")\n\t\t.replace(/</g, \"<\")\n\t\t.replace(/>/g, \">\")\n\t\t.replace(/\"/g, \""\")\n\t\t.replace(/'/g, \"'\");\n}\n"]}
|