Replace search skill with mem-search (#91)
* feat: add mem-search skill with progressive disclosure architecture Add comprehensive mem-search skill for accessing claude-mem's persistent cross-session memory database. Implements progressive disclosure workflow and token-efficient search patterns. Features: - 12 search operations (observations, sessions, prompts, by-type, by-concept, by-file, timelines, etc.) - Progressive disclosure principles to minimize token usage - Anti-patterns documentation to guide LLM behavior - HTTP API integration for all search functionality - Common workflows with composition examples Structure: - SKILL.md: Entry point with temporal trigger patterns - principles/: Progressive disclosure + anti-patterns - operations/: 12 search operation files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add CHANGELOG entry for mem-search skill Document mem-search skill addition in Unreleased section with: - 100% effectiveness compliance metrics - Comparison to previous search skill implementation - Progressive disclosure architecture details - Reference to audit report documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * docs: add mem-search skill audit report Add comprehensive audit report validating mem-search skill against Anthropic's official skill-creator documentation. Report includes: - Effectiveness metrics comparison (search vs mem-search) - Critical issues analysis for production readiness - Compliance validation across 6 key dimensions - Reference implementation guidance Result: mem-search achieves 100% compliance vs search's 67% 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Add comprehensive search architecture analysis document - Document current state of dual search architectures (HTTP API and MCP) - Analyze HTTP endpoints and MCP search server architectures - Identify DRY violations across search implementations - Evaluate the use of curl as the optimal approach for search - Provide architectural recommendations for immediate and long-term improvements - Outline action plan for cleanup, feature parity, DRY refactoring * refactor: Remove deprecated search skill documentation and operations * refactor: Reorganize documentation into public and context directories Changes: - Created docs/public/ for Mintlify documentation (.mdx files) - Created docs/context/ for internal planning and implementation docs - Moved all .mdx files and assets to docs/public/ - Moved all internal .md files to docs/context/ - Added CLAUDE.md to both directories explaining their purpose - Updated docs.json paths to work with new structure Benefits: - Clear separation between user-facing and internal documentation - Easier to maintain Mintlify docs in dedicated directory - Internal context files organized separately 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Enhance session management and continuity in hooks - Updated new-hook.ts to clarify session_id threading and idempotent session creation. - Modified prompts.ts to require claudeSessionId for continuation prompts, ensuring session context is maintained. - Improved SessionStore.ts documentation on createSDKSession to emphasize idempotent behavior and session connection. - Refined SDKAgent.ts to detail continuation prompt logic and its reliance on session.claudeSessionId for unified session handling. --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Alex Newman <thedotmack@gmail.com>
This commit is contained in:
+35
-3
@@ -1,6 +1,36 @@
|
||||
/**
|
||||
* New Hook - UserPromptSubmit
|
||||
* Consolidated entry point + logic
|
||||
*
|
||||
* DUAL PURPOSE HOOK: Handles BOTH session initialization AND continuation
|
||||
* ==========================================================================
|
||||
*
|
||||
* CRITICAL ARCHITECTURE FACTS (NEVER FORGET):
|
||||
*
|
||||
* 1. SESSION ID THREADING - The Single Source of Truth
|
||||
* - Claude Code assigns ONE session_id per conversation
|
||||
* - ALL hooks in that conversation receive the SAME session_id
|
||||
* - We ALWAYS use this session_id - NEVER generate our own
|
||||
* - This is how NEW hook, SAVE hook, and SUMMARY hook stay connected
|
||||
*
|
||||
* 2. NO EXISTENCE CHECKS NEEDED
|
||||
* - createSDKSession is idempotent (INSERT OR IGNORE)
|
||||
* - Prompt #1: Creates new database row, returns new ID
|
||||
* - Prompt #2+: Row exists, returns existing ID
|
||||
* - We NEVER need to check "does session exist?" - just use the session_id
|
||||
*
|
||||
* 3. CONTINUATION LOGIC LOCATION
|
||||
* - This hook does NOT contain continuation prompt logic
|
||||
* - That lives in SDKAgent.ts (lines 125-127)
|
||||
* - SDKAgent checks promptNumber to choose init vs continuation prompt
|
||||
* - BOTH prompts receive the SAME session_id from this hook
|
||||
*
|
||||
* 4. UNIFIED WITH SAVE HOOK
|
||||
* - SAVE hook uses: db.createSDKSession(session_id, '', '')
|
||||
* - NEW hook uses: db.createSDKSession(session_id, project, prompt)
|
||||
* - Both use session_id from hook context - this keeps everything connected
|
||||
*
|
||||
* This is KISS in action: Use the session_id we're given, trust idempotent
|
||||
* database operations, and let SDKAgent handle init vs continuation logic.
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
@@ -32,7 +62,9 @@ async function newHook(input?: UserPromptSubmitInput): Promise<void> {
|
||||
|
||||
const db = new SessionStore();
|
||||
|
||||
// Save session_id for indexing
|
||||
// CRITICAL: Use session_id from hook as THE source of truth
|
||||
// createSDKSession is idempotent - creates new or returns existing
|
||||
// This is how ALL hooks stay connected to the same session
|
||||
const sessionDbId = db.createSDKSession(session_id, project, prompt);
|
||||
const promptNumber = db.incrementPromptCounter(sessionDbId);
|
||||
|
||||
@@ -50,7 +82,7 @@ async function newHook(input?: UserPromptSubmitInput): Promise<void> {
|
||||
const response = await fetch(`http://127.0.0.1:${port}/sessions/${sessionDbId}/init`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ project, userPrompt: prompt }),
|
||||
body: JSON.stringify({ project, userPrompt: prompt, promptNumber }),
|
||||
signal: AbortSignal.timeout(5000)
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user