SuperCharge Claude Code v1.0.0 - Complete Customization Package
Features: - 30+ Custom Skills (cognitive, development, UI/UX, autonomous agents) - RalphLoop autonomous agent integration - Multi-AI consultation (Qwen) - Agent management system with sync capabilities - Custom hooks for session management - MCP servers integration - Plugin marketplace setup - Comprehensive installation script Components: - Skills: always-use-superpowers, ralph, brainstorming, ui-ux-pro-max, etc. - Agents: 100+ agents across engineering, marketing, product, etc. - Hooks: session-start-superpowers, qwen-consult, ralph-auto-trigger - Commands: /brainstorm, /write-plan, /execute-plan - MCP Servers: zai-mcp-server, web-search-prime, web-reader, zread - Binaries: ralphloop wrapper Installation: ./supercharge.sh
This commit is contained in:
91
plugins/examples/knowledge-base/commands/search.ts
Normal file
91
plugins/examples/knowledge-base/commands/search.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Knowledge Search Command
|
||||
* Search your knowledge base with semantic understanding
|
||||
*/
|
||||
|
||||
import { readFileSync, existsSync } from 'fs'
|
||||
import { join } from 'path'
|
||||
import { homedir } from 'os'
|
||||
|
||||
export interface SearchOptions {
|
||||
query: string
|
||||
category?: string
|
||||
tags?: string[]
|
||||
limit?: number
|
||||
}
|
||||
|
||||
const KNOWLEDGE_FILE = join(homedir(), '.claude', 'knowledge', 'knowledge.json')
|
||||
|
||||
interface KnowledgeEntry {
|
||||
id: string
|
||||
title?: string
|
||||
content: string
|
||||
tags: string[]
|
||||
category: string
|
||||
source?: string
|
||||
timestamp: string
|
||||
}
|
||||
|
||||
export async function handle(args: SearchOptions, context: any): Promise<string> {
|
||||
const { query, category, tags, limit = 10 } = args
|
||||
|
||||
try {
|
||||
if (!existsSync(KNOWLEDGE_FILE)) {
|
||||
return 'Knowledge base is empty. Add some knowledge first!'
|
||||
}
|
||||
|
||||
const data = readFileSync(KNOWLEDGE_FILE, 'utf-8')
|
||||
const knowledge: KnowledgeEntry[] = JSON.parse(data)
|
||||
|
||||
// Filter knowledge
|
||||
let results = knowledge
|
||||
|
||||
if (category) {
|
||||
results = results.filter(entry => entry.category === category)
|
||||
}
|
||||
|
||||
if (tags && tags.length > 0) {
|
||||
results = results.filter(entry =>
|
||||
tags.some(tag => entry.tags.includes(tag))
|
||||
)
|
||||
}
|
||||
|
||||
// Text search (simple implementation)
|
||||
if (query) {
|
||||
const queryLower = query.toLowerCase()
|
||||
results = results.filter(entry =>
|
||||
entry.content.toLowerCase().includes(queryLower) ||
|
||||
(entry.title && entry.title.toLowerCase().includes(queryLower)) ||
|
||||
entry.tags.some(tag => tag.toLowerCase().includes(queryLower))
|
||||
)
|
||||
}
|
||||
|
||||
// Limit results
|
||||
results = results.slice(0, limit)
|
||||
|
||||
if (results.length === 0) {
|
||||
return `No results found for query: "${query}"`
|
||||
}
|
||||
|
||||
// Format results
|
||||
const formatted = results.map(entry => {
|
||||
const lines = [
|
||||
`ID: ${entry.id}`,
|
||||
entry.title ? `Title: ${entry.title}` : null,
|
||||
`Category: ${entry.category}`,
|
||||
`Tags: ${entry.tags.join(', ') || 'none'}`,
|
||||
`Date: ${new Date(entry.timestamp).toLocaleDateString()}`,
|
||||
'',
|
||||
entry.content.slice(0, 200) + (entry.content.length > 200 ? '...' : ''),
|
||||
''
|
||||
]
|
||||
return lines.filter(Boolean).join('\n')
|
||||
})
|
||||
|
||||
return `Found ${results.length} result(s):\n\n${formatted.join('\n---\n\n')}`
|
||||
} catch (error: any) {
|
||||
throw new Error(`Failed to search knowledge: ${error.message}`)
|
||||
}
|
||||
}
|
||||
|
||||
export default { handle }
|
||||
Reference in New Issue
Block a user