bluera-knowledge 0.33.2 → 0.34.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.claude-plugin/settings.json +1 -3
- package/CHANGELOG.md +34 -0
- package/dist/{chunk-OMXQBWCR.js → chunk-TD3VX74F.js} +2 -2
- package/dist/{chunk-OPLZTNKK.js → chunk-V5MWZM5X.js} +10 -6
- package/dist/chunk-V5MWZM5X.js.map +1 -0
- package/dist/{chunk-SROFPHRA.js → chunk-VELBEZVB.js} +78 -11
- package/dist/chunk-VELBEZVB.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/mcp/bootstrap.js +6 -2
- package/dist/mcp/bootstrap.js.map +1 -1
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/hooks/hooks.json +0 -27
- package/package.json +1 -1
- package/skills/knowledge-search/SKILL.md +1 -1
- package/dist/chunk-OPLZTNKK.js.map +0 -1
- package/dist/chunk-SROFPHRA.js.map +0 -1
- /package/dist/{chunk-OMXQBWCR.js.map → chunk-TD3VX74F.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
ZilAdapter,
|
|
4
4
|
runMCPServer,
|
|
5
5
|
spawnBackgroundWorker
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-V5MWZM5X.js";
|
|
7
7
|
import {
|
|
8
8
|
IntelligentCrawler,
|
|
9
9
|
getCrawlStrategy
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TD3VX74F.js";
|
|
11
11
|
import {
|
|
12
12
|
ASTParser,
|
|
13
13
|
AdapterRegistry,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isRepoStoreDefinition,
|
|
26
26
|
isWebStoreDefinition,
|
|
27
27
|
ok
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-VELBEZVB.js";
|
|
29
29
|
import {
|
|
30
30
|
createDocumentId
|
|
31
31
|
} from "./chunk-CLIMKLTW.js";
|
package/dist/mcp/bootstrap.js
CHANGED
|
@@ -14,7 +14,11 @@ import {
|
|
|
14
14
|
import { homedir } from "os";
|
|
15
15
|
import { dirname, join } from "path";
|
|
16
16
|
import { fileURLToPath } from "url";
|
|
17
|
-
|
|
17
|
+
function expandShellVars(value) {
|
|
18
|
+
return value.replace(/\$\{(\w+)\}/g, (match, name) => process.env[name] ?? match);
|
|
19
|
+
}
|
|
20
|
+
var rawProjectRoot = process.env["PROJECT_ROOT"];
|
|
21
|
+
var envProjectRoot = rawProjectRoot !== void 0 && rawProjectRoot !== "" ? expandShellVars(rawProjectRoot) : void 0;
|
|
18
22
|
var logDir = envProjectRoot !== void 0 && envProjectRoot !== "" ? join(envProjectRoot, ".bluera", "bluera-knowledge", "logs") : join(homedir(), ".bluera", "bluera-knowledge", "logs");
|
|
19
23
|
var logFile = join(logDir, "app.log");
|
|
20
24
|
var log = (level, msg, data) => {
|
|
@@ -147,7 +151,7 @@ log("info", "Loading server module");
|
|
|
147
151
|
var importStart = Date.now();
|
|
148
152
|
var { runMCPServer } = await import("./server.js");
|
|
149
153
|
log("debug", "Server module loaded", { elapsedMs: Date.now() - importStart });
|
|
150
|
-
var projectRoot = process.env["PROJECT_ROOT"];
|
|
154
|
+
var projectRoot = process.env["PROJECT_ROOT"] !== void 0 ? expandShellVars(process.env["PROJECT_ROOT"]) : void 0;
|
|
151
155
|
if (projectRoot === void 0) {
|
|
152
156
|
throw new Error("PROJECT_ROOT environment variable is required");
|
|
153
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/bootstrap.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * MCP Server Bootstrap - installs dependencies before starting server.\n *\n * Uses only Node.js built-ins (no external dependencies required).\n * Self-locates plugin root via import.meta.url (doesn't rely on CLAUDE_PLUGIN_ROOT).\n *\n * Dependency installation strategy:\n * 1. Fast path: node_modules already exists → skip\n * 2. Package manager: Run bun install or npm install\n *\n * IMPORTANT: MCP servers must NOT log to stderr - Claude Code treats stderr output\n * as an error and may mark the MCP server as failed. All logging goes to file.\n */\nimport { execSync } from 'node:child_process';\nimport {\n appendFileSync,\n existsSync,\n mkdirSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Logging helper - writes to file since MCP servers must NOT use stderr\n// (Claude Code treats stderr as error and may fail the server)\n// JSON format matches pino output for consistency\n// Use PROJECT_ROOT if available (set by Claude Code), else fall back to home dir\nconst envProjectRoot = process.env['PROJECT_ROOT'];\nconst logDir =\n envProjectRoot !== undefined && envProjectRoot !== ''\n ? join(envProjectRoot, '.bluera', 'bluera-knowledge', 'logs')\n : join(homedir(), '.bluera', 'bluera-knowledge', 'logs');\nconst logFile = join(logDir, 'app.log');\n\nconst log = (\n level: 'info' | 'error' | 'debug',\n msg: string,\n data?: Record<string, unknown>\n): void => {\n try {\n mkdirSync(logDir, { recursive: true });\n const entry = {\n time: new Date().toISOString(),\n level,\n module: 'bootstrap',\n msg,\n ...data,\n };\n appendFileSync(logFile, `${JSON.stringify(entry)}\\n`);\n } catch {\n // Silently fail - we cannot use stderr for MCP servers\n }\n};\n\n// Self-locate plugin root from this file's path\n// dist/mcp/bootstrap.js -> plugin root (two directories up)\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst pluginRoot = join(__dirname, '..', '..');\n\n// Lock file to detect interrupted installs\nconst installLockFile = join(pluginRoot, '.node_modules_installing');\n\n// Get version from package.json for logging\nconst getVersion = (): string => {\n try {\n const pkg: unknown = JSON.parse(readFileSync(join(pluginRoot, 'package.json'), 'utf-8'));\n if (\n typeof pkg === 'object' &&\n pkg !== null &&\n 'version' in pkg &&\n typeof pkg.version === 'string'\n ) {\n return `v${pkg.version}`;\n }\n return 'unknown';\n } catch {\n return 'unknown';\n }\n};\n\n/**\n * Check if build tools are available for native module compilation.\n * Logs error to file and throws if make is not found.\n */\nfunction checkBuildTools(): void {\n try {\n execSync('which make', { stdio: 'ignore' });\n log('debug', 'Build tools available (make found)');\n } catch {\n log('error', 'Build tools not found - make is required for native modules', {\n fix: 'Install build-essential (Debian/Ubuntu), Development Tools (Fedora), or Xcode CLI Tools (macOS)',\n });\n throw new Error(\n 'Build tools not found. Install: sudo apt install build-essential (Debian/Ubuntu), ' +\n 'sudo dnf groupinstall \"Development Tools\" (Fedora), or xcode-select --install (macOS)'\n );\n }\n}\n\n/**\n * Install dependencies using bun or npm.\n * Uses stdio: 'pipe' to capture output and avoid corrupting MCP stdio transport.\n */\nfunction installWithPackageManager(): void {\n const hasBun = ((): boolean => {\n try {\n execSync('which bun', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n })();\n\n // CRITICAL: npm needs peer-deps bypass flag (tree-sitter-go/rust have conflicting requirements)\n const cmd = hasBun ? 'bun install --frozen-lockfile' : 'npm install --legacy-peer-deps --silent';\n log('info', 'Installing dependencies with package manager', { hasBun, cmd });\n\n try {\n // Use stdio: 'pipe' to capture output - 'inherit' would corrupt MCP stdio transport\n // Skip browser downloads during install - browsers are installed separately by setup.sh\n const output = execSync(cmd, {\n cwd: pluginRoot,\n stdio: 'pipe',\n env: {\n ...process.env,\n PUPPETEER_SKIP_DOWNLOAD: '1',\n PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1',\n },\n });\n if (output.length > 0) {\n log('debug', 'Install output', { output: output.toString().trim() });\n }\n log('info', 'Dependencies installed via package manager');\n } catch (error) {\n // Log installation failure details before re-throwing\n // execSync throws an object with stdout/stderr buffers on failure\n const errorMessage = error instanceof Error ? error.message : String(error);\n const errorDetails: Record<string, unknown> = { message: errorMessage };\n\n if (typeof error === 'object' && error !== null) {\n if ('stdout' in error && Buffer.isBuffer(error.stdout)) {\n errorDetails['stdout'] = error.stdout.toString().trim();\n }\n if ('stderr' in error && Buffer.isBuffer(error.stderr)) {\n errorDetails['stderr'] = error.stderr.toString().trim();\n }\n }\n\n log('error', 'Dependency installation failed', errorDetails);\n throw error;\n }\n}\n\n/**\n * Ensure dependencies are available.\n * Uses a lock file to detect and recover from interrupted installs.\n */\nfunction ensureDependencies(): void {\n const startTime = Date.now();\n log('debug', 'ensureDependencies starting');\n\n const nodeModulesPath = join(pluginRoot, 'node_modules');\n\n // Check for interrupted install - lock file exists means previous install was killed\n log('debug', 'Checking for interrupted install lock file', { lockFile: installLockFile });\n if (existsSync(installLockFile)) {\n log('info', 'Detected interrupted install, cleaning up');\n rmSync(nodeModulesPath, { recursive: true, force: true });\n unlinkSync(installLockFile);\n log('debug', 'Cleanup complete');\n }\n\n // Fast path: already installed\n log('debug', 'Checking node_modules exists', { path: nodeModulesPath });\n if (existsSync(nodeModulesPath)) {\n log('info', 'Dependencies already installed', { elapsedMs: Date.now() - startTime });\n return;\n }\n\n // Verify package.json exists before attempting install\n const packageJsonPath = join(pluginRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n log('error', 'package.json not found in plugin root — plugin cache may be corrupt', {\n pluginRoot,\n fix: 'Reinstall: /plugin uninstall bluera-knowledge && /plugin install bluera-knowledge@bluera',\n });\n throw new Error(\n `package.json not found at ${pluginRoot}. ` +\n 'Plugin cache may be corrupt. ' +\n 'Fix: /plugin uninstall bluera-knowledge && /plugin install bluera-knowledge@bluera'\n );\n }\n\n // Check build tools before attempting install\n log('debug', 'Checking build tools before install');\n checkBuildTools();\n\n // Create lock file before install (left behind if install interrupted/fails)\n log('debug', 'Creating lock file before install');\n writeFileSync(installLockFile, new Date().toISOString());\n\n const installStart = Date.now();\n log('debug', 'Starting package manager install');\n installWithPackageManager();\n log('debug', 'Package manager install finished', { elapsedMs: Date.now() - installStart });\n\n // Remove lock file on success\n unlinkSync(installLockFile);\n log('debug', 'ensureDependencies complete', { totalElapsedMs: Date.now() - startTime });\n}\n\n// Main entry point\nconst bootstrapStartTime = Date.now();\nconst VERSION = getVersion();\nlog('info', 'Bootstrap starting', { pluginRoot, version: VERSION });\n\nlog('debug', 'Calling ensureDependencies');\nensureDependencies();\nlog('debug', 'ensureDependencies returned', { elapsedMs: Date.now() - bootstrapStartTime });\n\n// Now that dependencies are installed, import and run the server\n// Dynamic import required because @modelcontextprotocol/sdk wouldn't be available before install\nlog('info', 'Loading server module');\nconst importStart = Date.now();\nconst { runMCPServer } = await import('./server.js');\nlog('debug', 'Server module loaded', { elapsedMs: Date.now() - importStart });\n\nconst projectRoot = process.env['PROJECT_ROOT'];\nif (projectRoot === undefined) {\n throw new Error('PROJECT_ROOT environment variable is required');\n}\n\nlog('info', 'Starting MCP server', {\n projectRoot,\n dataDir: process.env['DATA_DIR'],\n});\n\nawait runMCPServer({\n dataDir: process.env['DATA_DIR'],\n config: process.env['CONFIG_PATH'],\n projectRoot,\n});\n"],"mappings":";;;AAcA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAM9B,IAAM,iBAAiB,QAAQ,IAAI,cAAc;AACjD,IAAM,SACJ,mBAAmB,UAAa,mBAAmB,KAC/C,KAAK,gBAAgB,WAAW,oBAAoB,MAAM,IAC1D,KAAK,QAAQ,GAAG,WAAW,oBAAoB,MAAM;AAC3D,IAAM,UAAU,KAAK,QAAQ,SAAS;AAEtC,IAAM,MAAM,CACV,OACA,KACA,SACS;AACT,MAAI;AACF,cAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;AACrC,UAAM,QAAQ;AAAA,MACZ,OAAM,oBAAI,KAAK,GAAE,YAAY;AAAA,MAC7B;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,MACA,GAAG;AAAA,IACL;AACA,mBAAe,SAAS,GAAG,KAAK,UAAU,KAAK,CAAC;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installs dependencies before starting server.\n *\n * Uses only Node.js built-ins (no external dependencies required).\n * Self-locates plugin root via import.meta.url (doesn't rely on CLAUDE_PLUGIN_ROOT).\n *\n * Dependency installation strategy:\n * 1. Fast path: node_modules already exists → skip\n * 2. Package manager: Run bun install or npm install\n *\n * IMPORTANT: MCP servers must NOT log to stderr - Claude Code treats stderr output\n * as an error and may mark the MCP server as failed. All logging goes to file.\n */\nimport { execSync } from 'node:child_process';\nimport {\n appendFileSync,\n existsSync,\n mkdirSync,\n readFileSync,\n rmSync,\n unlinkSync,\n writeFileSync,\n} from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\n// Expand shell variable references like ${PWD} that Claude Code doesn't expand\n// when passing env vars from .mcp.json to the MCP server process.\nfunction expandShellVars(value: string): string {\n return value.replace(/\\$\\{(\\w+)\\}/g, (match, name: string) => process.env[name] ?? match);\n}\n\n// Logging helper - writes to file since MCP servers must NOT use stderr\n// (Claude Code treats stderr as error and may fail the server)\n// JSON format matches pino output for consistency\n// Use PROJECT_ROOT if available (set by Claude Code), else fall back to home dir\nconst rawProjectRoot = process.env['PROJECT_ROOT'];\nconst envProjectRoot =\n rawProjectRoot !== undefined && rawProjectRoot !== ''\n ? expandShellVars(rawProjectRoot)\n : undefined;\nconst logDir =\n envProjectRoot !== undefined && envProjectRoot !== ''\n ? join(envProjectRoot, '.bluera', 'bluera-knowledge', 'logs')\n : join(homedir(), '.bluera', 'bluera-knowledge', 'logs');\nconst logFile = join(logDir, 'app.log');\n\nconst log = (\n level: 'info' | 'error' | 'debug',\n msg: string,\n data?: Record<string, unknown>\n): void => {\n try {\n mkdirSync(logDir, { recursive: true });\n const entry = {\n time: new Date().toISOString(),\n level,\n module: 'bootstrap',\n msg,\n ...data,\n };\n appendFileSync(logFile, `${JSON.stringify(entry)}\\n`);\n } catch {\n // Silently fail - we cannot use stderr for MCP servers\n }\n};\n\n// Self-locate plugin root from this file's path\n// dist/mcp/bootstrap.js -> plugin root (two directories up)\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\nconst pluginRoot = join(__dirname, '..', '..');\n\n// Lock file to detect interrupted installs\nconst installLockFile = join(pluginRoot, '.node_modules_installing');\n\n// Get version from package.json for logging\nconst getVersion = (): string => {\n try {\n const pkg: unknown = JSON.parse(readFileSync(join(pluginRoot, 'package.json'), 'utf-8'));\n if (\n typeof pkg === 'object' &&\n pkg !== null &&\n 'version' in pkg &&\n typeof pkg.version === 'string'\n ) {\n return `v${pkg.version}`;\n }\n return 'unknown';\n } catch {\n return 'unknown';\n }\n};\n\n/**\n * Check if build tools are available for native module compilation.\n * Logs error to file and throws if make is not found.\n */\nfunction checkBuildTools(): void {\n try {\n execSync('which make', { stdio: 'ignore' });\n log('debug', 'Build tools available (make found)');\n } catch {\n log('error', 'Build tools not found - make is required for native modules', {\n fix: 'Install build-essential (Debian/Ubuntu), Development Tools (Fedora), or Xcode CLI Tools (macOS)',\n });\n throw new Error(\n 'Build tools not found. Install: sudo apt install build-essential (Debian/Ubuntu), ' +\n 'sudo dnf groupinstall \"Development Tools\" (Fedora), or xcode-select --install (macOS)'\n );\n }\n}\n\n/**\n * Install dependencies using bun or npm.\n * Uses stdio: 'pipe' to capture output and avoid corrupting MCP stdio transport.\n */\nfunction installWithPackageManager(): void {\n const hasBun = ((): boolean => {\n try {\n execSync('which bun', { stdio: 'ignore' });\n return true;\n } catch {\n return false;\n }\n })();\n\n // CRITICAL: npm needs peer-deps bypass flag (tree-sitter-go/rust have conflicting requirements)\n const cmd = hasBun ? 'bun install --frozen-lockfile' : 'npm install --legacy-peer-deps --silent';\n log('info', 'Installing dependencies with package manager', { hasBun, cmd });\n\n try {\n // Use stdio: 'pipe' to capture output - 'inherit' would corrupt MCP stdio transport\n // Skip browser downloads during install - browsers are installed separately by setup.sh\n const output = execSync(cmd, {\n cwd: pluginRoot,\n stdio: 'pipe',\n env: {\n ...process.env,\n PUPPETEER_SKIP_DOWNLOAD: '1',\n PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1',\n },\n });\n if (output.length > 0) {\n log('debug', 'Install output', { output: output.toString().trim() });\n }\n log('info', 'Dependencies installed via package manager');\n } catch (error) {\n // Log installation failure details before re-throwing\n // execSync throws an object with stdout/stderr buffers on failure\n const errorMessage = error instanceof Error ? error.message : String(error);\n const errorDetails: Record<string, unknown> = { message: errorMessage };\n\n if (typeof error === 'object' && error !== null) {\n if ('stdout' in error && Buffer.isBuffer(error.stdout)) {\n errorDetails['stdout'] = error.stdout.toString().trim();\n }\n if ('stderr' in error && Buffer.isBuffer(error.stderr)) {\n errorDetails['stderr'] = error.stderr.toString().trim();\n }\n }\n\n log('error', 'Dependency installation failed', errorDetails);\n throw error;\n }\n}\n\n/**\n * Ensure dependencies are available.\n * Uses a lock file to detect and recover from interrupted installs.\n */\nfunction ensureDependencies(): void {\n const startTime = Date.now();\n log('debug', 'ensureDependencies starting');\n\n const nodeModulesPath = join(pluginRoot, 'node_modules');\n\n // Check for interrupted install - lock file exists means previous install was killed\n log('debug', 'Checking for interrupted install lock file', { lockFile: installLockFile });\n if (existsSync(installLockFile)) {\n log('info', 'Detected interrupted install, cleaning up');\n rmSync(nodeModulesPath, { recursive: true, force: true });\n unlinkSync(installLockFile);\n log('debug', 'Cleanup complete');\n }\n\n // Fast path: already installed\n log('debug', 'Checking node_modules exists', { path: nodeModulesPath });\n if (existsSync(nodeModulesPath)) {\n log('info', 'Dependencies already installed', { elapsedMs: Date.now() - startTime });\n return;\n }\n\n // Verify package.json exists before attempting install\n const packageJsonPath = join(pluginRoot, 'package.json');\n if (!existsSync(packageJsonPath)) {\n log('error', 'package.json not found in plugin root — plugin cache may be corrupt', {\n pluginRoot,\n fix: 'Reinstall: /plugin uninstall bluera-knowledge && /plugin install bluera-knowledge@bluera',\n });\n throw new Error(\n `package.json not found at ${pluginRoot}. ` +\n 'Plugin cache may be corrupt. ' +\n 'Fix: /plugin uninstall bluera-knowledge && /plugin install bluera-knowledge@bluera'\n );\n }\n\n // Check build tools before attempting install\n log('debug', 'Checking build tools before install');\n checkBuildTools();\n\n // Create lock file before install (left behind if install interrupted/fails)\n log('debug', 'Creating lock file before install');\n writeFileSync(installLockFile, new Date().toISOString());\n\n const installStart = Date.now();\n log('debug', 'Starting package manager install');\n installWithPackageManager();\n log('debug', 'Package manager install finished', { elapsedMs: Date.now() - installStart });\n\n // Remove lock file on success\n unlinkSync(installLockFile);\n log('debug', 'ensureDependencies complete', { totalElapsedMs: Date.now() - startTime });\n}\n\n// Main entry point\nconst bootstrapStartTime = Date.now();\nconst VERSION = getVersion();\nlog('info', 'Bootstrap starting', { pluginRoot, version: VERSION });\n\nlog('debug', 'Calling ensureDependencies');\nensureDependencies();\nlog('debug', 'ensureDependencies returned', { elapsedMs: Date.now() - bootstrapStartTime });\n\n// Now that dependencies are installed, import and run the server\n// Dynamic import required because @modelcontextprotocol/sdk wouldn't be available before install\nlog('info', 'Loading server module');\nconst importStart = Date.now();\nconst { runMCPServer } = await import('./server.js');\nlog('debug', 'Server module loaded', { elapsedMs: Date.now() - importStart });\n\nconst projectRoot =\n process.env['PROJECT_ROOT'] !== undefined\n ? expandShellVars(process.env['PROJECT_ROOT'])\n : undefined;\nif (projectRoot === undefined) {\n throw new Error('PROJECT_ROOT environment variable is required');\n}\n\nlog('info', 'Starting MCP server', {\n projectRoot,\n dataDir: process.env['DATA_DIR'],\n});\n\nawait runMCPServer({\n dataDir: process.env['DATA_DIR'],\n config: process.env['CONFIG_PATH'],\n projectRoot,\n});\n"],"mappings":";;;AAcA,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,eAAe;AACxB,SAAS,SAAS,YAAY;AAC9B,SAAS,qBAAqB;AAI9B,SAAS,gBAAgB,OAAuB;AAC9C,SAAO,MAAM,QAAQ,gBAAgB,CAAC,OAAO,SAAiB,QAA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F,IAAI,QAAQ,uBAAuB;AACnC,IAAM,cAAc,KAAK,IAAI;AAC7B,IAAM,EAAE,aAAa,IAAI,MAAM,OAAO,aAAa;AACnD,IAAI,SAAS,wBAAwB,EAAE,WAAW,KAAK,IAAI,IAAI,YAAY,CAAC;AAE5E,IAAM,cACJ,QAAQ,IAAI,cAAc,MAAM,SAC5B,gBAAgB,QAAQ,IAAI,cAAc,CAAC,IAC3C;AACN,IAAI,gBAAgB,QAAW;AAC7B,QAAM,IAAI,MAAM,+CAA+C;AACjE;AAEA,IAAI,QAAQ,uBAAuB;AAAA,EACjC;AAAA,EACA,SAAS,QAAQ,IAAI,UAAU;AACjC,CAAC;AAED,MAAM,aAAa;AAAA,EACjB,SAAS,QAAQ,IAAI,UAAU;AAAA,EAC/B,QAAQ,QAAQ,IAAI,aAAa;AAAA,EACjC;AACF,CAAC;","names":[]}
|
package/dist/mcp/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMCPServer,
|
|
3
3
|
runMCPServer
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-V5MWZM5X.js";
|
|
5
|
+
import "../chunk-VELBEZVB.js";
|
|
6
6
|
import "../chunk-CLIMKLTW.js";
|
|
7
7
|
import "../chunk-N3XYMAU3.js";
|
|
8
8
|
import "../chunk-DGUM43GV.js";
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
IntelligentCrawler
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-TD3VX74F.js";
|
|
5
5
|
import {
|
|
6
6
|
JobService,
|
|
7
7
|
createLogger,
|
|
8
8
|
createServices,
|
|
9
9
|
destroyServices,
|
|
10
10
|
shutdownLogger
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-VELBEZVB.js";
|
|
12
12
|
import {
|
|
13
13
|
createDocumentId,
|
|
14
14
|
createStoreId
|
package/hooks/hooks.json
CHANGED
|
@@ -22,18 +22,6 @@
|
|
|
22
22
|
]
|
|
23
23
|
}
|
|
24
24
|
],
|
|
25
|
-
"PreToolUse": [
|
|
26
|
-
{
|
|
27
|
-
"matcher": "Grep|Read",
|
|
28
|
-
"hooks": [
|
|
29
|
-
{
|
|
30
|
-
"type": "command",
|
|
31
|
-
"command": "python3 ${CLAUDE_PLUGIN_ROOT:-.}/hooks/pretooluse-bk-suggest.py",
|
|
32
|
-
"timeout": 2
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
25
|
"PostToolUse": [
|
|
38
26
|
{
|
|
39
27
|
"matcher": "Grep",
|
|
@@ -74,16 +62,6 @@
|
|
|
74
62
|
"timeout": 2
|
|
75
63
|
}
|
|
76
64
|
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"matcher": "mcp__.*bluera-knowledge__search",
|
|
80
|
-
"hooks": [
|
|
81
|
-
{
|
|
82
|
-
"type": "command",
|
|
83
|
-
"command": "echo 'TIP: Use mcp__bluera-knowledge__get_full_context with the result ID for complete code context.'",
|
|
84
|
-
"timeout": 1
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
65
|
}
|
|
88
66
|
],
|
|
89
67
|
"UserPromptSubmit": [
|
|
@@ -94,11 +72,6 @@
|
|
|
94
72
|
"command": "${CLAUDE_PLUGIN_ROOT:-.}/hooks/job-status-hook.sh",
|
|
95
73
|
"timeout": 2,
|
|
96
74
|
"async": true
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
"type": "command",
|
|
100
|
-
"command": "python3 ${CLAUDE_PLUGIN_ROOT:-.}/hooks/skill-activation.py",
|
|
101
|
-
"timeout": 2
|
|
102
75
|
}
|
|
103
76
|
]
|
|
104
77
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: knowledge-search
|
|
3
|
-
description:
|
|
3
|
+
description: Use when the user asks about libraries, frameworks, dependencies, API references, implementation details, or needs code examples from third-party packages. Activates for library API questions, dependency errors, framework configuration, or code generation involving external packages.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Using Bluera Knowledge (BK)
|