21ff42074d
## Summary This PR introduces a Skills system for AI agents, inspired by the [Agent Skills specification](https://agentskills.io/specification). ## Changes ### Backend - **SkillEntity**: New database entity with migration for storing skills - **V2 Sync Mechanism**: Implemented FlatSkill, builders, validators, and action handlers following the v2 flat entity pattern - **Standard Skills**: Pre-defined skills (workflow-building, data-manipulation, dashboard-building, metadata-building, research, code-interpreter, xlsx, pdf, docx, pptx) - **GraphQL API**: CRUD operations for skills with proper guards and permissions - **Workspace Cache**: Integrated skills into the workspace cache system ### Frontend - **Skills Table**: Searchable table in AI settings showing all skills - **Skill Form**: Create/edit page with Label (primary), Description, and Content (markdown editor) - **API Name**: Following existing patterns, name is derived from label with advanced settings toggle for custom API names - **Standard vs Custom**: Standard skills are read-only, custom skills can be edited/deleted ## Key Design Decisions - Skills are stored in the database (Salesforce-like approach) rather than files - Name is derived from Label by default (isLabelSyncedWithName pattern) - Skills reference functions/files via @ mentions in markdown content rather than explicit relations - Standard skills are synced from code, custom skills are created via UI ## Screenshots Skills table and form UI follow existing settings patterns. ## Testing - [x] Lint passes - [x] Typecheck passes - [ ] CI tests
114 lines
3.0 KiB
TypeScript
114 lines
3.0 KiB
TypeScript
import { activateSkill } from 'test/integration/metadata/suites/skill/utils/activate-skill.util';
|
|
import { createSkill } from 'test/integration/metadata/suites/skill/utils/create-skill.util';
|
|
import { deactivateSkill } from 'test/integration/metadata/suites/skill/utils/deactivate-skill.util';
|
|
import { deleteSkill } from 'test/integration/metadata/suites/skill/utils/delete-skill.util';
|
|
|
|
describe('Skill activation should succeed', () => {
|
|
let testSkillId: string;
|
|
|
|
beforeEach(async () => {
|
|
const { data } = await createSkill({
|
|
expectToFail: false,
|
|
input: {
|
|
name: 'testSkillForActivation',
|
|
label: 'Test Skill For Activation',
|
|
content: 'Test content',
|
|
},
|
|
});
|
|
|
|
testSkillId = data.createSkill.id;
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await deleteSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
});
|
|
|
|
it('should create a skill with isActive true by default', async () => {
|
|
const { data } = await createSkill({
|
|
expectToFail: false,
|
|
input: {
|
|
name: 'activeByDefaultSkill',
|
|
label: 'Active By Default Skill',
|
|
content: 'Test content',
|
|
},
|
|
});
|
|
|
|
const skillId = data.createSkill.id;
|
|
|
|
expect(data.createSkill).toMatchObject({
|
|
id: skillId,
|
|
isActive: true,
|
|
isCustom: true,
|
|
});
|
|
|
|
await deleteSkill({
|
|
expectToFail: false,
|
|
input: { id: skillId },
|
|
});
|
|
});
|
|
|
|
it('should deactivate a skill', async () => {
|
|
const { data } = await deactivateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
expect(data.deactivateSkill).toMatchObject({
|
|
id: testSkillId,
|
|
isActive: false,
|
|
});
|
|
});
|
|
|
|
it('should activate a deactivated skill', async () => {
|
|
await deactivateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
const { data } = await activateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
expect(data.activateSkill).toMatchObject({
|
|
id: testSkillId,
|
|
isActive: true,
|
|
});
|
|
});
|
|
|
|
it('should allow deactivating an already active skill (no-op)', async () => {
|
|
const { data: firstDeactivate } = await deactivateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
expect(firstDeactivate.deactivateSkill.isActive).toBe(false);
|
|
|
|
const { data: secondDeactivate } = await deactivateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
expect(secondDeactivate.deactivateSkill.isActive).toBe(false);
|
|
});
|
|
|
|
it('should allow activating an already active skill (no-op)', async () => {
|
|
const { data: firstActivate } = await activateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
expect(firstActivate.activateSkill.isActive).toBe(true);
|
|
|
|
const { data: secondActivate } = await activateSkill({
|
|
expectToFail: false,
|
|
input: { id: testSkillId },
|
|
});
|
|
|
|
expect(secondActivate.activateSkill.isActive).toBe(true);
|
|
});
|
|
});
|