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>
41 lines
1.5 KiB
SQL
41 lines
1.5 KiB
SQL
-- Structured Skills: workspace-level skill entities with supporting files
|
|
-- and many-to-many agent-skill associations.
|
|
|
|
CREATE TABLE skill (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
workspace_id UUID NOT NULL REFERENCES workspace(id) ON DELETE CASCADE,
|
|
name TEXT NOT NULL,
|
|
description TEXT NOT NULL DEFAULT '',
|
|
content TEXT NOT NULL DEFAULT '',
|
|
config JSONB NOT NULL DEFAULT '{}',
|
|
created_by UUID REFERENCES "user"(id),
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(workspace_id, name)
|
|
);
|
|
|
|
CREATE TABLE skill_file (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
skill_id UUID NOT NULL REFERENCES skill(id) ON DELETE CASCADE,
|
|
path TEXT NOT NULL,
|
|
content TEXT NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE(skill_id, path)
|
|
);
|
|
|
|
CREATE TABLE agent_skill (
|
|
agent_id UUID NOT NULL REFERENCES agent(id) ON DELETE CASCADE,
|
|
skill_id UUID NOT NULL REFERENCES skill(id) ON DELETE CASCADE,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (agent_id, skill_id)
|
|
);
|
|
|
|
-- Remove old text-based skills column from agent
|
|
ALTER TABLE agent DROP COLUMN IF EXISTS skills;
|
|
|
|
-- Indexes
|
|
CREATE INDEX idx_skill_workspace ON skill(workspace_id);
|
|
CREATE INDEX idx_skill_file_skill ON skill_file(skill_id);
|
|
CREATE INDEX idx_agent_skill_skill ON agent_skill(skill_id);
|
|
CREATE INDEX idx_agent_skill_agent ON agent_skill(agent_id);
|