TextSkill
KIT · interface · 类型合同
Loaded skill: registration plus the parsed document text.
导入
ts
import type { TextSkill } from '@jangts/agent-core/kits/text-skills';js
/** @typedef {import('@jangts/agent-core/kits/text-skills').TextSkill} TextSkill */其他公开入口:@jangts/agent-core、@jangts/agent-core/types、@jangts/agent-core/structs、@jangts/agent-core/kits/text-skills、@jangts/agent-core/kits。
定义
ts
interface TextSkill继承或实现: TextSkillRegistration。
字段结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
description | string | 必需 | 只读。Description taken from the document header and matching the registration. |
instructions | string | 必需 | 只读。Instruction body without the header, bounded by maxInstructionChars. |
id | string | 必需 | 只读。Skill id, lowercase kebab case, bounded by maxIdChars (64 by default). |
entry | string | 必需 | 只读。Document path; must equal the loader's entryFor(id) result. |
kind | "text-workflow" | 必需 | 只读。Only text workflow skills are supported. |
toolIds | readonly string[] | 必需 | 只读。Tool ids the instructions may reference; validated by the caller, not executed here. |
使用示例
- TextSkills:只读文本 Skill:校验已登记的文本工作说明,读取由 App 提供;不运行文件里的代码。
从明确来源读取一份文本 Skill
入门 · Node.js
ts
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);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);同一 loader 增加应用自己的入口约定
配置 · Node.js
入口规则和工具引用只做登记校验;实际工具仍需应用注册和授权。
ts
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);js
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);