TextSkills: read-only text Skills
Validate registered text work instructions that the App reads; code inside the files is never executed.
load({entries}, {read}) returns a frozen TextSkill array. The default entry rule is id/SKILL.md; the default strict header requires name and description to appear in that order. The default maxIdChars=64, and the description and instruction budgets must be provided explicitly. The registered kind must be text-workflow, and toolIds must be unique. read and parseHeader are synchronous, and returning a Promise by mistake is rejected.
toolIds are declared dependencies; this text alone does not register, authorize, or execute tools. Source allowlists, file access, installation, and publication belong to the App.
Progressive examples for the same business case
Read one text Skill from an explicit source
Beginner · Node.js
import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['summarize/SKILL.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120 });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'summarize/SKILL.md', kind: 'text-workflow', toolIds: [] }] }, {
read(entry) { const text = documents.get(entry); if (!text) throw new Error('来源未登记'); return text; },
});
console.log(skills[0].description);import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['summarize/SKILL.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120 });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'summarize/SKILL.md', kind: 'text-workflow', toolIds: [] }] }, {
read(entry) { const text = documents.get(entry); if (!text)
throw new Error('来源未登记'); return text; },
});
console.log(skills[0].description);Add the application's own entry convention to the same loader
Configuration · Node.js
Entry rules and tool references are only registration checks; the actual tools still need to be registered and authorized by the application.
import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['skills/summarize.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120, maxIdChars: 32, entryFor: id => 'skills/' + id + '.md' });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'skills/summarize.md', kind: 'text-workflow', toolIds: ['read-source'] }] }, {
read(entry) { const text = documents.get(entry); if (!text) throw new Error('来源未登记'); return text; },
});
console.log(skills[0].toolIds);import { TextSkills } from '@jangts/agent-core/kits/text-skills';
const documents = new Map([['skills/summarize.md', '---\nname: summarize\ndescription: 汇总已读取资料\n---\n只根据已确认资料总结。']]);
const loader = TextSkills.defineTextSkillLoader({ maxInstructionChars: 2000, maxDescriptionChars: 120, maxIdChars: 32, entryFor: id => 'skills/' + id + '.md' });
const skills = loader.load({ entries: [{ id: 'summarize', entry: 'skills/summarize.md', kind: 'text-workflow', toolIds: ['read-source'] }] }, {
read(entry) { const text = documents.get(entry); if (!text)
throw new Error('来源未登记'); return text; },
});
console.log(skills[0].toolIds);