okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221apps/host: the owner's UI and the Node App Host0b3299a01

main
911 B14 linesraw
1/** Local overrides leave the original bundled/workspace instructions intact. */
2export function skillEdit(body) {
3  const edit = {};
4  for (const [key, max, required] of [['name', 120, true], ['description', 500, false], ['body', 64000, true]]) {
5    if (body[key] === undefined) continue;
6    if (typeof body[key] !== 'string' || body[key].length > max || (required && !body[key].trim())) throw new Error(`Invalid ${key}: ${required ? 'enter text, ' : ''}maximum ${max} characters.`);
7    edit[key] = key === 'body' ? body[key] : body[key].trim();
8  }
9  if (body.triggers !== undefined) {
10    if (!Array.isArray(body.triggers) || body.triggers.length > 32 || body.triggers.some(t => typeof t !== 'string' || t.length > 160)) throw new Error('Use up to 32 trigger phrases, at most 160 characters each.');
11    edit.triggers = [...new Set(body.triggers.map(t => t.trim()).filter(Boolean))];
12  }
13  return edit;
14}