mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboOs.git
synced 2026-06-17 09:36:55 +00:00
25 lines
934 B
JavaScript
25 lines
934 B
JavaScript
"use strict";
|
|
// Helper to encapsulate skill discovery/creation logic found in the bundle's
|
|
// Be constructor. This is intentionally small and only documents where to
|
|
// extract the logic when you want to fully replace the bundled constructor.
|
|
|
|
exports.createSkills = function (packageInfo, jiboRequire, createSkillFn) {
|
|
// Example small extractor — callers should implement creating Skill instances
|
|
// Parameters:
|
|
// - packageInfo: parsed package.json
|
|
// - jiboRequire: require('jibo') instance (passed in from consumer)
|
|
// - createSkillFn: function(id) => returns constructed skill
|
|
|
|
const skills = {};
|
|
(packageInfo.jibo && packageInfo.jibo.skills || []).forEach((id) => {
|
|
try {
|
|
const Skill = createSkillFn(id);
|
|
if (Skill) skills[id] = Skill;
|
|
}
|
|
catch (e) {
|
|
console.warn('skill creation failed', id, e);
|
|
}
|
|
});
|
|
return skills;
|
|
};
|