Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
merge: resolve conflicts with main (skills feature)
Naiyuan Qing06122dfe9e4e
diff --cc apps/web/features/workspace/store.tsindex c0e8e8a5d8,4bb673f160..bbabe377ed--- a/apps/web/features/workspace/store.ts+++ b/apps/web/features/workspace/store.ts@@@ -1,9 -1,7 +1,9 @@@"use client";import { create } from "zustand";- import type { Workspace, MemberWithUser, Agent } from "@multica/types";+ import type { Workspace, MemberWithUser, Agent, Skill } from "@multica/types";+import { useIssueStore } from "@/features/issues";+import { useInboxStore } from "@/features/inbox";import { api } from "@/shared/api";interface WorkspaceState {@@@ -21,8 -20,10 +22,11 @@@ interface WorkspaceActionsswitchWorkspace: (workspaceId: string) => Promise<void>;refreshWorkspaces: () => Promise<Workspace[]>;refreshMembers: () => Promise<void>;+ updateAgent: (id: string, updates: Partial<Agent>) => void;refreshAgents: () => Promise<void>;+ refreshSkills: () => Promise<void>;+ upsertSkill: (skill: Skill) => void;+ removeSkill: (id: string) => void;createWorkspace: (data: {name: string;slug: string;@@@ -65,15 -67,12 +70,16 @@@ export const useWorkspaceStore = createlocalStorage.setItem("multica_workspace_id", nextWorkspace.id);set({ workspace: nextWorkspace });+ console.log("[workspace-store] hydrate workspace:", nextWorkspace.name, nextWorkspace.id);- const [nextMembers, nextAgents] = await Promise.all([+ const [nextMembers, nextAgents, nextSkills] = await Promise.all([api.listMembers(nextWorkspace.id),api.listAgents({ workspace_id: nextWorkspace.id }),+ api.listSkills().catch(() => [] as Skill[]),+ useIssueStore.getState().fetch(),+ useInboxStore.getState().fetch(),]);+ console.log("[workspace-store] hydrate complete, members:", nextMembers.length, "agents:", nextAgents.length);- set({ members: nextMembers, agents: nextAgents });+ set({ members: nextMembers, agents: nextAgents, skills: nextSkills });return nextWorkspace;},@@@ -84,11 -82,6 +90,11 @@@const ws = workspaces.find((item) => item.id === workspaceId);if (!ws) return;+ // Clear stale data from other stores before switching+ useIssueStore.getState().setIssues([]);+ useInboxStore.getState().setItems([]);- set({ agents: [] });++ set({ agents: [], skills: [] });+await hydrateWorkspace(workspaces, ws.id);},diff --cc packages/types/src/events.tsindex 2d46f6a266,9ca647225f..e8e29a7586--- a/packages/types/src/events.ts+++ b/packages/types/src/events.ts@@@ -20,15 -17,11 +20,18 @@@ export type WSEventType| "task:completed"| "task:failed"| "inbox:new"+ | "inbox:read"+ | "inbox:archived"+ | "workspace:updated"+ | "workspace:deleted"+ | "member:added"+ | "member:updated"+ | "member:removed"| "daemon:heartbeat"- | "daemon:register";+ | "daemon:register"+ | "skill:created"+ | "skill:updated"+ | "skill:deleted";export interface WSMessage<T = unknown> {type: WSEventType;diff --cc server/internal/handler/agent.goindex 8af6176fca,935bb388d0..d0ea10e156--- a/server/internal/handler/agent.go+++ b/server/internal/handler/agent.go@@@ -134,22 -129,31 +134,42 @@@ func (h *Handler) ListAgents(w http.Resreturn}+ userID := requestUserID(r)+ isAdmin := roleAllowed(member.Role, "owner", "admin")++ // Batch-load skills for all agents to avoid N+1.+ skillRows, err := h.Queries.ListAgentSkillsByWorkspace(r.Context(), parseUUID(workspaceID))+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to load agent skills")+ return+ }+ skillMap := map[string][]SkillResponse{}+ for _, row := range skillRows {+ agentID := uuidToString(row.AgentID)+ skillMap[agentID] = append(skillMap[agentID], SkillResponse{+ ID: uuidToString(row.ID),+ Name: row.Name,+ Description: row.Description,+ })+ }+- resp := make([]AgentResponse, len(agents))- for i, a := range agents {- resp[i] = agentToResponse(a)- if skills, ok := skillMap[resp[i].ID]; ok {- resp[i].Skills = skills+ // Filter private agents: only visible to owner_id or workspace admin+ var visible []AgentResponse+ for _, a := range agents {+ if a.Visibility == "private" && !isAdmin && uuidToString(a.OwnerID) != userID {+ continue+ }- visible = append(visible, agentToResponse(a))++ resp := agentToResponse(a)++ if skills, ok := skillMap[resp.ID]; ok {++ resp.Skills = skills+ }++ visible = append(visible, resp)+ }+ if visible == nil {+ visible = []AgentResponse{}}- writeJSON(w, http.StatusOK, resp)+ writeJSON(w, http.StatusOK, visible)}func (h *Handler) GetAgent(w http.ResponseWriter, r *http.Request) {@@@ -255,56 -269,9 +285,57 @@@ func (h *Handler) CreateAgent(w http.Reagent, _ = h.Queries.GetAgent(r.Context(), agent.ID)}- writeJSON(w, http.StatusCreated, agentToResponse(agent))+ // Best-effort: create an initialization issue assigned to the new agent.+ h.createAgentInitIssue(r.Context(), agent, parseUUID(ownerID))++ resp := agentToResponse(agent)+ h.publish(protocol.EventAgentCreated, workspaceID, "member", ownerID, map[string]any{"agent": resp})+ writeJSON(w, http.StatusCreated, resp)}+// createAgentInitIssue creates an initialization issue assigned to a newly created agent.+// It incorporates workspace context so the agent can set up its environment.+// Failures are silently ignored — the agent creation itself has already succeeded.+func (h *Handler) createAgentInitIssue(ctx context.Context, agent db.Agent, creatorID pgtype.UUID) {+ ws, err := h.Queries.GetWorkspace(ctx, agent.WorkspaceID)+ if err != nil {+ return+ }++ var desc string+ if ws.Context.Valid && ws.Context.String != "" {+ desc = fmt.Sprintf("Initialize the development environment for agent **%s**.\n\n## Workspace Context\n\n%s\n\n## Instructions\n\n- Set up the local development environment based on the workspace context above\n- Clone and configure any referenced repositories\n- Verify access to the codebase and tools\n- Report back on what was set up and any issues encountered", agent.Name, ws.Context.String)+ } else {+ desc = fmt.Sprintf("Initialize the development environment for agent **%s**.\n\n## Instructions\n\n- Explore the local working directory and understand the project structure\n- Verify access to the codebase and tools\n- Report back on what was found and any issues encountered", agent.Name)+ }++ issue, err := h.Queries.CreateIssue(ctx, db.CreateIssueParams{+ WorkspaceID: agent.WorkspaceID,+ Title: "Initialize environment for " + agent.Name,+ Description: strToText(desc),+ Status: "todo",+ Priority: "medium",+ AssigneeType: pgtype.Text{String: "agent", Valid: true},+ AssigneeID: agent.ID,+ CreatorType: "member",+ CreatorID: creatorID,+ AcceptanceCriteria: []byte("[]"),+ ContextRefs: []byte("[]"),+ Position: 0,+ })+ if err != nil {+ return+ }++ h.publish(protocol.EventIssueCreated, uuidToString(agent.WorkspaceID), "system", "", map[string]any{"issue": issueToResponse(issue)})++ // Enqueue the task directly — we know the agent is assigned and status is "todo".+ if _, err := h.TaskService.EnqueueTaskForIssue(ctx, issue); err != nil {+ log.Printf("createAgentInitIssue: enqueue task failed for issue %s: %v", issue.Title, err)+ }+}+++type UpdateAgentRequest struct {Name *string `json:"name"`Description *string `json:"description"`diff --cc server/internal/handler/skill.goindex 0000000000,39082a31f1..5b02c306camode 000000,100644..100644--- a/server/internal/handler/skill.go+++ b/server/internal/handler/skill.go@@@ -1,0 -1,540 +1,540 @@@+ package handler++ import (+ "encoding/json"+ "net/http"+ "path/filepath"+ "strings"++ "github.com/go-chi/chi/v5"+ "github.com/jackc/pgx/v5/pgtype"+ db "github.com/multica-ai/multica/server/pkg/db/generated"+ )++ // --- Response structs ---++ type SkillResponse struct {+ ID string `json:"id"`+ WorkspaceID string `json:"workspace_id"`+ Name string `json:"name"`+ Description string `json:"description"`+ Content string `json:"content"`+ Config any `json:"config"`+ CreatedBy *string `json:"created_by"`+ CreatedAt string `json:"created_at"`+ UpdatedAt string `json:"updated_at"`+ }++ type SkillFileResponse struct {+ ID string `json:"id"`+ SkillID string `json:"skill_id"`+ Path string `json:"path"`+ Content string `json:"content"`+ CreatedAt string `json:"created_at"`+ UpdatedAt string `json:"updated_at"`+ }++ type SkillWithFilesResponse struct {+ SkillResponse+ Files []SkillFileResponse `json:"files"`+ }++ func skillToResponse(s db.Skill) SkillResponse {+ var config any+ if s.Config != nil {+ json.Unmarshal(s.Config, &config)+ }+ if config == nil {+ config = map[string]any{}+ }++ return SkillResponse{+ ID: uuidToString(s.ID),+ WorkspaceID: uuidToString(s.WorkspaceID),+ Name: s.Name,+ Description: s.Description,+ Content: s.Content,+ Config: config,+ CreatedBy: uuidToPtr(s.CreatedBy),+ CreatedAt: timestampToString(s.CreatedAt),+ UpdatedAt: timestampToString(s.UpdatedAt),+ }+ }++ func skillFileToResponse(f db.SkillFile) SkillFileResponse {+ return SkillFileResponse{+ ID: uuidToString(f.ID),+ SkillID: uuidToString(f.SkillID),+ Path: f.Path,+ Content: f.Content,+ CreatedAt: timestampToString(f.CreatedAt),+ UpdatedAt: timestampToString(f.UpdatedAt),+ }+ }++ // --- Request structs ---++ type CreateSkillRequest struct {+ Name string `json:"name"`+ Description string `json:"description"`+ Content string `json:"content"`+ Config any `json:"config"`+ Files []CreateSkillFileRequest `json:"files,omitempty"`+ }++ type CreateSkillFileRequest struct {+ Path string `json:"path"`+ Content string `json:"content"`+ }++ type UpdateSkillRequest struct {+ Name *string `json:"name"`+ Description *string `json:"description"`+ Content *string `json:"content"`+ Config any `json:"config"`+ Files []CreateSkillFileRequest `json:"files,omitempty"`+ }++ type SetAgentSkillsRequest struct {+ SkillIDs []string `json:"skill_ids"`+ }++ // --- Helpers ---++ // validateFilePath checks that a file path is safe (no traversal, no absolute paths).+ func validateFilePath(p string) bool {+ if p == "" {+ return false+ }+ if filepath.IsAbs(p) {+ return false+ }+ cleaned := filepath.Clean(p)+ if strings.HasPrefix(cleaned, "..") {+ return false+ }+ return true+ }++ func (h *Handler) loadSkillForUser(w http.ResponseWriter, r *http.Request, id string) (db.Skill, bool) {+ skill, err := h.Queries.GetSkill(r.Context(), parseUUID(id))+ if err != nil {+ if isNotFound(err) {+ writeError(w, http.StatusNotFound, "skill not found")+ } else {+ writeError(w, http.StatusInternalServerError, "failed to load skill")+ }+ return skill, false+ }+ if _, ok := h.requireWorkspaceMember(w, r, uuidToString(skill.WorkspaceID), "skill not found"); !ok {+ return skill, false+ }+ return skill, true+ }++ // --- Skill CRUD ---++ func (h *Handler) ListSkills(w http.ResponseWriter, r *http.Request) {+ workspaceID := resolveWorkspaceID(r)+ if _, ok := h.requireWorkspaceMember(w, r, workspaceID, "workspace not found"); !ok {+ return+ }++ skills, err := h.Queries.ListSkillsByWorkspace(r.Context(), parseUUID(workspaceID))+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to list skills")+ return+ }++ resp := make([]SkillResponse, len(skills))+ for i, s := range skills {+ resp[i] = skillToResponse(s)+ }++ writeJSON(w, http.StatusOK, resp)+ }++ func (h *Handler) GetSkill(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ skill, ok := h.loadSkillForUser(w, r, id)+ if !ok {+ return+ }++ files, err := h.Queries.ListSkillFiles(r.Context(), skill.ID)+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to list skill files")+ return+ }++ fileResps := make([]SkillFileResponse, len(files))+ for i, f := range files {+ fileResps[i] = skillFileToResponse(f)+ }++ writeJSON(w, http.StatusOK, SkillWithFilesResponse{+ SkillResponse: skillToResponse(skill),+ Files: fileResps,+ })+ }++ func (h *Handler) CreateSkill(w http.ResponseWriter, r *http.Request) {+ workspaceID := resolveWorkspaceID(r)+ if _, ok := h.requireWorkspaceRole(w, r, workspaceID, "workspace not found", "owner", "admin"); !ok {+ return+ }++ creatorID, ok := requireUserID(w, r)+ if !ok {+ return+ }++ var req CreateSkillRequest+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {+ writeError(w, http.StatusBadRequest, "invalid request body")+ return+ }++ if req.Name == "" {+ writeError(w, http.StatusBadRequest, "name is required")+ return+ }++ for _, f := range req.Files {+ if !validateFilePath(f.Path) {+ writeError(w, http.StatusBadRequest, "invalid file path: "+f.Path)+ return+ }+ }++ config, _ := json.Marshal(req.Config)+ if req.Config == nil {+ config = []byte("{}")+ }++ tx, err := h.TxStarter.Begin(r.Context())+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to start transaction")+ return+ }+ defer tx.Rollback(r.Context())++ qtx := h.Queries.WithTx(tx)++ skill, err := qtx.CreateSkill(r.Context(), db.CreateSkillParams{+ WorkspaceID: parseUUID(workspaceID),+ Name: req.Name,+ Description: req.Description,+ Content: req.Content,+ Config: config,+ CreatedBy: parseUUID(creatorID),+ })+ if err != nil {+ if isUniqueViolation(err) {+ writeError(w, http.StatusConflict, "a skill with this name already exists")+ return+ }+ writeError(w, http.StatusInternalServerError, "failed to create skill: "+err.Error())+ return+ }++ fileResps := make([]SkillFileResponse, 0, len(req.Files))+ for _, f := range req.Files {+ sf, err := qtx.UpsertSkillFile(r.Context(), db.UpsertSkillFileParams{+ SkillID: skill.ID,+ Path: f.Path,+ Content: f.Content,+ })+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to create skill file: "+err.Error())+ return+ }+ fileResps = append(fileResps, skillFileToResponse(sf))+ }++ if err := tx.Commit(r.Context()); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to commit")+ return+ }++ resp := SkillWithFilesResponse{+ SkillResponse: skillToResponse(skill),+ Files: fileResps,+ }- h.broadcast("skill:created", map[string]any{"skill": resp})++ h.publish("skill:created", workspaceID, "member", creatorID, map[string]any{"skill": resp})+ writeJSON(w, http.StatusCreated, resp)+ }++ func (h *Handler) UpdateSkill(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ skill, ok := h.loadSkillForUser(w, r, id)+ if !ok {+ return+ }+ if _, ok := h.requireWorkspaceRole(w, r, uuidToString(skill.WorkspaceID), "skill not found", "owner", "admin"); !ok {+ return+ }++ var req UpdateSkillRequest+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {+ writeError(w, http.StatusBadRequest, "invalid request body")+ return+ }++ for _, f := range req.Files {+ if !validateFilePath(f.Path) {+ writeError(w, http.StatusBadRequest, "invalid file path: "+f.Path)+ return+ }+ }++ tx, err := h.TxStarter.Begin(r.Context())+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to start transaction")+ return+ }+ defer tx.Rollback(r.Context())++ qtx := h.Queries.WithTx(tx)++ params := db.UpdateSkillParams{+ ID: parseUUID(id),+ }+ if req.Name != nil {+ params.Name = pgtype.Text{String: *req.Name, Valid: true}+ }+ if req.Description != nil {+ params.Description = pgtype.Text{String: *req.Description, Valid: true}+ }+ if req.Content != nil {+ params.Content = pgtype.Text{String: *req.Content, Valid: true}+ }+ if req.Config != nil {+ config, _ := json.Marshal(req.Config)+ params.Config = config+ }++ skill, err = qtx.UpdateSkill(r.Context(), params)+ if err != nil {+ if isUniqueViolation(err) {+ writeError(w, http.StatusConflict, "a skill with this name already exists")+ return+ }+ writeError(w, http.StatusInternalServerError, "failed to update skill: "+err.Error())+ return+ }++ // If files are provided, replace all files.+ var fileResps []SkillFileResponse+ if req.Files != nil {+ if err := qtx.DeleteSkillFilesBySkill(r.Context(), skill.ID); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to delete old skill files")+ return+ }+ fileResps = make([]SkillFileResponse, 0, len(req.Files))+ for _, f := range req.Files {+ sf, err := qtx.UpsertSkillFile(r.Context(), db.UpsertSkillFileParams{+ SkillID: skill.ID,+ Path: f.Path,+ Content: f.Content,+ })+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to upsert skill file: "+err.Error())+ return+ }+ fileResps = append(fileResps, skillFileToResponse(sf))+ }+ } else {+ files, _ := qtx.ListSkillFiles(r.Context(), skill.ID)+ fileResps = make([]SkillFileResponse, len(files))+ for i, f := range files {+ fileResps[i] = skillFileToResponse(f)+ }+ }++ if err := tx.Commit(r.Context()); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to commit")+ return+ }++ resp := SkillWithFilesResponse{+ SkillResponse: skillToResponse(skill),+ Files: fileResps,+ }- h.broadcast("skill:updated", map[string]any{"skill": resp})++ h.publish("skill:updated", resolveWorkspaceID(r), "member", requestUserID(r), map[string]any{"skill": resp})+ writeJSON(w, http.StatusOK, resp)+ }++ func (h *Handler) DeleteSkill(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ skill, ok := h.loadSkillForUser(w, r, id)+ if !ok {+ return+ }+ if _, ok := h.requireWorkspaceRole(w, r, uuidToString(skill.WorkspaceID), "skill not found", "owner", "admin"); !ok {+ return+ }++ if err := h.Queries.DeleteSkill(r.Context(), parseUUID(id)); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to delete skill")+ return+ }- h.broadcast("skill:deleted", map[string]any{"skill_id": id})++ h.publish("skill:deleted", uuidToString(skill.WorkspaceID), "member", requestUserID(r), map[string]any{"skill_id": id})+ w.WriteHeader(http.StatusNoContent)+ }++ // --- Skill File endpoints ---++ func (h *Handler) ListSkillFiles(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ skill, ok := h.loadSkillForUser(w, r, id)+ if !ok {+ return+ }++ files, err := h.Queries.ListSkillFiles(r.Context(), skill.ID)+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to list skill files")+ return+ }++ resp := make([]SkillFileResponse, len(files))+ for i, f := range files {+ resp[i] = skillFileToResponse(f)+ }+ writeJSON(w, http.StatusOK, resp)+ }++ func (h *Handler) UpsertSkillFile(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ skill, ok := h.loadSkillForUser(w, r, id)+ if !ok {+ return+ }+ if _, ok := h.requireWorkspaceRole(w, r, uuidToString(skill.WorkspaceID), "skill not found", "owner", "admin"); !ok {+ return+ }++ var req CreateSkillFileRequest+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {+ writeError(w, http.StatusBadRequest, "invalid request body")+ return+ }++ if !validateFilePath(req.Path) {+ writeError(w, http.StatusBadRequest, "invalid file path")+ return+ }++ sf, err := h.Queries.UpsertSkillFile(r.Context(), db.UpsertSkillFileParams{+ SkillID: skill.ID,+ Path: req.Path,+ Content: req.Content,+ })+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to upsert skill file: "+err.Error())+ return+ }++ writeJSON(w, http.StatusOK, skillFileToResponse(sf))+ }++ func (h *Handler) DeleteSkillFile(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ skill, ok := h.loadSkillForUser(w, r, id)+ if !ok {+ return+ }+ if _, ok := h.requireWorkspaceRole(w, r, uuidToString(skill.WorkspaceID), "skill not found", "owner", "admin"); !ok {+ return+ }++ fileID := chi.URLParam(r, "fileId")+ if err := h.Queries.DeleteSkillFile(r.Context(), parseUUID(fileID)); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to delete skill file")+ return+ }+ w.WriteHeader(http.StatusNoContent)+ }++ // --- Agent-Skill junction ---++ func (h *Handler) ListAgentSkills(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ agent, ok := h.loadAgentForUser(w, r, id)+ if !ok {+ return+ }++ skills, err := h.Queries.ListAgentSkills(r.Context(), agent.ID)+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to list agent skills")+ return+ }++ resp := make([]SkillResponse, len(skills))+ for i, s := range skills {+ resp[i] = skillToResponse(s)+ }+ writeJSON(w, http.StatusOK, resp)+ }++ func (h *Handler) SetAgentSkills(w http.ResponseWriter, r *http.Request) {+ id := chi.URLParam(r, "id")+ agent, ok := h.loadAgentForUser(w, r, id)+ if !ok {+ return+ }+ if _, ok := h.requireWorkspaceRole(w, r, uuidToString(agent.WorkspaceID), "agent not found", "owner", "admin"); !ok {+ return+ }++ var req SetAgentSkillsRequest+ if err := json.NewDecoder(r.Body).Decode(&req); err != nil {+ writeError(w, http.StatusBadRequest, "invalid request body")+ return+ }++ tx, err := h.TxStarter.Begin(r.Context())+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to start transaction")+ return+ }+ defer tx.Rollback(r.Context())++ qtx := h.Queries.WithTx(tx)++ if err := qtx.RemoveAllAgentSkills(r.Context(), agent.ID); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to clear agent skills")+ return+ }++ for _, skillID := range req.SkillIDs {+ if err := qtx.AddAgentSkill(r.Context(), db.AddAgentSkillParams{+ AgentID: agent.ID,+ SkillID: parseUUID(skillID),+ }); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to add agent skill: "+err.Error())+ return+ }+ }++ if err := tx.Commit(r.Context()); err != nil {+ writeError(w, http.StatusInternalServerError, "failed to commit")+ return+ }++ // Return the updated skills list.+ skills, err := h.Queries.ListAgentSkills(r.Context(), agent.ID)+ if err != nil {+ writeError(w, http.StatusInternalServerError, "failed to list agent skills")+ return+ }++ resp := make([]SkillResponse, len(skills))+ for i, s := range skills {+ resp[i] = skillToResponse(s)+ }- h.broadcast("agent:status", map[string]any{"agent_id": uuidToString(agent.ID), "skills": resp})++ h.publish("agent:status", uuidToString(agent.WorkspaceID), "member", requestUserID(r), map[string]any{"agent_id": uuidToString(agent.ID), "skills": resp})+ writeJSON(w, http.StatusOK, resp)+ }diff --cc server/internal/service/task.goindex 6e9b6a6c7d,3c191b3204..aa7d9fa2f0--- a/server/internal/service/task.go+++ b/server/internal/service/task.go@@@ -262,16 -257,39 +265,45 @@@ func (s *TaskService) updateAgentStatusif err != nil {return}- s.broadcast(protocol.EventAgentStatus, map[string]any{"agent": agentToMap(agent)})+ s.Bus.Publish(events.Event{+ Type: protocol.EventAgentStatus,+ WorkspaceID: util.UUIDToString(agent.WorkspaceID),+ ActorType: "system",+ ActorID: "",+ Payload: map[string]any{"agent": agentToMap(agent)},+ })}- func buildContextSnapshot(issue db.Issue, agent db.Agent, runtime db.AgentRuntime, workspaceContext string) map[string]any {+ type skillSnapshot struct {+ Name string `json:"name"`+ Content string `json:"content"`+ Files []skillFileSnapshot `json:"files,omitempty"`+ }++ type skillFileSnapshot struct {+ Path string `json:"path"`+ Content string `json:"content"`+ }++ func (s *TaskService) loadAgentSkillsForSnapshot(ctx context.Context, agentID pgtype.UUID) []skillSnapshot {+ skills, err := s.Queries.ListAgentSkills(ctx, agentID)+ if err != nil || len(skills) == 0 {+ return nil+ }++ result := make([]skillSnapshot, 0, len(skills))+ for _, sk := range skills {+ snap := skillSnapshot{Name: sk.Name, Content: sk.Content}+ files, _ := s.Queries.ListSkillFiles(ctx, sk.ID)+ for _, f := range files {+ snap.Files = append(snap.Files, skillFileSnapshot{Path: f.Path, Content: f.Content})+ }+ result = append(result, snap)+ }+ return result+ }++ func buildContextSnapshot(issue db.Issue, agent db.Agent, runtime db.AgentRuntime, workspaceContext string, skills []skillSnapshot) map[string]any {var ac []stringif issue.AcceptanceCriteria != nil {json.Unmarshal(issue.AcceptanceCriteria, &ac)