chore: remove deprecated files and configurations

- Deleted .gitignore, biome.json, next.config.ts, package.json, pnpm-lock.yaml, pnpm-workspace.yaml, postcss.config.mjs, README.md, and various API, component, and utility files to clean up the codebase.
- Removed unused database files and migration scripts to streamline the project structure.
- Eliminated obsolete hooks and services to enhance maintainability and reduce clutter.
This commit is contained in:
Evandro Fonseca Junior committed 2025-11-18 21:43:11 -03:00
1 parent a8bb7cc22d
commit ad9d5d32d2
119 files changed
-17633

No files matched your search

-28
View File
@@ -1,28 +0,0 @@
"use client";
import { useCallback, useEffect, useState } from "react";
export type CopyMode = "markdown" | "text";
const KEY = "ollahub-copy-mode";
export function useCopyPrefs() {
const [copyMode, setCopyModeState] = useState<CopyMode>("markdown");
useEffect(() => {
if (typeof window === "undefined") return;
const saved = localStorage.getItem(KEY) as CopyMode | null;
if (saved === "markdown" || saved === "text") {
setCopyModeState(saved);
}
}, []);
const setCopyMode = useCallback((mode: CopyMode) => {
setCopyModeState(mode);
if (typeof window !== "undefined") {
localStorage.setItem(KEY, mode);
}
}, []);
return { copyMode, setCopyMode };
}
-192
View File
@@ -1,192 +0,0 @@
"use client";
import { useState, useEffect, useCallback } from "react";
import { MCPProvider, MCPSearchParams } from "@/lib/types/mcp";
export function useMCPMarketplace() {
const [mcps, setMcps] = useState<MCPProvider[]>([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const [selectedCategory, setSelectedCategory] = useState("all");
const [searchTerm, setSearchTerm] = useState("");
const [sortBy, setSortBy] = useState<MCPSearchParams["sort"]>("rating");
const [sortOrder, setSortOrder] = useState<"asc" | "desc">("desc");
const [selectedMCP, setSelectedMCP] = useState<MCPProvider | null>(null);
const [showDetailModal, setShowDetailModal] = useState(false);
const fetchMCPs = useCallback(
async (params?: Partial<MCPSearchParams>) => {
setLoading(true);
setError(null);
try {
const searchParams = new URLSearchParams();
const category = params?.category || selectedCategory;
const search = params?.search || searchTerm;
const sort = params?.sort || sortBy;
const order = params?.order || sortOrder;
if (category && category !== "all") {
searchParams.append("category", category);
}
if (search) {
searchParams.append("search", search);
}
if (sort) {
searchParams.append("sort", sort);
}
if (order) {
searchParams.append("order", order);
}
searchParams.append("limit", "2000"); // Aumentado para 2000
const response = await fetch(`/api/mcp/list?${searchParams}`);
const data = await response.json();
if (data.success) {
setMcps(data.mcps);
} else {
setError(data.error || "Failed to fetch MCPs");
}
} catch (err) {
setError(err instanceof Error ? err.message : "Failed to fetch MCPs");
} finally {
setLoading(false);
}
},
[selectedCategory, searchTerm, sortBy, sortOrder]
);
const installMCP = useCallback(async (mcpId: string) => {
try {
const response = await fetch("/api/mcp/install", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ mcpId }),
});
const data = await response.json();
if (data.success) {
// Atualizar estado local
setMcps((prev) =>
prev.map((mcp) =>
mcp.id === mcpId ? { ...mcp, installed: true } : mcp
)
);
return { success: true, message: data.installation.message };
} else {
return { success: false, message: data.error };
}
} catch (err) {
return {
success: false,
message: err instanceof Error ? err.message : "Failed to install MCP",
};
}
}, []);
const uninstallMCP = useCallback(async (mcpId: string) => {
try {
const response = await fetch("/api/mcp/uninstall", {
method: "DELETE",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ mcpId }),
});
const data = await response.json();
if (data.success) {
// Atualizar estado local
setMcps((prev) =>
prev.map((mcp) =>
mcp.id === mcpId ? { ...mcp, installed: false } : mcp
)
);
return { success: true, message: data.installation.message };
} else {
return { success: false, message: data.error };
}
} catch (err) {
return {
success: false,
message: err instanceof Error ? err.message : "Failed to uninstall MCP",
};
}
}, []);
const viewMCPDetails = useCallback((mcp: MCPProvider) => {
setSelectedMCP(mcp);
setShowDetailModal(true);
}, []);
const closeDetailModal = useCallback(() => {
setShowDetailModal(false);
setSelectedMCP(null);
}, []);
const handleSearch = useCallback(
(search: string) => {
setSearchTerm(search);
fetchMCPs({ search });
},
[fetchMCPs]
);
const handleCategoryChange = useCallback(
(category: string) => {
setSelectedCategory(category);
fetchMCPs({ category });
},
[fetchMCPs]
);
const handleSortChange = useCallback(
(sort: MCPSearchParams["sort"]) => {
setSortBy(sort);
fetchMCPs({ sort });
},
[fetchMCPs]
);
const handleOrderChange = useCallback(
(order: "asc" | "desc") => {
setSortOrder(order);
fetchMCPs({ order });
},
[fetchMCPs]
);
// Carregar MCPs na inicialização
useEffect(() => {
fetchMCPs();
}, []);
return {
// Estado
mcps,
loading,
error,
selectedCategory,
searchTerm,
sortBy,
sortOrder,
selectedMCP,
showDetailModal,
// Ações
fetchMCPs,
installMCP,
uninstallMCP,
viewMCPDetails,
closeDetailModal,
handleSearch,
handleCategoryChange,
handleSortChange,
handleOrderChange,
// Setters diretos
setSearchTerm,
setSortBy,
setSortOrder,
};
}
-27
View File
@@ -1,27 +0,0 @@
export function extractCodeBlocks(
text: string
): Array<{ language: string; code: string }> {
const regex = /```(\w+)?\n([\s\S]*?)```/g;
const blocks: Array<{ language: string; code: string }> = [];
let match: RegExpExecArray | null;
while ((match = regex.exec(text)) !== null) {
const language = match[1] || "text";
const code = match[2]?.trimEnd() || "";
blocks.push({ language, code });
}
return blocks;
}
export function stripMarkdown(md: string): string {
// Remove code blocks first
let plain = md.replace(/```[\s\S]*?```/g, (block) =>
block.replace(/```[\s\S]*?\n/, "").replace(/```$/, "")
);
// Remove inline code
plain = plain.replace(/`([^`]+)`/g, "$1");
// Remove common markdown syntax
plain = plain
.replace(/(^|\s)[#>*_~`-]+/g, " ")
.replace(/\[(.*?)\]\((.*?)\)/g, "$1");
return plain;
}
-79
View File
@@ -1,79 +0,0 @@
"use client";
import { useCallback, useEffect, useState } from "react";
export type DevicePref = "auto" | "cpu" | "gpu";
type Prefs = {
selectedModel: string | null; // NOVO
systemPrompt: string;
device: DevicePref;
gpuIndex: number;
numGpu: number;
// Preferências de design
chatLayout?: "compact" | "edge"; // compact = centralizado com max-width; edge = até as bordas
bubbleSize?: "sm" | "md" | "lg"; // tamanhos de bolha
};
const defaultPrefs: Prefs = {
selectedModel: null, // NOVO
systemPrompt: "",
device: "auto",
gpuIndex: 0,
numGpu: 1,
chatLayout: "compact",
bubbleSize: "md",
};
export function useUserPrefs() {
const [prefs, setPrefs] = useState<Prefs>(defaultPrefs);
const [ready, setReady] = useState(false);
// Carregar do Redis
useEffect(() => {
fetch("/api/preferences")
.then((res) => res.json())
.then((data) => {
setPrefs(data);
setReady(true);
})
.catch((err) => {
console.error("Erro ao carregar preferências:", err);
setReady(true);
});
}, []);
// Salvar no Redis
const update = useCallback((next: Partial<Prefs>) => {
setPrefs((prev) => {
const merged: Prefs = { ...prev, ...next };
// Salvar no Redis
fetch("/api/preferences", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(merged),
}).catch((err) =>
console.error("Erro ao salvar preferências:", err)
);
return merged;
});
}, []);
return { prefs, ready, update };
}
export function buildOllamaOptions(
device: DevicePref,
numGpu: number,
gpuIndex: number
) {
if (device === "auto") return undefined;
if (device === "cpu") return { num_gpu: 0 } as const;
// gpu
return {
num_gpu: Math.max(1, numGpu),
main_gpu: Math.max(0, gpuIndex),
} as const;
}