From 9be0ea001b95df902af2c8aa882ef47985e24261 Mon Sep 17 00:00:00 2001 From: Willie Date: Mon, 30 Mar 2026 18:16:06 +0800 Subject: [PATCH] fix: agent list metadata, detail lookup, card icon, and time format handler_skills list: read agent metadata directly via os.ReadFile instead of install.ReadMeta (which appends subdirectory). Fixes agents showing as 'local' instead of 'github'. handler_skills detail: strip .md from URL param before agent lookup. Fixes 'skill not found: content-marketer.md' error. handler_skills: use time.RFC3339 instead of hardcoded format string. ResourcesPage: use FileText icon for agents, Folder for skills. --- internal/server/handler_skills.go | 42 ++++++++++++++++++------------- ui/src/pages/ResourcesPage.tsx | 5 +++- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/internal/server/handler_skills.go b/internal/server/handler_skills.go index 82a075831..9ade98be9 100644 --- a/internal/server/handler_skills.go +++ b/internal/server/handler_skills.go @@ -1,6 +1,7 @@ package server import ( + "encoding/json" "fmt" "log" "net/http" @@ -76,7 +77,7 @@ func (s *Server) handleListSkills(w http.ResponseWriter, r *http.Request) { } if meta, _ := install.ReadMeta(d.SourcePath); meta != nil { - item.InstalledAt = meta.InstalledAt.Format("2006-01-02T15:04:05Z") + item.InstalledAt = meta.InstalledAt.Format(time.RFC3339) item.Source = meta.Source item.Type = meta.Type item.RepoURL = meta.RepoURL @@ -107,14 +108,17 @@ func (s *Server) handleListSkills(w http.ResponseWriter, r *http.Request) { SourcePath: agentPath, } - // Check for agent metadata + // Check for agent metadata (agent meta is a standalone file, not inside a dir) metaPath := filepath.Join(agentsSource, agentName+".skillshare-meta.json") - if meta, _ := install.ReadMeta(metaPath); meta != nil { - item.InstalledAt = meta.InstalledAt.Format("2006-01-02T15:04:05Z") - item.Source = meta.Source - item.Type = meta.Type - item.RepoURL = meta.RepoURL - item.Version = meta.Version + if metaData, readErr := os.ReadFile(metaPath); readErr == nil { + var meta install.SkillMeta + if json.Unmarshal(metaData, &meta) == nil { + item.InstalledAt = meta.InstalledAt.Format(time.RFC3339) + item.Source = meta.Source + item.Type = meta.Type + item.RepoURL = meta.RepoURL + item.Version = meta.Version + } } items = append(items, item) @@ -202,24 +206,28 @@ func (s *Server) handleGetSkill(w http.ResponseWriter, r *http.Request) { // Fallback: check agents source if agentsSource != "" { - agentFile := name + ".md" + agentName := strings.TrimSuffix(name, ".md") + agentFile := agentName + ".md" agentPath := filepath.Join(agentsSource, agentFile) if data, err := os.ReadFile(agentPath); err == nil { item := skillItem{ - Name: name, + Name: agentName, Kind: "agent", FlatName: agentFile, RelPath: agentFile, SourcePath: agentPath, } - metaPath := filepath.Join(agentsSource, name+".skillshare-meta.json") - if meta, _ := install.ReadMeta(metaPath); meta != nil { - item.InstalledAt = meta.InstalledAt.Format("2006-01-02T15:04:05Z") - item.Source = meta.Source - item.Type = meta.Type - item.RepoURL = meta.RepoURL - item.Version = meta.Version + metaFilePath := filepath.Join(agentsSource, agentName+".skillshare-meta.json") + if metaData, readErr := os.ReadFile(metaFilePath); readErr == nil { + var meta install.SkillMeta + if json.Unmarshal(metaData, &meta) == nil { + item.InstalledAt = meta.InstalledAt.Format(time.RFC3339) + item.Source = meta.Source + item.Type = meta.Type + item.RepoURL = meta.RepoURL + item.Version = meta.Version + } } writeJSON(w, map[string]any{ diff --git a/ui/src/pages/ResourcesPage.tsx b/ui/src/pages/ResourcesPage.tsx index 3eb5707db..6815ace6b 100644 --- a/ui/src/pages/ResourcesPage.tsx +++ b/ui/src/pages/ResourcesPage.tsx @@ -26,6 +26,7 @@ import { X, Bot, Layers, + FileText, } from 'lucide-react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { VirtuosoGrid, Virtuoso } from 'react-virtuoso'; @@ -605,7 +606,9 @@ const SkillPostit = memo(function SkillPostit({
{skill.isInRepo ? - : + : skill.kind === 'agent' + ? + : }