From 17002345c9abba691c714cba04f2fa1bdc0e6d85 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 22 Dec 2025 10:25:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E9=92=A9=E5=AD=90?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9F=BA=E4=BA=8E=E5=94=AF=E4=B8=80=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E5=91=BD=E4=BB=A4=E5=8C=B9=E9=85=8D=EF=BC=9B?= =?UTF-8?q?=E5=9C=A8=E6=90=9C=E7=B4=A2=E5=85=83=E6=95=B0=E6=8D=AE=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9B=9E=E9=80=80=E6=A8=A1=E5=BC=8F=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard-js/components/hook-manager.js | 10 ++++---- .../dashboard-js/views/hook-manager.js | 25 +++++++++++++++---- ccw/src/tools/smart-search.ts | 1 + 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ccw/src/templates/dashboard-js/components/hook-manager.js b/ccw/src/templates/dashboard-js/components/hook-manager.js index 8c2b32b9..8ec28cd2 100644 --- a/ccw/src/templates/dashboard-js/components/hook-manager.js +++ b/ccw/src/templates/dashboard-js/components/hook-manager.js @@ -138,14 +138,14 @@ const HOOK_TEMPLATES = { category: 'memory', timeout: 5000 }, - // Session Context - Fires once per session at startup - // Uses state file to detect first prompt, only fires once + // Session Context - Progressive disclosure based on session state + // First prompt: returns cluster overview, subsequent: intent-matched sessions 'session-context': { event: 'UserPromptSubmit', matcher: '', - command: 'bash', - args: ['-c', 'STATE_FILE="/tmp/.ccw-session-$CLAUDE_SESSION_ID"; [ -f "$STATE_FILE" ] && exit 0; touch "$STATE_FILE"; curl -s -X POST -H "Content-Type: application/json" -d "{\\"sessionId\\":\\"$CLAUDE_SESSION_ID\\"}" http://localhost:3456/api/hook/session-context 2>/dev/null | jq -r ".content // empty"'], - description: 'Load session context once at startup (cluster overview)', + command: 'ccw', + args: ['hook', 'session-context', '--stdin'], + description: 'Progressive session context (cluster overview → intent matching)', category: 'context', timeout: 5000 } diff --git a/ccw/src/templates/dashboard-js/views/hook-manager.js b/ccw/src/templates/dashboard-js/views/hook-manager.js index 35125376..45da359e 100644 --- a/ccw/src/templates/dashboard-js/views/hook-manager.js +++ b/ccw/src/templates/dashboard-js/views/hook-manager.js @@ -449,8 +449,23 @@ function isHookTemplateInstalled(templateId) { const template = HOOK_TEMPLATES[templateId]; if (!template) return false; - // Build expected command string - const templateCmd = template.command + (template.args ? ' ' + template.args.join(' ') : ''); + // Define unique patterns for each template type (more specific than just command) + const uniquePatterns = { + 'session-context': 'hook session-context', + 'codexlens-update': 'codexlens update', + 'ccw-notify': 'api/hook', + 'log-tool': 'tool-usage.log', + 'lint-check': 'eslint', + 'git-add': 'git add', + 'memory-file-read': 'memory track --type file --action read', + 'memory-file-write': 'memory track --type file --action write', + 'memory-prompt-track': 'memory track --type topic', + 'skill-context-auto': 'skill-context-auto' + }; + + // Use unique pattern if defined, otherwise fall back to command + args + const searchPattern = uniquePatterns[templateId] || + (template.command + (template.args ? ' ' + template.args.join(' ') : '')); // Check project hooks const projectHooks = hookConfig.project?.hooks?.[template.event]; @@ -459,7 +474,7 @@ function isHookTemplateInstalled(templateId) { if (hookList.some(h => { // Check both old format (h.command) and new format (h.hooks[0].command) const cmd = h.hooks?.[0]?.command || h.command || ''; - return cmd.includes(template.command); + return cmd.includes(searchPattern); })) return true; } @@ -469,7 +484,7 @@ function isHookTemplateInstalled(templateId) { const hookList = Array.isArray(globalHooks) ? globalHooks : [globalHooks]; if (hookList.some(h => { const cmd = h.hooks?.[0]?.command || h.command || ''; - return cmd.includes(template.command); + return cmd.includes(searchPattern); })) return true; } @@ -512,7 +527,7 @@ async function uninstallHookTemplate(templateId) { // Define unique patterns for each template type const uniquePatterns = { - 'session-context': 'api/hook/session-context', + 'session-context': 'hook session-context', 'codexlens-update': 'codexlens update', 'ccw-notify': 'api/hook', 'log-tool': 'tool-usage.log', diff --git a/ccw/src/tools/smart-search.ts b/ccw/src/tools/smart-search.ts index 4841a9bb..931ee25e 100644 --- a/ccw/src/tools/smart-search.ts +++ b/ccw/src/tools/smart-search.ts @@ -244,6 +244,7 @@ interface SearchMetadata { warning?: string; note?: string; index_status?: 'indexed' | 'not_indexed' | 'partial'; + fallback?: string; // Fallback mode used (e.g., 'fuzzy') fallback_history?: string[]; suggested_weights?: Record; // Tokenization metadata (ripgrep mode)