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