@ngao/search 1.0.0-alpha.2 → 1.0.0-alpha.4
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/dist-bundled/main.js +238 -68
- package/package.json +3 -2
package/dist-bundled/main.js
CHANGED
|
@@ -28822,6 +28822,14 @@ function fromJSONSchema(schema, params) {
|
|
|
28822
28822
|
}
|
|
28823
28823
|
|
|
28824
28824
|
|
|
28825
|
+
/***/ },
|
|
28826
|
+
|
|
28827
|
+
/***/ 3785
|
|
28828
|
+
(module) {
|
|
28829
|
+
|
|
28830
|
+
"use strict";
|
|
28831
|
+
module.exports = require("readline");
|
|
28832
|
+
|
|
28825
28833
|
/***/ },
|
|
28826
28834
|
|
|
28827
28835
|
/***/ 3835
|
|
@@ -33308,6 +33316,112 @@ exports.BlockImpl = BlockImpl;
|
|
|
33308
33316
|
"use strict";
|
|
33309
33317
|
module.exports = require("node:buffer");
|
|
33310
33318
|
|
|
33319
|
+
/***/ },
|
|
33320
|
+
|
|
33321
|
+
/***/ 4600
|
|
33322
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
33323
|
+
|
|
33324
|
+
"use strict";
|
|
33325
|
+
|
|
33326
|
+
/**
|
|
33327
|
+
* Unified Entry Point for NGAO Search
|
|
33328
|
+
* Supports multiple transport modes: stdio (MCP) or http (REST)
|
|
33329
|
+
*
|
|
33330
|
+
* Transport selection via environment variable:
|
|
33331
|
+
* - MCP_TRANSPORT=stdio - Start MCP stdio server only (for Claude Desktop)
|
|
33332
|
+
* - MCP_TRANSPORT=http - Start REST HTTP server only (default)
|
|
33333
|
+
* - --setup - Run interactive MCP setup for Claude
|
|
33334
|
+
*
|
|
33335
|
+
* All transports share the same NgaoSearchService instance
|
|
33336
|
+
*/
|
|
33337
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
33338
|
+
if (k2 === undefined) k2 = k;
|
|
33339
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
33340
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33341
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33342
|
+
}
|
|
33343
|
+
Object.defineProperty(o, k2, desc);
|
|
33344
|
+
}) : (function(o, m, k, k2) {
|
|
33345
|
+
if (k2 === undefined) k2 = k;
|
|
33346
|
+
o[k2] = m[k];
|
|
33347
|
+
}));
|
|
33348
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
33349
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33350
|
+
}) : function(o, v) {
|
|
33351
|
+
o["default"] = v;
|
|
33352
|
+
});
|
|
33353
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
33354
|
+
if (mod && mod.__esModule) return mod;
|
|
33355
|
+
var result = {};
|
|
33356
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33357
|
+
__setModuleDefault(result, mod);
|
|
33358
|
+
return result;
|
|
33359
|
+
};
|
|
33360
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
33361
|
+
const ngao_search_service_1 = __webpack_require__(9055);
|
|
33362
|
+
const mcp_transport_1 = __webpack_require__(6716);
|
|
33363
|
+
const rest_transport_1 = __webpack_require__(1256);
|
|
33364
|
+
const logger_1 = __webpack_require__(1789);
|
|
33365
|
+
// Check for --setup flag for interactive setup
|
|
33366
|
+
const args = process.argv.slice(2);
|
|
33367
|
+
const setupMode = args.includes('--setup') || process.env.NGAO_SETUP === 'true';
|
|
33368
|
+
const transport = (process.env.MCP_TRANSPORT || 'http').toLowerCase();
|
|
33369
|
+
const httpPort = process.env.PORT ? parseInt(process.env.PORT, 10) : 0; // 0 = random available port
|
|
33370
|
+
/**
|
|
33371
|
+
* Main async function
|
|
33372
|
+
*/
|
|
33373
|
+
async function main() {
|
|
33374
|
+
// Run setup first if requested
|
|
33375
|
+
if (setupMode) {
|
|
33376
|
+
try {
|
|
33377
|
+
const { setupMCP } = await Promise.resolve().then(() => __importStar(__webpack_require__(5021)));
|
|
33378
|
+
await setupMCP();
|
|
33379
|
+
process.exit(0);
|
|
33380
|
+
}
|
|
33381
|
+
catch (error) {
|
|
33382
|
+
console.error('Setup failed:', error);
|
|
33383
|
+
process.exit(1);
|
|
33384
|
+
}
|
|
33385
|
+
}
|
|
33386
|
+
try {
|
|
33387
|
+
// Create shared service instance
|
|
33388
|
+
const service = new ngao_search_service_1.NgaoSearchService();
|
|
33389
|
+
switch (transport) {
|
|
33390
|
+
case 'stdio': {
|
|
33391
|
+
const logger = (0, logger_1.createLogger)('stdio');
|
|
33392
|
+
logger.info('Transport: MCP stdio (Claude Desktop)');
|
|
33393
|
+
logger.info('Initializing NgaoSearchService');
|
|
33394
|
+
const mcpTransport = new mcp_transport_1.McpTransport(service, logger);
|
|
33395
|
+
await mcpTransport.start();
|
|
33396
|
+
logger.info('NGAO Search server started successfully');
|
|
33397
|
+
break;
|
|
33398
|
+
}
|
|
33399
|
+
case 'http': {
|
|
33400
|
+
const logger = (0, logger_1.createLogger)('http');
|
|
33401
|
+
logger.info('Transport: HTTP REST API');
|
|
33402
|
+
logger.info('Initializing NgaoSearchService');
|
|
33403
|
+
const restTransport = new rest_transport_1.RestTransport(service, logger);
|
|
33404
|
+
restTransport.start(httpPort);
|
|
33405
|
+
logger.info('NGAO Search server started successfully');
|
|
33406
|
+
break;
|
|
33407
|
+
}
|
|
33408
|
+
default:
|
|
33409
|
+
console.error(`❌ Unknown transport: ${transport}`);
|
|
33410
|
+
console.error(' Valid options: stdio, http');
|
|
33411
|
+
console.error(' Default: http');
|
|
33412
|
+
process.exit(1);
|
|
33413
|
+
}
|
|
33414
|
+
}
|
|
33415
|
+
catch (error) {
|
|
33416
|
+
console.error('❌ Failed to start NGAO Search server:');
|
|
33417
|
+
console.error(error);
|
|
33418
|
+
process.exit(1);
|
|
33419
|
+
}
|
|
33420
|
+
}
|
|
33421
|
+
// Start the server
|
|
33422
|
+
main();
|
|
33423
|
+
|
|
33424
|
+
|
|
33311
33425
|
/***/ },
|
|
33312
33426
|
|
|
33313
33427
|
/***/ 4633
|
|
@@ -34258,6 +34372,123 @@ function parseLiteralDef(def, refs) {
|
|
|
34258
34372
|
exports.parseLiteralDef = parseLiteralDef;
|
|
34259
34373
|
|
|
34260
34374
|
|
|
34375
|
+
/***/ },
|
|
34376
|
+
|
|
34377
|
+
/***/ 5021
|
|
34378
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
34379
|
+
|
|
34380
|
+
"use strict";
|
|
34381
|
+
|
|
34382
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
34383
|
+
if (k2 === undefined) k2 = k;
|
|
34384
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
34385
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
34386
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34387
|
+
}
|
|
34388
|
+
Object.defineProperty(o, k2, desc);
|
|
34389
|
+
}) : (function(o, m, k, k2) {
|
|
34390
|
+
if (k2 === undefined) k2 = k;
|
|
34391
|
+
o[k2] = m[k];
|
|
34392
|
+
}));
|
|
34393
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34394
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
34395
|
+
}) : function(o, v) {
|
|
34396
|
+
o["default"] = v;
|
|
34397
|
+
});
|
|
34398
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34399
|
+
if (mod && mod.__esModule) return mod;
|
|
34400
|
+
var result = {};
|
|
34401
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
34402
|
+
__setModuleDefault(result, mod);
|
|
34403
|
+
return result;
|
|
34404
|
+
};
|
|
34405
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
34406
|
+
exports.setupMCP = void 0;
|
|
34407
|
+
const fs = __importStar(__webpack_require__(9896));
|
|
34408
|
+
const path = __importStar(__webpack_require__(6928));
|
|
34409
|
+
const readline = __importStar(__webpack_require__(3785));
|
|
34410
|
+
const rl = readline.createInterface({
|
|
34411
|
+
input: process.stdin,
|
|
34412
|
+
output: process.stdout,
|
|
34413
|
+
});
|
|
34414
|
+
function question(prompt) {
|
|
34415
|
+
return new Promise((resolve) => {
|
|
34416
|
+
rl.question(prompt, (answer) => {
|
|
34417
|
+
resolve(answer);
|
|
34418
|
+
});
|
|
34419
|
+
});
|
|
34420
|
+
}
|
|
34421
|
+
async function setupMCP() {
|
|
34422
|
+
console.log('\n🔧 NGAO Search - MCP Setup for Claude\n');
|
|
34423
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '.';
|
|
34424
|
+
const claudeConfigPath = path.join(homeDir, '.claude');
|
|
34425
|
+
const mcpConfigFile = path.join(claudeConfigPath, 'mcp.json');
|
|
34426
|
+
// Check if already set up
|
|
34427
|
+
if (fs.existsSync(mcpConfigFile)) {
|
|
34428
|
+
const existingConfig = JSON.parse(fs.readFileSync(mcpConfigFile, 'utf8'));
|
|
34429
|
+
if (existingConfig.mcpServers?.['ngao-search']) {
|
|
34430
|
+
console.log('✅ NGAO Search is already configured in Claude MCP!');
|
|
34431
|
+
rl.close();
|
|
34432
|
+
return;
|
|
34433
|
+
}
|
|
34434
|
+
}
|
|
34435
|
+
// Ask for project directory
|
|
34436
|
+
const projectDir = await question('📁 Enter your project directory path (or press Enter for current): ');
|
|
34437
|
+
const resolvedProjectDir = projectDir.trim() || process.cwd();
|
|
34438
|
+
// Ask for port
|
|
34439
|
+
const portAnswer = await question('🔌 Enter port for MCP server (default: 3000): ');
|
|
34440
|
+
const port = portAnswer.trim() || '3000';
|
|
34441
|
+
// Create .claude directory if needed
|
|
34442
|
+
if (!fs.existsSync(claudeConfigPath)) {
|
|
34443
|
+
fs.mkdirSync(claudeConfigPath, { recursive: true });
|
|
34444
|
+
}
|
|
34445
|
+
// Read existing config or create new
|
|
34446
|
+
let mcpConfig = { mcpServers: {} };
|
|
34447
|
+
if (fs.existsSync(mcpConfigFile)) {
|
|
34448
|
+
mcpConfig = JSON.parse(fs.readFileSync(mcpConfigFile, 'utf8'));
|
|
34449
|
+
}
|
|
34450
|
+
// Add ngao-search server config
|
|
34451
|
+
mcpConfig.mcpServers = mcpConfig.mcpServers || {};
|
|
34452
|
+
mcpConfig.mcpServers['ngao-search'] = {
|
|
34453
|
+
command: 'npx',
|
|
34454
|
+
args: ['@ngao/search@alpha'],
|
|
34455
|
+
env: {
|
|
34456
|
+
NGAO_SEARCH_PORT: port,
|
|
34457
|
+
NGAO_SEARCH_PROJECT: resolvedProjectDir,
|
|
34458
|
+
},
|
|
34459
|
+
};
|
|
34460
|
+
// Write config file
|
|
34461
|
+
fs.writeFileSync(mcpConfigFile, JSON.stringify(mcpConfig, null, 2));
|
|
34462
|
+
console.log(`\n✅ MCP configuration saved to: ${mcpConfigFile}\n`);
|
|
34463
|
+
// Create .ngao-search config in project
|
|
34464
|
+
const projectConfigPath = path.join(resolvedProjectDir, '.ngao-search.json');
|
|
34465
|
+
if (!fs.existsSync(projectConfigPath)) {
|
|
34466
|
+
const projectConfig = {
|
|
34467
|
+
port,
|
|
34468
|
+
indexDir: path.join(resolvedProjectDir, '.ngao-search-index'),
|
|
34469
|
+
includePaths: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.py', '**/*.md'],
|
|
34470
|
+
excludePaths: ['node_modules/**', 'dist/**', '.git/**'],
|
|
34471
|
+
};
|
|
34472
|
+
fs.writeFileSync(projectConfigPath, JSON.stringify(projectConfig, null, 2));
|
|
34473
|
+
console.log(`✅ Project config created: ${projectConfigPath}\n`);
|
|
34474
|
+
}
|
|
34475
|
+
// Show setup instructions
|
|
34476
|
+
console.log('📝 Setup Instructions:\n');
|
|
34477
|
+
console.log('1. Claude now has access to NGAO Search MCP server');
|
|
34478
|
+
console.log('2. When you ask Claude about your code, it can:');
|
|
34479
|
+
console.log(' - Search through your project files');
|
|
34480
|
+
console.log(' - Index and understand your codebase');
|
|
34481
|
+
console.log(' - Provide context-aware code suggestions\n');
|
|
34482
|
+
console.log('3. Restart Claude Desktop for changes to take effect\n');
|
|
34483
|
+
console.log(`📍 Project directory: ${resolvedProjectDir}`);
|
|
34484
|
+
console.log(`🔌 Server port: ${port}\n`);
|
|
34485
|
+
rl.close();
|
|
34486
|
+
}
|
|
34487
|
+
exports.setupMCP = setupMCP;
|
|
34488
|
+
// Run setup
|
|
34489
|
+
setupMCP().catch(console.error);
|
|
34490
|
+
|
|
34491
|
+
|
|
34261
34492
|
/***/ },
|
|
34262
34493
|
|
|
34263
34494
|
/***/ 5039
|
|
@@ -65975,74 +66206,13 @@ exports.PythonParser = PythonParser;
|
|
|
65975
66206
|
/******/ })();
|
|
65976
66207
|
/******/
|
|
65977
66208
|
/************************************************************************/
|
|
65978
|
-
|
|
65979
|
-
//
|
|
65980
|
-
|
|
65981
|
-
|
|
65982
|
-
var
|
|
65983
|
-
|
|
65984
|
-
|
|
65985
|
-
* Unified Entry Point for NGAO Search
|
|
65986
|
-
* Supports multiple transport modes: stdio (MCP) or http (REST)
|
|
65987
|
-
*
|
|
65988
|
-
* Transport selection via environment variable:
|
|
65989
|
-
* - MCP_TRANSPORT=stdio - Start MCP stdio server only (for Claude Desktop)
|
|
65990
|
-
* - MCP_TRANSPORT=http - Start REST HTTP server only (default)
|
|
65991
|
-
*
|
|
65992
|
-
* All transports share the same NgaoSearchService instance
|
|
65993
|
-
*/
|
|
65994
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
65995
|
-
const ngao_search_service_1 = __webpack_require__(9055);
|
|
65996
|
-
const mcp_transport_1 = __webpack_require__(6716);
|
|
65997
|
-
const rest_transport_1 = __webpack_require__(1256);
|
|
65998
|
-
const logger_1 = __webpack_require__(1789);
|
|
65999
|
-
const transport = (process.env.MCP_TRANSPORT || 'http').toLowerCase();
|
|
66000
|
-
const httpPort = process.env.PORT ? parseInt(process.env.PORT, 10) : 0; // 0 = random available port
|
|
66001
|
-
/**
|
|
66002
|
-
* Main async function
|
|
66003
|
-
*/
|
|
66004
|
-
async function main() {
|
|
66005
|
-
try {
|
|
66006
|
-
// Create shared service instance
|
|
66007
|
-
const service = new ngao_search_service_1.NgaoSearchService();
|
|
66008
|
-
switch (transport) {
|
|
66009
|
-
case 'stdio': {
|
|
66010
|
-
const logger = (0, logger_1.createLogger)('stdio');
|
|
66011
|
-
logger.info('Transport: MCP stdio (Claude Desktop)');
|
|
66012
|
-
logger.info('Initializing NgaoSearchService');
|
|
66013
|
-
const mcpTransport = new mcp_transport_1.McpTransport(service, logger);
|
|
66014
|
-
await mcpTransport.start();
|
|
66015
|
-
logger.info('NGAO Search server started successfully');
|
|
66016
|
-
break;
|
|
66017
|
-
}
|
|
66018
|
-
case 'http': {
|
|
66019
|
-
const logger = (0, logger_1.createLogger)('http');
|
|
66020
|
-
logger.info('Transport: HTTP REST API');
|
|
66021
|
-
logger.info('Initializing NgaoSearchService');
|
|
66022
|
-
const restTransport = new rest_transport_1.RestTransport(service, logger);
|
|
66023
|
-
restTransport.start(httpPort);
|
|
66024
|
-
logger.info('NGAO Search server started successfully');
|
|
66025
|
-
break;
|
|
66026
|
-
}
|
|
66027
|
-
default:
|
|
66028
|
-
console.error(`❌ Unknown transport: ${transport}`);
|
|
66029
|
-
console.error(' Valid options: stdio, http');
|
|
66030
|
-
console.error(' Default: http');
|
|
66031
|
-
process.exit(1);
|
|
66032
|
-
}
|
|
66033
|
-
}
|
|
66034
|
-
catch (error) {
|
|
66035
|
-
console.error('❌ Failed to start NGAO Search server:');
|
|
66036
|
-
console.error(error);
|
|
66037
|
-
process.exit(1);
|
|
66038
|
-
}
|
|
66039
|
-
}
|
|
66040
|
-
// Start the server
|
|
66041
|
-
main();
|
|
66042
|
-
|
|
66043
|
-
})();
|
|
66044
|
-
|
|
66045
|
-
module.exports = __webpack_exports__;
|
|
66209
|
+
/******/
|
|
66210
|
+
/******/ // startup
|
|
66211
|
+
/******/ // Load entry module and return exports
|
|
66212
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
66213
|
+
/******/ var __webpack_exports__ = __webpack_require__(4600);
|
|
66214
|
+
/******/ module.exports = __webpack_exports__;
|
|
66215
|
+
/******/
|
|
66046
66216
|
/******/ })()
|
|
66047
66217
|
;
|
|
66048
66218
|
//# sourceMappingURL=main.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngao/search",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "NGAO Search - Model Context Protocol Server for Local Code/Document Search with LLM-Friendly Output",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"scripts": {
|
|
18
18
|
"build": "npm run build:backend && npm run clean:dist",
|
|
19
19
|
"build:backend": "webpack --config webpack.backend.config.js --mode production && tsc --emitDeclarationOnly",
|
|
20
|
-
"build:bundled": "BUNDLE=true webpack --config webpack.backend.config.js && npm run clean:dist:bundled",
|
|
20
|
+
"build:bundled": "BUNDLE=true webpack --config webpack.backend.config.js && npm run add:shebang && npm run clean:dist:bundled",
|
|
21
|
+
"add:shebang": "node -e \"const fs=require('fs');const f='dist-bundled/main.js';const c=fs.readFileSync(f,'utf8');if(!c.startsWith('#!')){fs.writeFileSync(f,'#!/usr/bin/env node\\n'+c);console.log('✓ Shebang added');}\"",
|
|
21
22
|
"clean:dist": "rm -rf dist/backend dist/cli dist/mcp dist/shared dist/index.* dist/**/*.map dist/*.map 2>/dev/null; true",
|
|
22
23
|
"clean:dist:bundled": "rm -rf dist-bundled/backend dist-bundled/cli dist-bundled/mcp dist-bundled/shared dist-bundled/*.map 2>/dev/null; true",
|
|
23
24
|
"start": "npm run build && node dist/main.js",
|