Skip to content
English

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。

字段结构 ​

字段类型必需说明
descriptionstring必需只读。Description taken from the document header and matching the registration.
instructionsstring必需只读。Instruction body without the header, bounded by maxInstructionChars.
idstring必需只读。Skill id, lowercase kebab case, bounded by maxIdChars (64 by default).
entrystring必需只读。Document path; must equal the loader's entryFor(id) result.
kind"text-workflow"必需只读。Only text workflow skills are supported.
toolIdsreadonly string[]必需只读。Tool ids the instructions may reference; validated by the caller, not executed here.

使用示例 ​

从明确来源读取一份文本 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);

相关策略源码 ​

相关定义 ​

接口参考、使用示例与开发指南。