feat(ui): add content editor components for skills and thoughts
Some checks failed
CI / build-and-test (push) Failing after -31m24s
Some checks failed
CI / build-and-test (push) Failing after -31m24s
* Implement ContentEditorField for inline editing of content * Create ContentEditorModal for editing content in a modal * Introduce FormerShell for managing forms related to skills and thoughts * Enhance SkillsPage and ThoughtsPage with new components for better content management
This commit is contained in:
@@ -214,10 +214,10 @@ func routes(logger *slog.Logger, cfg *config.Config, info buildinfo.Info, db *st
|
||||
Backfill: backfillTool,
|
||||
Reparse: tools.NewReparseMetadataTool(db, bgMetadata, cfg.Capture, activeProjects, logger),
|
||||
RetryMetadata: tools.NewRetryEnrichmentTool(enrichmentRetryer),
|
||||
Maintenance: tools.NewMaintenanceTool(db),
|
||||
Skills: tools.NewSkillsTool(db, activeProjects),
|
||||
ChatHistory: tools.NewChatHistoryTool(db, activeProjects),
|
||||
Describe: tools.NewDescribeTool(db, mcpserver.BuildToolCatalog()),
|
||||
//Maintenance: tools.NewMaintenanceTool(db),
|
||||
Skills: tools.NewSkillsTool(db, activeProjects),
|
||||
ChatHistory: tools.NewChatHistoryTool(db, activeProjects),
|
||||
Describe: tools.NewDescribeTool(db, mcpserver.BuildToolCatalog()),
|
||||
}
|
||||
|
||||
mcpHandlers, err := mcpserver.NewHandlers(cfg.MCP, logger, toolSet, activeProjects.Clear)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/bitechdev/ResolveSpec/pkg/resolvespec"
|
||||
"github.com/uptrace/bunrouter"
|
||||
@@ -26,6 +27,21 @@ func registerResolveSpecAdminRoutes(mux *http.ServeMux, db *store.DB, middleware
|
||||
|
||||
rsMount := http.StripPrefix("/api/rs", rsRouter)
|
||||
protectedRSMount := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" && strings.HasSuffix(r.URL.Path, "/") {
|
||||
trimmed := strings.TrimRight(r.URL.Path, "/")
|
||||
if trimmed == "" {
|
||||
trimmed = "/"
|
||||
}
|
||||
clone := r.Clone(r.Context())
|
||||
clone.URL.Path = trimmed
|
||||
if clone.URL.RawPath != "" {
|
||||
clone.URL.RawPath = strings.TrimRight(clone.URL.RawPath, "/")
|
||||
if clone.URL.RawPath == "" {
|
||||
clone.URL.RawPath = "/"
|
||||
}
|
||||
}
|
||||
r = clone
|
||||
}
|
||||
if r.Method == http.MethodOptions {
|
||||
rsMount.ServeHTTP(w, r)
|
||||
return
|
||||
@@ -50,15 +66,36 @@ func registerResolveSpecGuards(rs *resolvespec.Handler) {
|
||||
mutableByEntity := map[string]map[string]struct{}{
|
||||
"projects": {
|
||||
"create": {},
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
"thoughts": {
|
||||
"create": {},
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
"plans": {
|
||||
"create": {},
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
"learnings": {
|
||||
"create": {},
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
"agent_skills": {
|
||||
"create": {},
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
"agent_guardrails": {
|
||||
"create": {},
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
"stored_files": {
|
||||
"update": {},
|
||||
"delete": {},
|
||||
},
|
||||
}
|
||||
@@ -98,33 +135,35 @@ type resolveSpecModel struct {
|
||||
}
|
||||
|
||||
func resolveSpecModels() []resolveSpecModel {
|
||||
//This must be generated with relspec to include all models
|
||||
//Use the relspec command with template generation. It supprot templ.
|
||||
return []resolveSpecModel{
|
||||
{schema: "public", entity: "activities", model: generatedmodels.ModelPublicActivities{}},
|
||||
// {schema: "public", entity: "activities", model: generatedmodels.ModelPublicActivities{}},
|
||||
{schema: "public", entity: "agent_guardrails", model: generatedmodels.ModelPublicAgentGuardrails{}},
|
||||
{schema: "public", entity: "agent_skills", model: generatedmodels.ModelPublicAgentSkills{}},
|
||||
{schema: "public", entity: "chat_histories", model: generatedmodels.ModelPublicChatHistories{}},
|
||||
{schema: "public", entity: "contact_interactions", model: generatedmodels.ModelPublicContactInteractions{}},
|
||||
// {schema: "public", entity: "contact_interactions", model: generatedmodels.ModelPublicContactInteractions{}},
|
||||
{schema: "public", entity: "embeddings", model: generatedmodels.ModelPublicEmbeddings{}},
|
||||
{schema: "public", entity: "family_members", model: generatedmodels.ModelPublicFamilyMembers{}},
|
||||
{schema: "public", entity: "household_items", model: generatedmodels.ModelPublicHouseholdItems{}},
|
||||
{schema: "public", entity: "household_vendors", model: generatedmodels.ModelPublicHouseholdVendors{}},
|
||||
{schema: "public", entity: "important_dates", model: generatedmodels.ModelPublicImportantDates{}},
|
||||
// {schema: "public", entity: "family_members", model: generatedmodels.ModelPublicFamilyMembers{}},
|
||||
// {schema: "public", entity: "household_items", model: generatedmodels.ModelPublicHouseholdItems{}},
|
||||
// {schema: "public", entity: "household_vendors", model: generatedmodels.ModelPublicHouseholdVendors{}},
|
||||
// {schema: "public", entity: "important_dates", model: generatedmodels.ModelPublicImportantDates{}},
|
||||
{schema: "public", entity: "learnings", model: generatedmodels.ModelPublicLearnings{}},
|
||||
{schema: "public", entity: "maintenance_logs", model: generatedmodels.ModelPublicMaintenanceLogs{}},
|
||||
{schema: "public", entity: "maintenance_tasks", model: generatedmodels.ModelPublicMaintenanceTasks{}},
|
||||
{schema: "public", entity: "meal_plans", model: generatedmodels.ModelPublicMealPlans{}},
|
||||
{schema: "public", entity: "opportunities", model: generatedmodels.ModelPublicOpportunities{}},
|
||||
// {schema: "public", entity: "maintenance_logs", model: generatedmodels.ModelPublicMaintenanceLogs{}},
|
||||
// {schema: "public", entity: "maintenance_tasks", model: generatedmodels.ModelPublicMaintenanceTasks{}},
|
||||
// {schema: "public", entity: "meal_plans", model: generatedmodels.ModelPublicMealPlans{}},
|
||||
// {schema: "public", entity: "opportunities", model: generatedmodels.ModelPublicOpportunities{}},
|
||||
{schema: "public", entity: "plan_dependencies", model: generatedmodels.ModelPublicPlanDependencies{}},
|
||||
{schema: "public", entity: "plan_guardrails", model: generatedmodels.ModelPublicPlanGuardrails{}},
|
||||
{schema: "public", entity: "plan_related_plans", model: generatedmodels.ModelPublicPlanRelatedPlans{}},
|
||||
{schema: "public", entity: "plan_skills", model: generatedmodels.ModelPublicPlanSkills{}},
|
||||
{schema: "public", entity: "plans", model: generatedmodels.ModelPublicPlans{}},
|
||||
{schema: "public", entity: "professional_contacts", model: generatedmodels.ModelPublicProfessionalContacts{}},
|
||||
// {schema: "public", entity: "professional_contacts", model: generatedmodels.ModelPublicProfessionalContacts{}},
|
||||
{schema: "public", entity: "project_guardrails", model: generatedmodels.ModelPublicProjectGuardrails{}},
|
||||
{schema: "public", entity: "project_skills", model: generatedmodels.ModelPublicProjectSkills{}},
|
||||
{schema: "public", entity: "projects", model: generatedmodels.ModelPublicProjects{}},
|
||||
{schema: "public", entity: "recipes", model: generatedmodels.ModelPublicRecipes{}},
|
||||
{schema: "public", entity: "shopping_lists", model: generatedmodels.ModelPublicShoppingLists{}},
|
||||
// {schema: "public", entity: "recipes", model: generatedmodels.ModelPublicRecipes{}},
|
||||
// {schema: "public", entity: "shopping_lists", model: generatedmodels.ModelPublicShoppingLists{}},
|
||||
{schema: "public", entity: "stored_files", model: generatedmodels.ModelPublicStoredFiles{}},
|
||||
{schema: "public", entity: "thought_links", model: generatedmodels.ModelPublicThoughtLinks{}},
|
||||
{schema: "public", entity: "thoughts", model: generatedmodels.ModelPublicThoughts{}},
|
||||
|
||||
@@ -63,10 +63,25 @@ func TestResolveSpecGuardAllowsSupportedMutations(t *testing.T) {
|
||||
}{
|
||||
{name: "learnings read", entity: "learnings", operation: "read"},
|
||||
{name: "projects create", entity: "projects", operation: "create"},
|
||||
{name: "projects update", entity: "projects", operation: "update"},
|
||||
{name: "projects delete", entity: "projects", operation: "delete"},
|
||||
{name: "plans create", entity: "plans", operation: "create"},
|
||||
{name: "plans update", entity: "plans", operation: "update"},
|
||||
{name: "plans delete", entity: "plans", operation: "delete"},
|
||||
{name: "learnings create", entity: "learnings", operation: "create"},
|
||||
{name: "learnings update", entity: "learnings", operation: "update"},
|
||||
{name: "learnings delete", entity: "learnings", operation: "delete"},
|
||||
{name: "thoughts create", entity: "thoughts", operation: "create"},
|
||||
{name: "thoughts update", entity: "thoughts", operation: "update"},
|
||||
{name: "thoughts delete", entity: "thoughts", operation: "delete"},
|
||||
{name: "agent_skills create", entity: "agent_skills", operation: "create"},
|
||||
{name: "agent_skills update", entity: "agent_skills", operation: "update"},
|
||||
{name: "agent_skills delete", entity: "agent_skills", operation: "delete"},
|
||||
{name: "agent_guardrails create", entity: "agent_guardrails", operation: "create"},
|
||||
{name: "agent_guardrails update", entity: "agent_guardrails", operation: "update"},
|
||||
{name: "agent_guardrails delete", entity: "agent_guardrails", operation: "delete"},
|
||||
{name: "stored_files update", entity: "stored_files", operation: "update"},
|
||||
{name: "stored_files delete", entity: "stored_files", operation: "delete"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
@@ -100,32 +115,18 @@ func TestResolveSpecGuardBlocksUnsupportedMutations(t *testing.T) {
|
||||
wantMessageIn string
|
||||
}{
|
||||
{
|
||||
name: "create not allowed on thoughts",
|
||||
entity: "thoughts",
|
||||
name: "mutations blocked for non-allowlisted operation",
|
||||
entity: "stored_files",
|
||||
operation: "create",
|
||||
wantCode: http.StatusForbidden,
|
||||
wantMessageIn: `operation "create" is not allowed for public.thoughts`,
|
||||
},
|
||||
{
|
||||
name: "delete not allowed on projects",
|
||||
entity: "projects",
|
||||
operation: "delete",
|
||||
wantCode: http.StatusForbidden,
|
||||
wantMessageIn: `operation "delete" is not allowed for public.projects`,
|
||||
wantMessageIn: `operation "create" is not allowed for public.stored_files`,
|
||||
},
|
||||
{
|
||||
name: "mutations blocked for non-allowlisted entity",
|
||||
entity: "stored_files",
|
||||
entity: "maintenance_logs",
|
||||
operation: "delete",
|
||||
wantCode: http.StatusForbidden,
|
||||
wantMessageIn: `operation "delete" is not allowed for public.stored_files`,
|
||||
},
|
||||
{
|
||||
name: "mutations blocked for learnings",
|
||||
entity: "learnings",
|
||||
operation: "delete",
|
||||
wantCode: http.StatusForbidden,
|
||||
wantMessageIn: `operation "delete" is not allowed for public.learnings`,
|
||||
wantMessageIn: `operation "delete" is not allowed for public.maintenance_logs`,
|
||||
},
|
||||
{
|
||||
name: "unknown operation is rejected",
|
||||
|
||||
Reference in New Issue
Block a user