feat: structured skills system with meta skill runtime injection
Replace agent.skills TEXT field with structured skill/skill_file/agent_skill tables. Skills are workspace-level entities with supporting files, reusable across agents via many-to-many bindings. Backend: migration 008, sqlc queries, CRUD handler, agent-skill junction, structured skill loading in task context snapshot. Daemon: meta skill injection via runtime-native config (.claude/CLAUDE.md for Claude, AGENTS.md for Codex) so agents discover .agent_context/ skills through their native mechanism. Lean prompt without inlined skill content. Frontend: Skills management page, agent Skills tab picker, SDK methods, TypeScript types, workspace store integration. Also removes auto-creation of init issues when creating agents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
63df5dccda
commit
02df33803a
29 changed files with 2320 additions and 192 deletions
80
server/pkg/db/queries/skill.sql
Normal file
80
server/pkg/db/queries/skill.sql
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
-- Skill CRUD
|
||||
|
||||
-- name: ListSkillsByWorkspace :many
|
||||
SELECT * FROM skill
|
||||
WHERE workspace_id = $1
|
||||
ORDER BY name ASC;
|
||||
|
||||
-- name: GetSkill :one
|
||||
SELECT * FROM skill
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: CreateSkill :one
|
||||
INSERT INTO skill (workspace_id, name, description, content, config, created_by)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
RETURNING *;
|
||||
|
||||
-- name: UpdateSkill :one
|
||||
UPDATE skill SET
|
||||
name = COALESCE(sqlc.narg('name'), name),
|
||||
description = COALESCE(sqlc.narg('description'), description),
|
||||
content = COALESCE(sqlc.narg('content'), content),
|
||||
config = COALESCE(sqlc.narg('config'), config),
|
||||
updated_at = now()
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteSkill :exec
|
||||
DELETE FROM skill WHERE id = $1;
|
||||
|
||||
-- Skill File CRUD
|
||||
|
||||
-- name: ListSkillFiles :many
|
||||
SELECT * FROM skill_file
|
||||
WHERE skill_id = $1
|
||||
ORDER BY path ASC;
|
||||
|
||||
-- name: GetSkillFile :one
|
||||
SELECT * FROM skill_file
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: UpsertSkillFile :one
|
||||
INSERT INTO skill_file (skill_id, path, content)
|
||||
VALUES ($1, $2, $3)
|
||||
ON CONFLICT (skill_id, path) DO UPDATE SET
|
||||
content = EXCLUDED.content,
|
||||
updated_at = now()
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteSkillFile :exec
|
||||
DELETE FROM skill_file WHERE id = $1;
|
||||
|
||||
-- name: DeleteSkillFilesBySkill :exec
|
||||
DELETE FROM skill_file WHERE skill_id = $1;
|
||||
|
||||
-- Agent-Skill junction
|
||||
|
||||
-- name: ListAgentSkills :many
|
||||
SELECT s.* FROM skill s
|
||||
JOIN agent_skill ask ON ask.skill_id = s.id
|
||||
WHERE ask.agent_id = $1
|
||||
ORDER BY s.name ASC;
|
||||
|
||||
-- name: AddAgentSkill :exec
|
||||
INSERT INTO agent_skill (agent_id, skill_id)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT DO NOTHING;
|
||||
|
||||
-- name: RemoveAgentSkill :exec
|
||||
DELETE FROM agent_skill
|
||||
WHERE agent_id = $1 AND skill_id = $2;
|
||||
|
||||
-- name: RemoveAllAgentSkills :exec
|
||||
DELETE FROM agent_skill WHERE agent_id = $1;
|
||||
|
||||
-- name: ListAgentSkillsByWorkspace :many
|
||||
SELECT ask.agent_id, s.id, s.name, s.description
|
||||
FROM agent_skill ask
|
||||
JOIN skill s ON s.id = ask.skill_id
|
||||
WHERE s.workspace_id = $1
|
||||
ORDER BY s.name ASC;
|
||||
Loading…
Add table
Add a link
Reference in a new issue