@nylorun/agents 0.20.0-beta → 0.21.0-beta

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.
@@ -1,8 +1,7 @@
1
1
  import { basename } from "node:path";
2
- import { formatSkillCatalog, SKILLS_USAGE } from "./catalog.js";
3
2
  import { loadSkillsFromDirectory, resolveSkillsRoot, } from "./load.js";
4
3
  /**
5
- * Load an agentskills.io catalog folder and return one capability for `Agent.use`.
4
+ * Load an agentskills.io catalog folder as one part of an agent, for `.skills()`.
6
5
  *
7
6
  * Expected layout:
8
7
  * ```
@@ -15,39 +14,34 @@ import { loadSkillsFromDirectory, resolveSkillsRoot, } from "./load.js";
15
14
  *
16
15
  * Sets `skills`: each skill's name, description and files (every file of its folder, binary
17
16
  * included, by content hash). The client uploads the files the Runtime lacks when it registers
18
- * the agent, and the Runtime serves `load_skill` / `read_skill_resource` from them.
17
+ * the agent; the Runtime adds the skill catalog and serves `load_skill` / `read_skill_resource`
18
+ * from them.
19
19
  */
20
- export function skills(directory, options = {}) {
20
+ export function skills(directory) {
21
21
  const root = resolveSkillsRoot(directory);
22
22
  const diagnostics = [];
23
23
  const loaded = loadSkillsFromDirectory(root, diagnostics);
24
24
  const listed = Object.values(loaded);
25
- const id = options.id ?? basename(root);
25
+ const id = `skills:${basename(root)}`;
26
26
  if (listed.length === 0) {
27
27
  return { id, root, diagnostics };
28
28
  }
29
- const { skills: skillManifest, skillFiles } = skillsDeclaration(listed);
30
- return {
31
- id,
32
- root,
33
- instructions: [
34
- SKILLS_USAGE,
35
- formatSkillCatalog(listed.map((skill) => ({
36
- name: skill.name,
37
- description: skill.description,
38
- }))),
39
- ],
40
- skills: skillManifest,
41
- skillFiles,
42
- diagnostics,
43
- };
29
+ return { id, root, ...skillsDeclaration(listed), diagnostics };
44
30
  }
45
- /** The manifest's skills and the bytes behind their files, for a capability declaration. */
46
- export function skillsDeclaration(listed) {
31
+ /**
32
+ * The manifest's skills and the bytes behind their files. A plugin's skills carry its label, so
33
+ * a tool call can be traced to the plugin that brought the skill.
34
+ */
35
+ export function skillsDeclaration(listed, plugin) {
47
36
  return {
48
37
  skills: Object.fromEntries(listed.map((skill) => [
49
38
  skill.name,
50
- { name: skill.name, description: skill.description, files: skill.files },
39
+ {
40
+ name: skill.name,
41
+ description: skill.description,
42
+ files: skill.files,
43
+ ...(plugin === undefined ? {} : { plugin }),
44
+ },
51
45
  ])),
52
46
  skillFiles: Object.assign({}, ...listed.map((skill) => skill.sources)),
53
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/agents",
3
- "version": "0.20.0-beta",
3
+ "version": "0.21.0-beta",
4
4
  "description": "Nylorun agent definitions and session client",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -43,7 +43,7 @@
43
43
  "test": "vitest run --passWithNoTests"
44
44
  },
45
45
  "dependencies": {
46
- "@nylorun/core": "0.20.0-beta",
46
+ "@nylorun/core": "0.21.0-beta",
47
47
  "gray-matter": "^4.0.3"
48
48
  },
49
49
  "peerDependencies": {
@@ -1,5 +0,0 @@
1
- export declare const SKILLS_USAGE = "The following skills provide specialized instructions. When a task matches a skill description, call load_skill with that name before proceeding.";
2
- export declare function formatSkillCatalog(skills: readonly {
3
- name: string;
4
- description: string;
5
- }[]): string;
@@ -1,14 +0,0 @@
1
- export const SKILLS_USAGE = "The following skills provide specialized instructions. When a task matches a skill description, call load_skill with that name before proceeding.";
2
- export function formatSkillCatalog(skills) {
3
- const entries = skills
4
- .map((skill) => ` <skill>\n <name>${escapeXml(skill.name)}</name>\n <description>${escapeXml(skill.description)}</description>\n </skill>`)
5
- .join("\n");
6
- return `<available_skills>\n${entries}\n</available_skills>`;
7
- }
8
- function escapeXml(value) {
9
- return value
10
- .replaceAll("&", "&amp;")
11
- .replaceAll("<", "&lt;")
12
- .replaceAll(">", "&gt;")
13
- .replaceAll('"', "&quot;");
14
- }