feat(db): add project personas and skills tables
CI / build-and-test (push) Failing after 1m52s

* Introduce project_personas table with foreign keys to projects and agent_personas
* Add project_skills table with foreign key to projects and agent_skills
* Include override boolean field in agent_persona_skills and project_skills
* Update schema and migration files to reflect new tables and fields
* Enhance CORS handling to reflect request origin
This commit is contained in:
2026-07-04 23:45:51 +02:00
parent 1adf50e3db
commit c179e014ad
69 changed files with 1329 additions and 184 deletions
+31 -8
View File
@@ -116,6 +116,24 @@ func scanSkill(row skillScanner) (ext.AgentSkill, error) {
}, nil
}
func normalizeSkillSlices(skill *ext.AgentSkill) {
if skill.Tags == nil {
skill.Tags = []string{}
}
if skill.LanguageTags == nil {
skill.LanguageTags = []string{}
}
if skill.LibraryTags == nil {
skill.LibraryTags = []string{}
}
if skill.FrameworkTags == nil {
skill.FrameworkTags = []string{}
}
if skill.DomainTags == nil {
skill.DomainTags = []string{}
}
}
func (db *DB) GetSkill(ctx context.Context, id int64) (ext.AgentSkill, error) {
row := db.pool.QueryRow(ctx, `select `+skillSelectCols+` from agent_skills where id = $1`, id)
s, err := scanSkill(row)
@@ -278,12 +296,12 @@ func (db *DB) GetGuardrail(ctx context.Context, id int64) (ext.AgentGuardrail, e
// Project Skills
func (db *DB) AddProjectSkill(ctx context.Context, projectID, skillID int64) error {
func (db *DB) AddProjectSkill(ctx context.Context, projectID, skillID int64, override bool) error {
_, err := db.pool.Exec(ctx, `
insert into project_skills (project_id, skill_id)
values ($1, $2)
on conflict do nothing
`, projectID, skillID)
insert into project_skills (project_id, skill_id, override)
values ($1, $2, $3)
on conflict (project_id, skill_id) do update set override = excluded.override
`, projectID, skillID, override)
if err != nil {
return fmt.Errorf("add project skill: %w", err)
}
@@ -305,7 +323,9 @@ func (db *DB) RemoveProjectSkill(ctx context.Context, projectID, skillID int64)
func (db *DB) ListProjectSkills(ctx context.Context, projectID int64) ([]ext.AgentSkill, error) {
rows, err := db.pool.Query(ctx, `
select s.`+skillSelectCols+`
select s.id, s.name, s.description, s.content, s.tags::text[],
s.language_tags::text[], s.library_tags::text[], s.framework_tags::text[],
s.domain_tags::text[], s.created_at, s.updated_at, ps.override
from agent_skills s
join project_skills ps on ps.skill_id = s.id
where ps.project_id = $1
@@ -318,10 +338,13 @@ func (db *DB) ListProjectSkills(ctx context.Context, projectID int64) ([]ext.Age
var skills []ext.AgentSkill
for rows.Next() {
s, err := scanSkill(rows)
if err != nil {
var s ext.AgentSkill
if err := rows.Scan(&s.ID, &s.Name, &s.Description, &s.Content, &s.Tags,
&s.LanguageTags, &s.LibraryTags, &s.FrameworkTags, &s.DomainTags,
&s.CreatedAt, &s.UpdatedAt, &s.Override); err != nil {
return nil, fmt.Errorf("scan project skill: %w", err)
}
normalizeSkillSlices(&s)
skills = append(skills, s)
}
return skills, rows.Err()