@crownpeak/dqm-react-component-dev-mcp 1.2.0
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/README.md +138 -0
- package/data/.env.example +22 -0
- package/data/.gitattributes +47 -0
- package/data/.glfrc.json +7 -0
- package/data/.husky/pre-commit +5 -0
- package/data/.nvmrc +1 -0
- package/data/CHANGELOG.md +75 -0
- package/data/CODE_OF_CONDUCT.md +129 -0
- package/data/CONTRIBUTING.md +203 -0
- package/data/DOCS-STRUCTURE.md +307 -0
- package/data/I18N.md +292 -0
- package/data/LICENSE +22 -0
- package/data/README.md +315 -0
- package/data/SECURITY.md +125 -0
- package/data/WIKI-DEPLOYMENT.md +348 -0
- package/data/docs/AI-FEATURES.md +610 -0
- package/data/docs/API-REFERENCE.md +1022 -0
- package/data/docs/AUTHENTICATION.md +301 -0
- package/data/docs/BACKEND-API.md +468 -0
- package/data/docs/DEVELOPMENT.md +375 -0
- package/data/docs/EXAMPLES.md +622 -0
- package/data/docs/MCP-SERVER.md +307 -0
- package/data/docs/MIGRATION-GUIDE.md +367 -0
- package/data/docs/NPM-PUBLISH.md +193 -0
- package/data/docs/QUICKSTART.md +206 -0
- package/data/docs/REDIS-SETUP.md +162 -0
- package/data/docs/SERVER.md +228 -0
- package/data/docs/TROUBLESHOOTING.md +657 -0
- package/data/docs/WIDGET-GUIDE.md +638 -0
- package/data/docs/WIKI-HOME.md +58 -0
- package/data/docs/WIKI-SIDEBAR.md +39 -0
- package/data/package.json +171 -0
- package/data/playwright.config.ts +64 -0
- package/data/probe/.cargo/config.toml +10 -0
- package/data/probe/.claude/commands/performance-review.md +15 -0
- package/data/probe/.clinerules +288 -0
- package/data/probe/.dockerignore +57 -0
- package/data/probe/.githooks/post-commit +11 -0
- package/data/probe/.githooks/pre-commit +99 -0
- package/data/probe/.githooks/pre-commit-vow +9 -0
- package/data/probe/.prompts/engineer.md +41 -0
- package/data/probe/.roomodes +28 -0
- package/data/probe/.windsurfrules +0 -0
- package/data/probe/BASH_TOOL_SUMMARY.md +148 -0
- package/data/probe/BENCHMARKING.md +256 -0
- package/data/probe/CLAUDE.md +226 -0
- package/data/probe/CODE_OF_CONDUCT.md +128 -0
- package/data/probe/CONTRIBUTING.md +193 -0
- package/data/probe/Cargo.toml +120 -0
- package/data/probe/Cross.toml +10 -0
- package/data/probe/DOCKER-README.md +224 -0
- package/data/probe/Dockerfile +32 -0
- package/data/probe/ENHANCED_DEBUG_TELEMETRY.md +188 -0
- package/data/probe/LICENSE +201 -0
- package/data/probe/Makefile +210 -0
- package/data/probe/README.md +824 -0
- package/data/probe/SECURITY.md +67 -0
- package/data/probe/WINDOWS-GUIDE.md +294 -0
- package/data/probe/benches/parsing_benchmarks.rs +370 -0
- package/data/probe/benches/search_benchmarks.rs +599 -0
- package/data/probe/benches/simd_benchmarks.rs +372 -0
- package/data/probe/benches/timing_benchmarks.rs +287 -0
- package/data/probe/build-windows.bat +229 -0
- package/data/probe/codex-config/config.toml +6 -0
- package/data/probe/docs/PERFORMANCE_OPTIMIZATION.md +161 -0
- package/data/probe/examples/cache_demo.rs +46 -0
- package/data/probe/examples/chat/.dockerignore +37 -0
- package/data/probe/examples/chat/ChatSessionManager.js +295 -0
- package/data/probe/examples/chat/Dockerfile +98 -0
- package/data/probe/examples/chat/LICENSE +201 -0
- package/data/probe/examples/chat/LOCAL_IMAGE_SUPPORT.md +195 -0
- package/data/probe/examples/chat/MCP_INTEGRATION.md +400 -0
- package/data/probe/examples/chat/README.md +338 -0
- package/data/probe/examples/chat/TRACING.md +226 -0
- package/data/probe/examples/chat/appTracer.js +968 -0
- package/data/probe/examples/chat/auth.js +76 -0
- package/data/probe/examples/chat/bin/probe-chat.js +13 -0
- package/data/probe/examples/chat/build.js +104 -0
- package/data/probe/examples/chat/cancelRequest.js +84 -0
- package/data/probe/examples/chat/demo-agentic-image-flow.js +88 -0
- package/data/probe/examples/chat/demo-local-images.js +128 -0
- package/data/probe/examples/chat/fileSpanExporter.js +181 -0
- package/data/probe/examples/chat/implement/README.md +228 -0
- package/data/probe/examples/chat/implement/backends/AiderBackend.js +750 -0
- package/data/probe/examples/chat/implement/backends/BaseBackend.js +276 -0
- package/data/probe/examples/chat/implement/backends/ClaudeCodeBackend.js +767 -0
- package/data/probe/examples/chat/implement/backends/MockBackend.js +237 -0
- package/data/probe/examples/chat/implement/backends/registry.js +85 -0
- package/data/probe/examples/chat/implement/core/BackendManager.js +567 -0
- package/data/probe/examples/chat/implement/core/ImplementTool.js +354 -0
- package/data/probe/examples/chat/implement/core/config.js +428 -0
- package/data/probe/examples/chat/implement/core/timeouts.js +58 -0
- package/data/probe/examples/chat/implement/core/utils.js +496 -0
- package/data/probe/examples/chat/implement/types/BackendTypes.js +126 -0
- package/data/probe/examples/chat/index.js +669 -0
- package/data/probe/examples/chat/mcpServer.js +341 -0
- package/data/probe/examples/chat/npm/LICENSE +15 -0
- package/data/probe/examples/chat/npm/README.md +168 -0
- package/data/probe/examples/chat/npm/bin/probe-chat.js +156 -0
- package/data/probe/examples/chat/npm/index.js +259 -0
- package/data/probe/examples/chat/npm/package.json +54 -0
- package/data/probe/examples/chat/package.json +102 -0
- package/data/probe/examples/chat/probeChat.js +456 -0
- package/data/probe/examples/chat/probeTool.js +491 -0
- package/data/probe/examples/chat/storage/JsonChatStorage.js +476 -0
- package/data/probe/examples/chat/telemetry.js +281 -0
- package/data/probe/examples/chat/test/integration/chatFlows.test.js +320 -0
- package/data/probe/examples/chat/test/integration/toolCalling.test.js +471 -0
- package/data/probe/examples/chat/test/mocks/mockLLMProvider.js +269 -0
- package/data/probe/examples/chat/test/test-backends.js +90 -0
- package/data/probe/examples/chat/test/testUtils.js +530 -0
- package/data/probe/examples/chat/test/unit/backendTimeout.test.js +161 -0
- package/data/probe/examples/chat/test/unit/packageFiles.test.js +120 -0
- package/data/probe/examples/chat/test/verify-tests.js +118 -0
- package/data/probe/examples/chat/test-agentic-image-loading.js +294 -0
- package/data/probe/examples/chat/test-ai-sdk-telemetry.js +204 -0
- package/data/probe/examples/chat/test-chat-tracing.js +38 -0
- package/data/probe/examples/chat/test-direct-function.js +49 -0
- package/data/probe/examples/chat/test-file-size-validation.js +103 -0
- package/data/probe/examples/chat/test-full-mcp-integration.js +258 -0
- package/data/probe/examples/chat/test-github-context.txt +12 -0
- package/data/probe/examples/chat/test-hierarchy.js +203 -0
- package/data/probe/examples/chat/test-image-spans.js +37 -0
- package/data/probe/examples/chat/test-local-image-reading.js +176 -0
- package/data/probe/examples/chat/test-mcp-integration.js +136 -0
- package/data/probe/examples/chat/test-mcp-probe-server.js +161 -0
- package/data/probe/examples/chat/test-mcp-with-ai.js +279 -0
- package/data/probe/examples/chat/test-multiple-allowed-dirs.js +111 -0
- package/data/probe/examples/chat/test-probe-mcp-server.js +110 -0
- package/data/probe/examples/chat/test-security-validation.js +145 -0
- package/data/probe/examples/chat/test-simple-tracing.js +32 -0
- package/data/probe/examples/chat/test-trace-verification.js +235 -0
- package/data/probe/examples/chat/test-tracing.js +114 -0
- package/data/probe/examples/chat/tokenCounter.js +419 -0
- package/data/probe/examples/chat/tokenUsageDisplay.js +134 -0
- package/data/probe/examples/chat/webServer.js +1103 -0
- package/data/probe/examples/reranker/Cargo.toml +33 -0
- package/data/probe/examples/reranker/DEBUG_OUTPUT_ANALYSIS.md +71 -0
- package/data/probe/examples/reranker/MODELS.md +66 -0
- package/data/probe/examples/reranker/MODEL_COMPARISON.md +60 -0
- package/data/probe/examples/reranker/MULTI_MODEL_ANALYSIS.md +176 -0
- package/data/probe/examples/reranker/PERFORMANCE_SUMMARY.md +156 -0
- package/data/probe/examples/reranker/README.md +347 -0
- package/data/probe/examples/reranker/RUST_BERT_COMPARISON.md +82 -0
- package/data/probe/examples/reranker/TOKENIZATION_GUIDE.md +120 -0
- package/data/probe/examples/reranker/check_rust_tokenizer.py +108 -0
- package/data/probe/examples/reranker/convert_to_torchscript.py +109 -0
- package/data/probe/examples/reranker/debug_scoring.py +189 -0
- package/data/probe/examples/reranker/debug_tokenization.py +154 -0
- package/data/probe/examples/reranker/download_models.sh +73 -0
- package/data/probe/examples/reranker/requirements.txt +13 -0
- package/data/probe/examples/reranker/run_comprehensive_benchmark.sh +83 -0
- package/data/probe/examples/reranker/rust_bert_test/Cargo.toml +12 -0
- package/data/probe/examples/reranker/rust_bert_test/README.md +54 -0
- package/data/probe/examples/reranker/simple_test.py +50 -0
- package/data/probe/examples/reranker/test_all_models.sh +63 -0
- package/data/probe/examples/reranker/test_bert_results.sh +44 -0
- package/data/probe/examples/reranker/test_cross_encoder.py +334 -0
- package/data/probe/examples/reranker/test_cross_encoder.sh +80 -0
- package/data/probe/examples/reranker/test_exact_comparison.py +151 -0
- package/data/probe/examples/reranker/test_parallel_performance.sh +56 -0
- package/data/probe/examples/reranker/test_scores.py +132 -0
- package/data/probe/install.ps1 +508 -0
- package/data/probe/install.sh +460 -0
- package/data/probe/npm/CLONE_METHOD_EXAMPLES.md +596 -0
- package/data/probe/npm/CONTEXT_COMPACTION.md +303 -0
- package/data/probe/npm/DELEGATE_TOOL_README.md +166 -0
- package/data/probe/npm/MAID_INTEGRATION.md +313 -0
- package/data/probe/npm/MCP_INTEGRATION_SUMMARY.md +241 -0
- package/data/probe/npm/README.md +824 -0
- package/data/probe/npm/bin/.gitignore +7 -0
- package/data/probe/npm/bin/.gitkeep +0 -0
- package/data/probe/npm/bin/README.md +12 -0
- package/data/probe/npm/bin/probe +167 -0
- package/data/probe/npm/docs/CLAUDE_CODE_INTEGRATION.md +414 -0
- package/data/probe/npm/docs/CODEX_INTEGRATION.md +502 -0
- package/data/probe/npm/docs/EDIT_CREATE_TOOLS.md +233 -0
- package/data/probe/npm/docs/RETRY_AND_FALLBACK.md +674 -0
- package/data/probe/npm/example-usage.js +335 -0
- package/data/probe/npm/examples/multi-engine-demo.js +117 -0
- package/data/probe/npm/examples/probe-agent-cli.js +113 -0
- package/data/probe/npm/examples/test-agent-edit.js +114 -0
- package/data/probe/npm/examples/test-edit-create.js +120 -0
- package/data/probe/npm/examples/test-edit-direct.js +114 -0
- package/data/probe/npm/index.d.ts +744 -0
- package/data/probe/npm/jest.config.js +52 -0
- package/data/probe/npm/package.json +117 -0
- package/data/probe/npm/scripts/build-agent.cjs +75 -0
- package/data/probe/npm/scripts/build-cjs.js +124 -0
- package/data/probe/npm/scripts/build-mcp.cjs +36 -0
- package/data/probe/npm/scripts/postinstall.js +216 -0
- package/data/probe/npm/test-codex-e2e.js +78 -0
- package/data/probe/npm/test-download-lock.js +109 -0
- package/data/probe/npm/test-grep-security.js +94 -0
- package/data/probe/npm/test-grep-simplified.js +63 -0
- package/data/probe/npm/test-grep.js +51 -0
- package/data/probe/npm/tests/README.md +96 -0
- package/data/probe/npm/tests/agent-compact-history.test.js +174 -0
- package/data/probe/npm/tests/allow-tests-default.test.js +151 -0
- package/data/probe/npm/tests/contextCompactor.test.js +498 -0
- package/data/probe/npm/tests/delegate-config.test.js +353 -0
- package/data/probe/npm/tests/delegate-integration.test.js +348 -0
- package/data/probe/npm/tests/extractor-integration.test.js +162 -0
- package/data/probe/npm/tests/extractor.test.js +317 -0
- package/data/probe/npm/tests/fixtures/sampleDiagrams.js +267 -0
- package/data/probe/npm/tests/integration/claude-code-auto-fallback.spec.js +148 -0
- package/data/probe/npm/tests/integration/claude-code-multi-step.spec.js +127 -0
- package/data/probe/npm/tests/integration/claude-code-tool-events.spec.js +163 -0
- package/data/probe/npm/tests/integration/codex-auto-fallback.spec.js +191 -0
- package/data/probe/npm/tests/integration/codex-tool-events.spec.js +147 -0
- package/data/probe/npm/tests/integration/examplesChatMcp.test.js +402 -0
- package/data/probe/npm/tests/integration/mcpDotenvSupport.test.js +174 -0
- package/data/probe/npm/tests/integration/mcpErrorHandling.test.js +566 -0
- package/data/probe/npm/tests/integration/mcpRobustness.test.js +564 -0
- package/data/probe/npm/tests/integration/mcpStdoutPurity.test.js +355 -0
- package/data/probe/npm/tests/integration/probeAgentMcp.test.js +398 -0
- package/data/probe/npm/tests/integration/retryFallback.test.js +368 -0
- package/data/probe/npm/tests/integration/schema-in-initial-message.test.js +318 -0
- package/data/probe/npm/tests/integration/schema-validation-loop-prevention.test.js +244 -0
- package/data/probe/npm/tests/integration/schemaRetryLogic.test.js +94 -0
- package/data/probe/npm/tests/integration/validationFlow.test.js +329 -0
- package/data/probe/npm/tests/manual/test-codex-basic.js +110 -0
- package/data/probe/npm/tests/mcp/mcpClientManager.test.js +614 -0
- package/data/probe/npm/tests/mcp/mcpConfig.test.js +359 -0
- package/data/probe/npm/tests/mcp/mcpXmlBridge.test.js +436 -0
- package/data/probe/npm/tests/mcp/mockMcpServer.js +510 -0
- package/data/probe/npm/tests/mcp-strict-syntax.test.js +319 -0
- package/data/probe/npm/tests/mermaidQuoteEscaping.test.js +214 -0
- package/data/probe/npm/tests/nestedQuoteFix.test.js +40 -0
- package/data/probe/npm/tests/setup.js +46 -0
- package/data/probe/npm/tests/unit/allowed-tools.test.js +513 -0
- package/data/probe/npm/tests/unit/attempt-completion-closing-tag-in-content.test.js +188 -0
- package/data/probe/npm/tests/unit/attemptCompletionJsonFix.test.js +238 -0
- package/data/probe/npm/tests/unit/attemptCompletionJsonIssue.test.js +128 -0
- package/data/probe/npm/tests/unit/backtickAutoFix.test.js +35 -0
- package/data/probe/npm/tests/unit/bash-probe-agent-integration.test.js +389 -0
- package/data/probe/npm/tests/unit/bash-simple-commands.test.js +324 -0
- package/data/probe/npm/tests/unit/bash-tool-comprehensive.test.js +371 -0
- package/data/probe/npm/tests/unit/bash-tool-integration.test.js +310 -0
- package/data/probe/npm/tests/unit/bash-tool.test.js +341 -0
- package/data/probe/npm/tests/unit/completion-prompt.test.js +379 -0
- package/data/probe/npm/tests/unit/cwd-path-options.test.js +287 -0
- package/data/probe/npm/tests/unit/delegate-limits.test.js +422 -0
- package/data/probe/npm/tests/unit/direct-content-attempt-completion.test.js +235 -0
- package/data/probe/npm/tests/unit/edit-create-tools.test.js +609 -0
- package/data/probe/npm/tests/unit/enhancedMermaidValidation.test.js +577 -0
- package/data/probe/npm/tests/unit/extract-content.test.js +83 -0
- package/data/probe/npm/tests/unit/extract-multiple-targets.test.js +89 -0
- package/data/probe/npm/tests/unit/fallbackManager.test.js +442 -0
- package/data/probe/npm/tests/unit/githubCompatibilityValidation.test.js +258 -0
- package/data/probe/npm/tests/unit/imageConfig.test.js +149 -0
- package/data/probe/npm/tests/unit/imagePathResolution.test.js +345 -0
- package/data/probe/npm/tests/unit/json-fixing-agent.test.js +238 -0
- package/data/probe/npm/tests/unit/json-validation-enhanced-errors.test.js +199 -0
- package/data/probe/npm/tests/unit/jsonValidationInfiniteLoopFix.test.js +228 -0
- package/data/probe/npm/tests/unit/maidIntegration.test.js +139 -0
- package/data/probe/npm/tests/unit/maxIterationsWarning.test.js +195 -0
- package/data/probe/npm/tests/unit/mermaidEdgeLabelFix.test.js +161 -0
- package/data/probe/npm/tests/unit/mermaidHtmlEntities.test.js +76 -0
- package/data/probe/npm/tests/unit/mermaidInfiniteLoopFix.test.js +64 -0
- package/data/probe/npm/tests/unit/mermaidValidation.test.js +723 -0
- package/data/probe/npm/tests/unit/mermaidValidationVisorExample.test.js +309 -0
- package/data/probe/npm/tests/unit/probe-agent-clone-realistic.test.js +643 -0
- package/data/probe/npm/tests/unit/probe-agent-clone.test.js +476 -0
- package/data/probe/npm/tests/unit/probe-agent-delegate.test.js +400 -0
- package/data/probe/npm/tests/unit/probe-agent-model-option.test.js +118 -0
- package/data/probe/npm/tests/unit/probeTool-security.test.js +283 -0
- package/data/probe/npm/tests/unit/readImageTool.test.js +418 -0
- package/data/probe/npm/tests/unit/retryManager.test.js +317 -0
- package/data/probe/npm/tests/unit/schema-aware-reminders.test.js +288 -0
- package/data/probe/npm/tests/unit/schemaDefinitionDetection.test.js +115 -0
- package/data/probe/npm/tests/unit/schemaUtils.test.js +1268 -0
- package/data/probe/npm/tests/unit/simpleTelemetry.test.js +282 -0
- package/data/probe/npm/tests/unit/simplified-attempt-completion.test.js +274 -0
- package/data/probe/npm/tests/unit/single-quote-json-bug.test.js +231 -0
- package/data/probe/npm/tests/unit/subgraphAutoFix.test.js +110 -0
- package/data/probe/npm/tests/unit/system-prompt.test.js +32 -0
- package/data/probe/npm/tests/unit/types-probe-agent-options.test.js +42 -0
- package/data/probe/npm/tests/unit/xmlParsing.test.js +720 -0
- package/data/probe/npm/tsconfig.json +21 -0
- package/data/probe/result1.txt +19 -0
- package/data/probe/result2.txt +26 -0
- package/data/probe/scripts/benchmark.sh +270 -0
- package/data/probe/scripts/cache_memory_analysis.rs +844 -0
- package/data/probe/scripts/claude-hook-wrapper.sh +56 -0
- package/data/probe/site/.env.example +10 -0
- package/data/probe/site/DEPLOYMENT.md +86 -0
- package/data/probe/site/README.md +183 -0
- package/data/probe/site/adding-languages.md +135 -0
- package/data/probe/site/ai-chat.md +427 -0
- package/data/probe/site/ai-integration.md +1488 -0
- package/data/probe/site/blog/agentic-flow-custom-xml-protocol.md +407 -0
- package/data/probe/site/blog/index.md +118 -0
- package/data/probe/site/blog/v0.6.0-release.md +426 -0
- package/data/probe/site/blog.md +8 -0
- package/data/probe/site/changelog.md +200 -0
- package/data/probe/site/cli-mode.md +437 -0
- package/data/probe/site/code-extraction.md +436 -0
- package/data/probe/site/contributing/README.md +9 -0
- package/data/probe/site/contributing/documentation-cross-references.md +215 -0
- package/data/probe/site/contributing/documentation-maintenance.md +275 -0
- package/data/probe/site/contributing/documentation-structure.md +75 -0
- package/data/probe/site/documentation-cross-references.md +215 -0
- package/data/probe/site/documentation-guide.md +132 -0
- package/data/probe/site/documentation-maintenance.md +275 -0
- package/data/probe/site/features.md +147 -0
- package/data/probe/site/how-it-works.md +118 -0
- package/data/probe/site/index.md +175 -0
- package/data/probe/site/index.md.bak +133 -0
- package/data/probe/site/installation.md +235 -0
- package/data/probe/site/integrations/docker.md +248 -0
- package/data/probe/site/integrations/github-actions.md +413 -0
- package/data/probe/site/language-support-overview.md +168 -0
- package/data/probe/site/mcp-integration.md +587 -0
- package/data/probe/site/mcp-server.md +304 -0
- package/data/probe/site/navigation-structure.md +76 -0
- package/data/probe/site/nodejs-sdk.md +798 -0
- package/data/probe/site/output-formats.md +625 -0
- package/data/probe/site/package.json +21 -0
- package/data/probe/site/public/_headers +28 -0
- package/data/probe/site/public/_redirects +11 -0
- package/data/probe/site/quick-start.md +289 -0
- package/data/probe/site/search-functionality.md +291 -0
- package/data/probe/site/search-reference.md +291 -0
- package/data/probe/site/supported-languages.md +215 -0
- package/data/probe/site/use-cases/README.md +8 -0
- package/data/probe/site/use-cases/advanced-cli.md +253 -0
- package/data/probe/site/use-cases/ai-code-editors.md +239 -0
- package/data/probe/site/use-cases/building-ai-tools.md +529 -0
- package/data/probe/site/use-cases/cli-ai-workflows.md +285 -0
- package/data/probe/site/use-cases/deploying-probe-web-interface.md +255 -0
- package/data/probe/site/use-cases/integrating-probe-into-ai-code-editors.md +161 -0
- package/data/probe/site/use-cases/nodejs-sdk.md +596 -0
- package/data/probe/site/use-cases/team-chat.md +350 -0
- package/data/probe/site/web-interface.md +434 -0
- package/data/probe/site/wrangler.toml +9 -0
- package/data/probe/test-api-key.sh +1 -0
- package/data/probe/test-probe-implementation/hello.js +7 -0
- package/data/probe/test_cases/demonstrate_early_termination_issues.sh +176 -0
- package/data/probe/test_cases/early_termination_issues.rs +533 -0
- package/data/probe/test_data/test_nested_struct.go +26 -0
- package/data/probe/tests/README.md +286 -0
- package/data/probe/tests/README_search_determinism_tests.md +116 -0
- package/data/probe/tests/adjacent_comment_test.rs +152 -0
- package/data/probe/tests/apostrophe_handling_tests.rs +132 -0
- package/data/probe/tests/block_filtering_with_ast_tests.rs +669 -0
- package/data/probe/tests/block_merging_tests.rs +396 -0
- package/data/probe/tests/c_outline_format_tests.rs +2179 -0
- package/data/probe/tests/cache_invalidation_issues.rs.disabled +682 -0
- package/data/probe/tests/cache_order_tests.rs +147 -0
- package/data/probe/tests/cache_query_scoping_tests.rs +221 -0
- package/data/probe/tests/cli_tests.rs +680 -0
- package/data/probe/tests/comment_context_integration_test.rs +240 -0
- package/data/probe/tests/common.rs +33 -0
- package/data/probe/tests/complex_block_merging_tests.rs +599 -0
- package/data/probe/tests/complex_query_block_filtering_tests.rs +422 -0
- package/data/probe/tests/control_flow_closing_braces_test.rs +91 -0
- package/data/probe/tests/cpp_outline_format_tests.rs +1507 -0
- package/data/probe/tests/csharp_outline_format_tests.rs +941 -0
- package/data/probe/tests/elastic_query_integration_tests.rs +922 -0
- package/data/probe/tests/extract_command_tests.rs +1848 -0
- package/data/probe/tests/extract_deduplication_tests.rs +146 -0
- package/data/probe/tests/extract_input_file_tests.rs +84 -0
- package/data/probe/tests/extract_prompt_tests.rs +102 -0
- package/data/probe/tests/filename_search_tests.rs +96 -0
- package/data/probe/tests/fixtures/user/AssemblyInfo.cs +3 -0
- package/data/probe/tests/github_extract_tests.rs +234 -0
- package/data/probe/tests/go_comment_test.rs +253 -0
- package/data/probe/tests/go_outline_format_tests.rs +2587 -0
- package/data/probe/tests/go_path_resolver_tests.rs +96 -0
- package/data/probe/tests/html_outline_format_tests.rs +637 -0
- package/data/probe/tests/integration_tests.rs +837 -0
- package/data/probe/tests/ip_whitelist_test.rs +148 -0
- package/data/probe/tests/java_outline_format_tests.rs +1611 -0
- package/data/probe/tests/javascript_extract_tests.rs +315 -0
- package/data/probe/tests/javascript_outline_format_tests.rs +1464 -0
- package/data/probe/tests/json_format_tests.rs +436 -0
- package/data/probe/tests/json_schema_validation_tests.rs +450 -0
- package/data/probe/tests/lib_usage.rs +60 -0
- package/data/probe/tests/line_comment_context_extension_test.rs +459 -0
- package/data/probe/tests/line_map_cache_tests.rs +114 -0
- package/data/probe/tests/markdown_integration_tests.rs +190 -0
- package/data/probe/tests/mocks/test_ip_whitelist.go +11 -0
- package/data/probe/tests/mocks/test_object.js +27 -0
- package/data/probe/tests/mocks/test_struct.go +50 -0
- package/data/probe/tests/multi_keyword_pattern_tests.rs +464 -0
- package/data/probe/tests/multi_language_syntax_integration_tests.rs +218 -0
- package/data/probe/tests/multiple_capture_groups_tests.rs +169 -0
- package/data/probe/tests/negative_compound_word_tests.rs +246 -0
- package/data/probe/tests/nested_symbol_extraction_tests.rs +99 -0
- package/data/probe/tests/outline_cross_file_interference_test.rs +335 -0
- package/data/probe/tests/outline_keyword_preservation_test.rs +67 -0
- package/data/probe/tests/output_format_edge_cases_tests.rs +693 -0
- package/data/probe/tests/parallel_extraction_tests.rs +178 -0
- package/data/probe/tests/parallel_search_tests.rs +355 -0
- package/data/probe/tests/path_resolver_tests.rs +698 -0
- package/data/probe/tests/php_outline_format_extended_tests.rs +928 -0
- package/data/probe/tests/php_outline_format_tests.rs +768 -0
- package/data/probe/tests/property_tests.proptest-regressions +9 -0
- package/data/probe/tests/property_tests.rs +118 -0
- package/data/probe/tests/python_outline_format_tests.rs +1538 -0
- package/data/probe/tests/query_command_json_tests.rs +438 -0
- package/data/probe/tests/query_command_tests.rs +232 -0
- package/data/probe/tests/query_command_xml_tests.rs +569 -0
- package/data/probe/tests/quoted_term_with_negative_keyword_tests.rs +216 -0
- package/data/probe/tests/required_terms_filename_tests.rs +116 -0
- package/data/probe/tests/ruby_outline_format_tests.rs +1011 -0
- package/data/probe/tests/rust_line_comment_context_test.rs +151 -0
- package/data/probe/tests/rust_outline_format_enhanced_tests.rs +725 -0
- package/data/probe/tests/rust_outline_format_tests.rs +843 -0
- package/data/probe/tests/schemas/xml_output_schema.xsd +38 -0
- package/data/probe/tests/search_determinism_tests.rs +451 -0
- package/data/probe/tests/search_hints_tests.rs +253 -0
- package/data/probe/tests/special_character_escaping_tests.rs +417 -0
- package/data/probe/tests/stemming_compound_word_filtering_tests.rs +535 -0
- package/data/probe/tests/strict_elastic_syntax_tests.rs +404 -0
- package/data/probe/tests/swift_outline_format_tests.rs +3319 -0
- package/data/probe/tests/symbols_tests.rs +166 -0
- package/data/probe/tests/test_file.rs +45 -0
- package/data/probe/tests/test_tokenize.rs +28 -0
- package/data/probe/tests/timeout_tests.rs +82 -0
- package/data/probe/tests/tokenization_tests.rs +195 -0
- package/data/probe/tests/tokenized_block_filtering_tests.rs +174 -0
- package/data/probe/tests/typescript_extract_tests.rs +214 -0
- package/data/probe/tests/typescript_outline_format_tests.rs +2188 -0
- package/data/probe/tests/xml_format_tests.rs +568 -0
- package/data/probe/tests/xml_schema_validation_tests.rs +497 -0
- package/data/scripts/postinstall.mjs +9 -0
- package/data/scripts/set-version.js +0 -0
- package/data/scripts/wiki-build.sh +111 -0
- package/data/scripts/wiki-deploy.sh +73 -0
- package/data/serve.json +12 -0
- package/data/test/demo-dynamic.html +134 -0
- package/data/test/demo-esm.html +105 -0
- package/data/test/demo-iife.html +78 -0
- package/data/tsconfig.json +7 -0
- package/data/vite.server.ts +483 -0
- package/data/vitest.config.ts +40 -0
- package/data/wiki/Home.md +58 -0
- package/data/wiki/_Sidebar.md +39 -0
- package/docs-mcp.config.json +20 -0
- package/package.json +56 -0
- package/src/config.js +111 -0
- package/src/index.js +395 -0
|
@@ -0,0 +1,1488 @@
|
|
|
1
|
+
# Probe AI Integration
|
|
2
|
+
|
|
3
|
+
Probe offers powerful AI integration capabilities that allow you to leverage large language models (LLMs) to understand and navigate your codebase more effectively. This document provides comprehensive information about Probe's AI features, including the AI chat mode, ProbeAgent SDK for building AI applications, MCP server integration, and Node.js SDK for programmatic access.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Privacy Considerations](#privacy-considerations)
|
|
8
|
+
- [AI Chat Mode](#ai-chat-mode)
|
|
9
|
+
- [Overview](#overview)
|
|
10
|
+
- [Installation and Setup](#installation-and-setup)
|
|
11
|
+
- [Features](#features)
|
|
12
|
+
- [Configuration Options](#configuration-options)
|
|
13
|
+
- [Advanced Usage](#advanced-usage)
|
|
14
|
+
- [Best Practices](#best-practices)
|
|
15
|
+
- [ProbeAgent SDK](#probeagent-sdk)
|
|
16
|
+
- [Overview](#probeagent-overview)
|
|
17
|
+
- [Installation](#probeagent-installation)
|
|
18
|
+
- [Quick Start](#probeagent-quick-start)
|
|
19
|
+
- [API Reference](#probeagent-api)
|
|
20
|
+
- [Usage Examples](#probeagent-examples)
|
|
21
|
+
- [Advanced Features](#probeagent-advanced)
|
|
22
|
+
- [Comparison with ProbeChat](#probeagent-vs-probechat)
|
|
23
|
+
- [MCP Server Integration](#mcp-server-integration)
|
|
24
|
+
- [Overview](#mcp-overview)
|
|
25
|
+
- [Setting Up the MCP Server](#setting-up-the-mcp-server)
|
|
26
|
+
- [Available Tools](#available-tools)
|
|
27
|
+
- [Integration with AI Assistants](#integration-with-ai-assistants)
|
|
28
|
+
- [Advanced Configuration](#advanced-configuration)
|
|
29
|
+
- [Troubleshooting](#troubleshooting)
|
|
30
|
+
- [Node.js SDK](#nodejs-sdk)
|
|
31
|
+
- [Overview](#sdk-overview)
|
|
32
|
+
- [Installation](#sdk-installation)
|
|
33
|
+
- [Core Functions](#core-functions)
|
|
34
|
+
- [AI Tools Integration](#ai-tools-integration)
|
|
35
|
+
- [Examples](#examples)
|
|
36
|
+
- [API Reference](#api-reference)
|
|
37
|
+
|
|
38
|
+
## Privacy Considerations {#privacy-considerations}
|
|
39
|
+
|
|
40
|
+
When using Probe's AI integration features, it's important to understand the privacy implications:
|
|
41
|
+
|
|
42
|
+
- **Local Search Engine**: Probe itself is a fully local semantic code search tool that doesn't require embedding generation or cloud indexing
|
|
43
|
+
- **Works Like Elastic Search**: Probe functions like a full elastic search on top of your codebase or documentation, without requiring indexing
|
|
44
|
+
- **AI Service Integration**: When using Probe with external AI services (Anthropic, OpenAI, Google, etc.), code snippets found by Probe are sent to those services
|
|
45
|
+
- **Data Transmission**: The following data may be transmitted to external AI providers:
|
|
46
|
+
- Your natural language queries
|
|
47
|
+
- Code snippets and context found by Probe's search
|
|
48
|
+
- Conversation history for contextual awareness
|
|
49
|
+
- **Provider Selection**: You can choose which AI provider to use based on your privacy requirements
|
|
50
|
+
- **Local Model Options**: For maximum privacy, Probe can be used with locally-running AI models, keeping all data on your machine
|
|
51
|
+
|
|
52
|
+
Consider these privacy aspects when choosing how to integrate Probe with AI services, especially when working with sensitive or proprietary code.
|
|
53
|
+
|
|
54
|
+
## AI Chat Mode {#ai-chat-mode}
|
|
55
|
+
|
|
56
|
+
### Overview {#overview}
|
|
57
|
+
|
|
58
|
+
Probe's AI Chat mode provides an interactive CLI interface where you can ask questions about your codebase and get AI-powered responses. This mode combines Probe's powerful code search capabilities with large language models to help you understand and navigate your codebase more effectively.
|
|
59
|
+
|
|
60
|
+
Key benefits:
|
|
61
|
+
|
|
62
|
+
- **Natural Language Understanding**: Ask questions about your code in plain English
|
|
63
|
+
- **Contextual Awareness**: The AI maintains conversation history for follow-up questions
|
|
64
|
+
- **Code-Aware Responses**: Get explanations that reference specific files and line numbers
|
|
65
|
+
- **Intelligent Search**: The AI automatically formulates optimal search queries based on your questions
|
|
66
|
+
|
|
67
|
+
### Installation and Setup {#installation-and-setup}
|
|
68
|
+
|
|
69
|
+
The AI chat functionality is available as a standalone npm package that can be run directly with npx.
|
|
70
|
+
|
|
71
|
+
#### Using npx (Recommended)
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Run directly with npx (no installation needed)
|
|
75
|
+
npx -y @probelabs/probe-chat@latest
|
|
76
|
+
|
|
77
|
+
# Set your API key first
|
|
78
|
+
export ANTHROPIC_API_KEY=your_api_key
|
|
79
|
+
# Or for OpenAI
|
|
80
|
+
# export OPENAI_API_KEY=your_api_key
|
|
81
|
+
# Or for Google
|
|
82
|
+
# export GOOGLE_API_KEY=your_api_key
|
|
83
|
+
|
|
84
|
+
# Or specify a directory to search
|
|
85
|
+
npx -y @probelabs/probe-chat@latest /path/to/your/project
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### Using the npm package
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Install globally
|
|
92
|
+
npm install -g @probelabs/probe-chat@latest
|
|
93
|
+
|
|
94
|
+
# Start the chat interface
|
|
95
|
+
probe-chat
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Using the example code
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Navigate to the examples directory
|
|
102
|
+
cd examples/chat
|
|
103
|
+
|
|
104
|
+
# Install dependencies
|
|
105
|
+
npm install
|
|
106
|
+
|
|
107
|
+
# Set your API key
|
|
108
|
+
export ANTHROPIC_API_KEY=your_api_key
|
|
109
|
+
# Or for OpenAI
|
|
110
|
+
# export OPENAI_API_KEY=your_api_key
|
|
111
|
+
# Or for Google
|
|
112
|
+
# export GOOGLE_API_KEY=your_api_key
|
|
113
|
+
|
|
114
|
+
# Start the chat interface
|
|
115
|
+
node index.js
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Features {#features}
|
|
119
|
+
|
|
120
|
+
#### AI-Powered Search
|
|
121
|
+
|
|
122
|
+
The AI Chat mode uses large language models to understand your questions and search your codebase intelligently. It can:
|
|
123
|
+
|
|
124
|
+
- Find relevant code based on natural language descriptions
|
|
125
|
+
- Explain how different parts of your codebase work together
|
|
126
|
+
- Identify patterns and architectural decisions
|
|
127
|
+
- Help you understand complex code
|
|
128
|
+
|
|
129
|
+
#### Multi-Model Support
|
|
130
|
+
|
|
131
|
+
Probe's AI Chat mode supports multiple AI providers:
|
|
132
|
+
|
|
133
|
+
- **Anthropic Claude**: Provides excellent code understanding and explanation capabilities
|
|
134
|
+
- **OpenAI GPT**: Offers strong general-purpose capabilities
|
|
135
|
+
- **Google Gemini**: Delivers fast responses and efficient code search
|
|
136
|
+
|
|
137
|
+
The default model is selected based on which API key you provide, or you can force a specific provider using the `--force-provider` option or the `FORCE_PROVIDER` environment variable.
|
|
138
|
+
|
|
139
|
+
#### Force Provider Option
|
|
140
|
+
|
|
141
|
+
You can force the chat to use a specific provider regardless of which API keys are available:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Force using Anthropic Claude
|
|
145
|
+
probe-chat --force-provider anthropic
|
|
146
|
+
|
|
147
|
+
# Force using OpenAI
|
|
148
|
+
probe-chat --force-provider openai
|
|
149
|
+
|
|
150
|
+
# Force using Google Gemini
|
|
151
|
+
probe-chat --force-provider google
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
This is useful when you have multiple API keys configured but want to use a specific provider for certain tasks.
|
|
155
|
+
|
|
156
|
+
#### Token Tracking
|
|
157
|
+
|
|
158
|
+
The AI Chat mode monitors token usage for both requests and responses, helping you keep track of your API usage:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
Token Usage: Request: 1245 Response: 1532 (Current message only: ~1532)
|
|
162
|
+
Total: 2777 tokens (Cumulative for entire session)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Conversation History
|
|
166
|
+
|
|
167
|
+
The chat maintains context across multiple interactions, allowing for follow-up questions and deeper exploration of topics. The history is managed efficiently to prevent context overflow:
|
|
168
|
+
|
|
169
|
+
- Maintains up to 20 previous messages by default
|
|
170
|
+
- Automatically trims older messages when the limit is reached
|
|
171
|
+
- Preserves context for follow-up questions
|
|
172
|
+
|
|
173
|
+
#### Session-Based Caching
|
|
174
|
+
|
|
175
|
+
The AI Chat mode uses a session-based caching system to avoid showing the same code blocks multiple times in a conversation:
|
|
176
|
+
|
|
177
|
+
- Each chat instance generates a unique session ID
|
|
178
|
+
- The session ID is used to track which code blocks have already been shown
|
|
179
|
+
- This prevents redundant information in responses
|
|
180
|
+
- The cache is maintained for the duration of the chat session
|
|
181
|
+
|
|
182
|
+
#### Colored Output
|
|
183
|
+
|
|
184
|
+
The terminal interface provides user-friendly colored output with syntax highlighting for code blocks, making it easier to read and understand the AI's responses.
|
|
185
|
+
|
|
186
|
+
### Configuration Options {#configuration-options}
|
|
187
|
+
|
|
188
|
+
You can configure the AI Chat mode using environment variables:
|
|
189
|
+
|
|
190
|
+
#### Model Selection
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Override the default model
|
|
194
|
+
export MODEL_NAME=claude-3-opus-20240229
|
|
195
|
+
probe-chat
|
|
196
|
+
|
|
197
|
+
# For Google models
|
|
198
|
+
export MODEL_NAME=gemini-2.0-flash
|
|
199
|
+
probe-chat
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
#### Force Provider
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Force a specific provider
|
|
206
|
+
export FORCE_PROVIDER=anthropic # Options: anthropic, openai, google
|
|
207
|
+
probe-chat
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
#### API URLs
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
# Override API URLs (useful for proxies or enterprise deployments)
|
|
214
|
+
export ANTHROPIC_API_URL=https://your-anthropic-proxy.com
|
|
215
|
+
export OPENAI_API_URL=https://your-openai-proxy.com/v1
|
|
216
|
+
export GOOGLE_API_URL=https://your-google-proxy.com
|
|
217
|
+
probe-chat
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### Debug Mode
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
# Enable debug mode for detailed logging
|
|
224
|
+
export DEBUG=1 probe-chat
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### Allowed Folders
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
# Specify which folders the AI can search
|
|
231
|
+
export ALLOWED_FOLDERS=/path/to/project1,/path/to/project2
|
|
232
|
+
probe-chat
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Advanced Usage {#advanced-usage}
|
|
236
|
+
|
|
237
|
+
#### Programmatic Usage in Node.js
|
|
238
|
+
|
|
239
|
+
You can also use the AI Chat functionality programmatically in your Node.js applications:
|
|
240
|
+
|
|
241
|
+
```javascript
|
|
242
|
+
import { ProbeChat } from '@probelabs/probe-chat';
|
|
243
|
+
import { StreamingTextResponse } from 'ai';
|
|
244
|
+
|
|
245
|
+
// Create a chat instance
|
|
246
|
+
const chat = new ProbeChat({
|
|
247
|
+
model: 'claude-3-sonnet-20240229',
|
|
248
|
+
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
|
|
249
|
+
// Or use OpenAI
|
|
250
|
+
// openaiApiKey: process.env.OPENAI_API_KEY,
|
|
251
|
+
// Or use Google
|
|
252
|
+
// googleApiKey: process.env.GOOGLE_API_KEY,
|
|
253
|
+
// Force a specific provider
|
|
254
|
+
// forceProvider: 'anthropic', // Options: 'anthropic', 'openai', 'google'
|
|
255
|
+
allowedFolders: ['/path/to/your/project']
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// In an API route or Express handler
|
|
259
|
+
export async function POST(req) {
|
|
260
|
+
const { messages } = await req.json();
|
|
261
|
+
const userMessage = messages[messages.length - 1].content;
|
|
262
|
+
|
|
263
|
+
// Get a streaming response from the AI
|
|
264
|
+
const stream = await chat.chat(userMessage, { stream: true });
|
|
265
|
+
|
|
266
|
+
// Return a streaming response
|
|
267
|
+
return new StreamingTextResponse(stream);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Or use it in a non-streaming way
|
|
271
|
+
const response = await chat.chat('How is authentication implemented?');
|
|
272
|
+
console.log(response);
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### Custom System Messages
|
|
276
|
+
|
|
277
|
+
You can customize the system message to provide specific instructions to the AI:
|
|
278
|
+
|
|
279
|
+
```javascript
|
|
280
|
+
const chat = new ProbeChat({
|
|
281
|
+
model: 'claude-3-sonnet-20240229',
|
|
282
|
+
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
|
|
283
|
+
// Or use a different provider
|
|
284
|
+
// forceProvider: 'google',
|
|
285
|
+
// googleApiKey: process.env.GOOGLE_API_KEY,
|
|
286
|
+
allowedFolders: ['/path/to/your/project'],
|
|
287
|
+
systemMessage: 'You are a code expert focusing on security issues. When analyzing code, prioritize identifying security vulnerabilities.'
|
|
288
|
+
});
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
#### Experimental Thinking
|
|
292
|
+
|
|
293
|
+
For Claude 3.7 models, you can enable the experimental thinking feature for more detailed reasoning:
|
|
294
|
+
|
|
295
|
+
```javascript
|
|
296
|
+
const chat = new ProbeChat({
|
|
297
|
+
model: 'claude-3-7-sonnet-latest',
|
|
298
|
+
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
|
|
299
|
+
allowedFolders: ['/path/to/your/project'],
|
|
300
|
+
experimentalThinking: {
|
|
301
|
+
enabled: true,
|
|
302
|
+
budget: 8000
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Best Practices {#best-practices}
|
|
308
|
+
|
|
309
|
+
1. **Be Specific**: Ask specific questions about your codebase for more targeted answers
|
|
310
|
+
2. **Start with Overview Questions**: Begin with high-level questions to understand the structure before diving into details
|
|
311
|
+
3. **Follow Up**: Use follow-up questions to explore topics in more depth
|
|
312
|
+
4. **Reference Files**: Mention specific files or directories if you want to focus on a particular area
|
|
313
|
+
5. **Ask for Explanations**: The AI is particularly good at explaining complex code or concepts
|
|
314
|
+
6. **Request Examples**: Ask for examples if you're trying to understand how to use a particular feature or API
|
|
315
|
+
7. **Use Multiple Queries**: If you don't find what you're looking for, try reformulating your question
|
|
316
|
+
8. **Combine with CLI**: Use the AI chat for exploration and understanding, then switch to the CLI for specific searches
|
|
317
|
+
|
|
318
|
+
## ProbeAgent SDK {#probeagent-sdk}
|
|
319
|
+
|
|
320
|
+
### Overview {#probeagent-overview}
|
|
321
|
+
|
|
322
|
+
The ProbeAgent SDK provides a powerful programmatic interface for building AI-powered code analysis applications. Unlike the basic Node.js SDK which focuses on search/query/extract operations, ProbeAgent offers a complete AI conversation system with persistent sessions, advanced mermaid diagram validation, and intelligent code understanding.
|
|
323
|
+
|
|
324
|
+
Key Features:
|
|
325
|
+
|
|
326
|
+
- **Full AI Conversation System**: Multi-turn conversations with persistent history
|
|
327
|
+
- **Session Management**: Isolated conversation sessions with unique IDs
|
|
328
|
+
- **Multiple AI Providers**: Support for Anthropic, OpenAI, and Google models
|
|
329
|
+
- **Code Modification**: Optional edit capabilities with `allowEdit` flag
|
|
330
|
+
- **Structured Output**: JSON schema validation and automatic mermaid diagram fixing
|
|
331
|
+
- **Event System**: Real-time monitoring of tool execution
|
|
332
|
+
- **Custom Personas**: Predefined expert roles (architect, code-review, engineer, support)
|
|
333
|
+
- **Token Usage Tracking**: Monitor API usage and costs
|
|
334
|
+
|
|
335
|
+
### Installation {#probeagent-installation}
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
npm install @probelabs/probe
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Quick Start {#probeagent-quick-start}
|
|
342
|
+
|
|
343
|
+
```javascript
|
|
344
|
+
import { ProbeAgent } from '@probelabs/probe';
|
|
345
|
+
|
|
346
|
+
// Create agent instance
|
|
347
|
+
const agent = new ProbeAgent({
|
|
348
|
+
path: '/path/to/your/codebase',
|
|
349
|
+
provider: 'anthropic', // or 'openai', 'google'
|
|
350
|
+
promptType: 'code-explorer', // or 'architect', 'code-review', 'engineer', 'support'
|
|
351
|
+
allowEdit: false, // set to true for code modification
|
|
352
|
+
debug: true
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Ask questions about your code
|
|
356
|
+
const response = await agent.answer('How does the authentication system work?');
|
|
357
|
+
console.log(response);
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### API Reference {#probeagent-api}
|
|
361
|
+
|
|
362
|
+
#### Constructor Options
|
|
363
|
+
|
|
364
|
+
| Parameter | Type | Default | Description |
|
|
365
|
+
|-----------|------|---------|-------------|
|
|
366
|
+
| `sessionId` | `string` | `randomUUID()` | Unique session identifier |
|
|
367
|
+
| `path` | `string` | `process.cwd()` | Search directory path |
|
|
368
|
+
| `provider` | `string` | auto-detect | AI provider: 'anthropic', 'openai', 'google' |
|
|
369
|
+
| `model` | `string` | provider default | Model name override |
|
|
370
|
+
| `allowEdit` | `boolean` | `false` | Enable code modification capabilities |
|
|
371
|
+
| `promptType` | `string` | `'code-explorer'` | Persona: 'code-explorer', 'architect', 'code-review', 'engineer', 'support', 'code-review-template' |
|
|
372
|
+
| `customPrompt` | `string` | `null` | Custom system prompt (overrides promptType) |
|
|
373
|
+
| `debug` | `boolean` | `false` | Enable debug logging |
|
|
374
|
+
| `maxIterations` | `number` | `30` | Maximum tool iterations (configurable via MAX_TOOL_ITERATIONS env var) |
|
|
375
|
+
|
|
376
|
+
#### Methods
|
|
377
|
+
|
|
378
|
+
**`agent.answer(message, images?, schemaOrOptions?)`**
|
|
379
|
+
|
|
380
|
+
Main method for asking questions about your codebase. Supports automatic schema validation and formatting.
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
// Basic usage
|
|
384
|
+
const response = await agent.answer('Explain the database connection logic');
|
|
385
|
+
|
|
386
|
+
// With images (multimodal)
|
|
387
|
+
const response = await agent.answer(
|
|
388
|
+
'Analyze this architecture diagram',
|
|
389
|
+
[imageBase64OrUrl]
|
|
390
|
+
);
|
|
391
|
+
|
|
392
|
+
// With schema for structured output (string format - backwards compatible)
|
|
393
|
+
const response = await agent.answer(
|
|
394
|
+
'List all functions',
|
|
395
|
+
[],
|
|
396
|
+
'{"functions": [{"name": "string", "file": "string"}]}'
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
// With schema in options object (recommended)
|
|
400
|
+
const response = await agent.answer(
|
|
401
|
+
'List all functions',
|
|
402
|
+
[],
|
|
403
|
+
{
|
|
404
|
+
schema: '{"functions": [{"name": "string", "file": "string"}]}',
|
|
405
|
+
// Other options can be added here
|
|
406
|
+
}
|
|
407
|
+
);
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
**Schema Validation Features:**
|
|
411
|
+
- Automatic response formatting according to provided schema
|
|
412
|
+
- JSON schema validation with automatic error correction
|
|
413
|
+
- Mermaid diagram validation and fixing
|
|
414
|
+
- Clean response output (removes code blocks and formatting artifacts)
|
|
415
|
+
- Backwards compatible with string schema parameter
|
|
416
|
+
|
|
417
|
+
**`agent.getTokenUsage()`**
|
|
418
|
+
|
|
419
|
+
Get token usage statistics for the current session.
|
|
420
|
+
|
|
421
|
+
```javascript
|
|
422
|
+
const usage = agent.getTokenUsage();
|
|
423
|
+
console.log(`Total tokens: ${usage.totalTokens}`);
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
**`agent.cancel()`**
|
|
427
|
+
|
|
428
|
+
Cancel any ongoing operations.
|
|
429
|
+
|
|
430
|
+
```javascript
|
|
431
|
+
agent.cancel();
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
### Usage Examples {#probeagent-examples}
|
|
435
|
+
|
|
436
|
+
#### Basic Code Analysis
|
|
437
|
+
|
|
438
|
+
```javascript
|
|
439
|
+
import { ProbeAgent } from '@probelabs/probe';
|
|
440
|
+
|
|
441
|
+
const agent = new ProbeAgent({
|
|
442
|
+
path: './my-project',
|
|
443
|
+
provider: 'anthropic'
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// Ask about architecture
|
|
447
|
+
const architecture = await agent.answer('Describe the overall architecture of this codebase');
|
|
448
|
+
|
|
449
|
+
// Find specific functionality
|
|
450
|
+
const auth = await agent.answer('How is user authentication implemented?');
|
|
451
|
+
|
|
452
|
+
// Code review
|
|
453
|
+
const issues = await agent.answer('Are there any potential security issues?');
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
#### Using Different Personas
|
|
457
|
+
|
|
458
|
+
```javascript
|
|
459
|
+
// Code review specialist
|
|
460
|
+
const reviewer = new ProbeAgent({
|
|
461
|
+
path: './my-project',
|
|
462
|
+
promptType: 'code-review'
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
const review = await reviewer.answer('Review this codebase for bugs and improvements');
|
|
466
|
+
|
|
467
|
+
// Software architect
|
|
468
|
+
const architect = new ProbeAgent({
|
|
469
|
+
path: './my-project',
|
|
470
|
+
promptType: 'architect'
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
const design = await architect.answer('Suggest improvements to the system architecture');
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
#### Structured Output with Schemas
|
|
477
|
+
|
|
478
|
+
```javascript
|
|
479
|
+
const agent = new ProbeAgent({ path: './my-project' });
|
|
480
|
+
|
|
481
|
+
// Get structured JSON response
|
|
482
|
+
const functions = await agent.answer(
|
|
483
|
+
'List all public functions in the codebase',
|
|
484
|
+
[],
|
|
485
|
+
{
|
|
486
|
+
schema: JSON.stringify({
|
|
487
|
+
functions: [
|
|
488
|
+
{
|
|
489
|
+
name: 'string',
|
|
490
|
+
file: 'string',
|
|
491
|
+
parameters: ['string'],
|
|
492
|
+
description: 'string'
|
|
493
|
+
}
|
|
494
|
+
]
|
|
495
|
+
})
|
|
496
|
+
}
|
|
497
|
+
);
|
|
498
|
+
|
|
499
|
+
// Response is automatically validated and corrected if needed
|
|
500
|
+
const functionList = JSON.parse(functions);
|
|
501
|
+
|
|
502
|
+
// Example with automatic JSON error correction
|
|
503
|
+
const apiEndpoints = await agent.answer(
|
|
504
|
+
'List all API endpoints with their methods',
|
|
505
|
+
[],
|
|
506
|
+
{
|
|
507
|
+
schema: JSON.stringify({
|
|
508
|
+
endpoints: [
|
|
509
|
+
{
|
|
510
|
+
path: 'string',
|
|
511
|
+
method: 'string',
|
|
512
|
+
handler: 'string',
|
|
513
|
+
file: 'string'
|
|
514
|
+
}
|
|
515
|
+
]
|
|
516
|
+
})
|
|
517
|
+
}
|
|
518
|
+
);
|
|
519
|
+
// ProbeAgent will automatically fix any JSON formatting issues
|
|
520
|
+
const endpoints = JSON.parse(apiEndpoints);
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
#### Multi-turn Conversations
|
|
524
|
+
|
|
525
|
+
```javascript
|
|
526
|
+
const agent = new ProbeAgent({ path: './my-project' });
|
|
527
|
+
|
|
528
|
+
// First question
|
|
529
|
+
await agent.answer('What does the User model look like?');
|
|
530
|
+
|
|
531
|
+
// Follow-up (agent remembers context)
|
|
532
|
+
await agent.answer('How is the User model used in the authentication system?');
|
|
533
|
+
|
|
534
|
+
// Another follow-up
|
|
535
|
+
await agent.answer('Are there any potential issues with this approach?');
|
|
536
|
+
|
|
537
|
+
// Check conversation history
|
|
538
|
+
console.log(`Conversation has ${agent.history.length} messages`);
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
#### Event Monitoring
|
|
542
|
+
|
|
543
|
+
```javascript
|
|
544
|
+
const agent = new ProbeAgent({
|
|
545
|
+
path: './my-project',
|
|
546
|
+
debug: true
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// Listen to tool call events
|
|
550
|
+
agent.events.on('toolCall', (event) => {
|
|
551
|
+
console.log(`Tool ${event.name} ${event.status}: ${event.description}`);
|
|
552
|
+
});
|
|
553
|
+
|
|
554
|
+
await agent.answer('Search for all API endpoints');
|
|
555
|
+
```
|
|
556
|
+
|
|
557
|
+
#### Code Modification (Advanced)
|
|
558
|
+
|
|
559
|
+
```javascript
|
|
560
|
+
const agent = new ProbeAgent({
|
|
561
|
+
path: './my-project',
|
|
562
|
+
allowEdit: true, // Enable code modification
|
|
563
|
+
promptType: 'engineer'
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
// Agent can now modify code files
|
|
567
|
+
await agent.answer('Add input validation to the user registration endpoint');
|
|
568
|
+
await agent.answer('Refactor the database connection code to use connection pooling');
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
#### Session Management
|
|
572
|
+
|
|
573
|
+
```javascript
|
|
574
|
+
import { ProbeAgent } from '@probelabs/probe';
|
|
575
|
+
|
|
576
|
+
class CodeAnalyzer {
|
|
577
|
+
constructor(projectPath) {
|
|
578
|
+
this.agent = new ProbeAgent({
|
|
579
|
+
sessionId: `analyzer-${Date.now()}`,
|
|
580
|
+
path: projectPath,
|
|
581
|
+
promptType: 'architect',
|
|
582
|
+
debug: process.env.NODE_ENV === 'development'
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
async analyzeFeature(featureName) {
|
|
587
|
+
return await this.agent.answer(`Analyze the ${featureName} feature implementation`);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
async suggestImprovements() {
|
|
591
|
+
return await this.agent.answer('What improvements would you suggest for this codebase?');
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
getUsage() {
|
|
595
|
+
return this.agent.getTokenUsage();
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// Usage
|
|
600
|
+
const analyzer = new CodeAnalyzer('./my-project');
|
|
601
|
+
const analysis = await analyzer.analyzeFeature('authentication');
|
|
602
|
+
const improvements = await analyzer.suggestImprovements();
|
|
603
|
+
const usage = analyzer.getUsage();
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
### Advanced Features {#probeagent-advanced}
|
|
607
|
+
|
|
608
|
+
#### Mermaid Diagram Generation and Validation
|
|
609
|
+
|
|
610
|
+
ProbeAgent includes comprehensive Mermaid diagram validation and automatic fixing capabilities:
|
|
611
|
+
|
|
612
|
+
```javascript
|
|
613
|
+
const agent = new ProbeAgent({ path: './my-project' });
|
|
614
|
+
|
|
615
|
+
// Generate a Mermaid diagram with automatic validation
|
|
616
|
+
const diagram = await agent.answer(
|
|
617
|
+
'Create a mermaid diagram showing the system architecture',
|
|
618
|
+
[],
|
|
619
|
+
{ schema: 'Generate response with mermaid diagram in code blocks' }
|
|
620
|
+
);
|
|
621
|
+
// Automatically validates and fixes mermaid syntax errors!
|
|
622
|
+
|
|
623
|
+
// Example: Architecture diagram with automatic fixing
|
|
624
|
+
const architectureDiagram = await agent.answer(
|
|
625
|
+
'Create a detailed mermaid flowchart of the authentication flow',
|
|
626
|
+
[],
|
|
627
|
+
{
|
|
628
|
+
schema: JSON.stringify({
|
|
629
|
+
diagram: 'string', // Mermaid diagram code
|
|
630
|
+
description: 'string'
|
|
631
|
+
})
|
|
632
|
+
}
|
|
633
|
+
);
|
|
634
|
+
|
|
635
|
+
// Example: Class diagram with validation
|
|
636
|
+
const classDiagram = await agent.answer(
|
|
637
|
+
'Generate a mermaid class diagram for the User model and its relationships',
|
|
638
|
+
[],
|
|
639
|
+
{ schema: 'Provide the response with a valid mermaid class diagram' }
|
|
640
|
+
);
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
**Mermaid Validation Features:**
|
|
644
|
+
- **Automatic Syntax Validation**: Validates Mermaid diagram syntax using the official Mermaid CLI
|
|
645
|
+
- **Error Detection**: Identifies syntax errors, missing nodes, invalid relationships
|
|
646
|
+
- **Automatic Fixing**: Uses AI to automatically correct syntax errors
|
|
647
|
+
- **Multiple Diagram Support**: Can validate and fix multiple diagrams in a single response
|
|
648
|
+
- **Diagram Types Supported**: flowchart, sequence, class, state, entity-relationship, gantt, pie, git, journey, and more
|
|
649
|
+
- **Preserves Content**: Maintains the original diagram intent while fixing syntax issues
|
|
650
|
+
|
|
651
|
+
#### Integration with Web Frameworks
|
|
652
|
+
|
|
653
|
+
```javascript
|
|
654
|
+
// Express.js integration example
|
|
655
|
+
app.post('/analyze', async (req, res) => {
|
|
656
|
+
const agent = new ProbeAgent({
|
|
657
|
+
path: req.body.projectPath,
|
|
658
|
+
sessionId: req.session.id
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
try {
|
|
662
|
+
const result = await agent.answer(req.body.question);
|
|
663
|
+
res.json({ response: result, usage: agent.getTokenUsage() });
|
|
664
|
+
} catch (error) {
|
|
665
|
+
res.status(500).json({ error: error.message });
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
#### Environment Variables
|
|
671
|
+
|
|
672
|
+
Set these environment variables for API access:
|
|
673
|
+
|
|
674
|
+
```bash
|
|
675
|
+
# Anthropic Claude (recommended)
|
|
676
|
+
export ANTHROPIC_API_KEY="your-key-here"
|
|
677
|
+
|
|
678
|
+
# OpenAI GPT
|
|
679
|
+
export OPENAI_API_KEY="your-key-here"
|
|
680
|
+
|
|
681
|
+
# Google Gemini
|
|
682
|
+
export GOOGLE_API_KEY="your-key-here"
|
|
683
|
+
|
|
684
|
+
# Force specific provider (optional)
|
|
685
|
+
export FORCE_PROVIDER="anthropic"
|
|
686
|
+
|
|
687
|
+
# Override model (optional)
|
|
688
|
+
export MODEL_NAME="claude-3-opus-20240229"
|
|
689
|
+
|
|
690
|
+
# Enable debug mode (optional)
|
|
691
|
+
export DEBUG=1
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
### Comparison with ProbeChat {#probeagent-vs-probechat}
|
|
695
|
+
|
|
696
|
+
| Feature | ProbeAgent | ProbeChat |
|
|
697
|
+
|---------|------------|-----------|
|
|
698
|
+
| **Purpose** | Full SDK for building AI apps | Simple chat interface |
|
|
699
|
+
| **Session Management** | Advanced with persistent history | Basic conversation |
|
|
700
|
+
| **Code Modification** | Supports `allowEdit` flag | Read-only |
|
|
701
|
+
| **Custom Personas** | 6+ predefined personas (including code-review-template) | Limited customization |
|
|
702
|
+
| **Structured Output** | Full JSON schema validation with auto-correction | Basic responses |
|
|
703
|
+
| **Event System** | Real-time tool monitoring | None |
|
|
704
|
+
| **Mermaid Validation** | Advanced validation & automatic fixing | Basic support |
|
|
705
|
+
| **Schema Handling** | Automatic formatting, validation, and error correction | None |
|
|
706
|
+
| **JSON Validation** | Automatic detection and correction of malformed JSON | None |
|
|
707
|
+
| **Max Iterations** | Configurable (default 30, via MAX_TOOL_ITERATIONS env) | Fixed |
|
|
708
|
+
| **Use Case** | Building AI applications with structured outputs | Interactive exploration |
|
|
709
|
+
|
|
710
|
+
Use **ProbeAgent** when you want to build sophisticated AI-powered code analysis tools with structured outputs, and **ProbeChat** when you need a simple chat interface for code exploration.
|
|
711
|
+
|
|
712
|
+
## MCP Server Integration {#mcp-server-integration}
|
|
713
|
+
|
|
714
|
+
### Overview {#mcp-overview}
|
|
715
|
+
|
|
716
|
+
The Model Context Protocol (MCP) server mode allows Probe to integrate seamlessly with AI editors and assistants. This mode exposes Probe's powerful search capabilities through a standardized interface that AI tools can use to search and understand your codebase.
|
|
717
|
+
|
|
718
|
+
Key benefits:
|
|
719
|
+
|
|
720
|
+
- **Seamless AI Integration**: Allows AI assistants to search and analyze your code
|
|
721
|
+
- **Standardized Protocol**: Uses the Model Context Protocol for compatibility with various AI tools
|
|
722
|
+
- **Enhanced AI Capabilities**: Gives AI assistants code-aware capabilities
|
|
723
|
+
- **Secure Access**: Provides controlled access to your codebase
|
|
724
|
+
|
|
725
|
+
### Setting Up the MCP Server {#setting-up-the-mcp-server}
|
|
726
|
+
|
|
727
|
+
#### Using NPX (Recommended)
|
|
728
|
+
|
|
729
|
+
The easiest way to use Probe's MCP server is through NPX:
|
|
730
|
+
|
|
731
|
+
```json
|
|
732
|
+
{
|
|
733
|
+
"mcpServers": {
|
|
734
|
+
"probe": {
|
|
735
|
+
"command": "npx",
|
|
736
|
+
"args": [
|
|
737
|
+
"-y",
|
|
738
|
+
"@probelabs/probe@latest"
|
|
739
|
+
]
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
Add this configuration to your AI editor's MCP configuration file. The exact location depends on your editor, but common locations include:
|
|
746
|
+
|
|
747
|
+
- For Cline: `.cline/mcp_config.json` in your project directory
|
|
748
|
+
- For other editors: Check your editor's documentation for MCP configuration
|
|
749
|
+
|
|
750
|
+
#### Manual Installation
|
|
751
|
+
|
|
752
|
+
If you prefer to install the MCP server manually:
|
|
753
|
+
|
|
754
|
+
1. Install the NPM package globally:
|
|
755
|
+
```bash
|
|
756
|
+
npm install -g @probelabs/probe@latest
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
2. Configure your AI editor to use the installed package:
|
|
760
|
+
```json
|
|
761
|
+
{
|
|
762
|
+
"mcpServers": {
|
|
763
|
+
"probe": {
|
|
764
|
+
"command": "probe", "args": ["mcp"]
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
```
|
|
769
|
+
|
|
770
|
+
#### Technical Implementation
|
|
771
|
+
|
|
772
|
+
The Probe MCP server:
|
|
773
|
+
|
|
774
|
+
- Implements the Model Context Protocol specification
|
|
775
|
+
- Uses stdio for communication with AI editors
|
|
776
|
+
- Automatically downloads and manages the Probe binary
|
|
777
|
+
- Provides three main tools: search_code, query_code, and extract_code
|
|
778
|
+
- Handles tool execution and error reporting
|
|
779
|
+
|
|
780
|
+
### Available Tools {#available-tools}
|
|
781
|
+
|
|
782
|
+
The Probe MCP server provides the following tools:
|
|
783
|
+
|
|
784
|
+
#### search_code
|
|
785
|
+
|
|
786
|
+
Search code in a specified directory using Elasticsearch-like query syntax with session-based caching.
|
|
787
|
+
|
|
788
|
+
```json
|
|
789
|
+
{
|
|
790
|
+
"path": "/path/to/your/project",
|
|
791
|
+
"query": "authentication flow",
|
|
792
|
+
"maxTokens": 20000
|
|
793
|
+
}
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
The search tool supports Elasticsearch-like query syntax with the following features:
|
|
797
|
+
- Basic term searching: "config" or "search"
|
|
798
|
+
- Field-specific searching: "field:value" (e.g., "function:parse")
|
|
799
|
+
- Required terms with + prefix: "+required"
|
|
800
|
+
- Excluded terms with - prefix: "-excluded"
|
|
801
|
+
- Logical operators: "term1 AND term2", "term1 OR term2"
|
|
802
|
+
- Grouping with parentheses: "(term1 OR term2) AND term3"
|
|
803
|
+
|
|
804
|
+
#### query_code
|
|
805
|
+
|
|
806
|
+
Find specific code structures (functions, classes, etc.) using tree-sitter patterns.
|
|
807
|
+
|
|
808
|
+
```json
|
|
809
|
+
{
|
|
810
|
+
"path": "/path/to/your/project",
|
|
811
|
+
"pattern": "fn $NAME($$$PARAMS) $$$BODY",
|
|
812
|
+
"language": "rust"
|
|
813
|
+
}
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
Pattern syntax:
|
|
817
|
+
- `$NAME`: Matches an identifier (e.g., function name)
|
|
818
|
+
- `$$$PARAMS`: Matches parameter lists
|
|
819
|
+
- `$$$BODY`: Matches function bodies
|
|
820
|
+
- `$$$FIELDS`: Matches struct/class fields
|
|
821
|
+
- `$$$METHODS`: Matches class methods
|
|
822
|
+
|
|
823
|
+
#### extract_code
|
|
824
|
+
|
|
825
|
+
Extract code blocks from files based on file paths and optional line numbers.
|
|
826
|
+
|
|
827
|
+
```json
|
|
828
|
+
{
|
|
829
|
+
"path": "/path/to/your/project",
|
|
830
|
+
"files": ["/path/to/your/project/src/main.rs:42"]
|
|
831
|
+
}
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
### Integration with AI Assistants {#integration-with-ai-assistants}
|
|
835
|
+
|
|
836
|
+
Once configured, you can ask your AI assistant to search your codebase with natural language queries. The AI will translate your request into appropriate Probe commands and display the results.
|
|
837
|
+
|
|
838
|
+
#### Example Queries
|
|
839
|
+
|
|
840
|
+
Here are some examples of natural language queries you can use:
|
|
841
|
+
|
|
842
|
+
- "Do the probe and search my codebase for implementations of the ranking algorithm"
|
|
843
|
+
- "Using probe find all functions related to error handling in the src directory"
|
|
844
|
+
- "Search for code that handles user authentication"
|
|
845
|
+
- "Find all instances where we're using the BM25 algorithm"
|
|
846
|
+
- "Look for functions that process query parameters"
|
|
847
|
+
|
|
848
|
+
#### How It Works
|
|
849
|
+
|
|
850
|
+
1. You ask a question about your codebase to your AI assistant
|
|
851
|
+
2. The AI assistant recognizes that Probe can help answer this question
|
|
852
|
+
3. The assistant formulates an appropriate search query and parameters
|
|
853
|
+
4. The MCP server executes the Probe search command
|
|
854
|
+
5. The results are returned to the AI assistant
|
|
855
|
+
6. The assistant analyzes the code and provides you with an answer
|
|
856
|
+
|
|
857
|
+
#### Technical Details
|
|
858
|
+
|
|
859
|
+
The MCP server:
|
|
860
|
+
|
|
861
|
+
- Receives tool call requests from the AI assistant
|
|
862
|
+
- Parses the request parameters
|
|
863
|
+
- Executes the appropriate Probe command
|
|
864
|
+
- Returns the results to the AI assistant
|
|
865
|
+
- Handles errors and provides appropriate error messages
|
|
866
|
+
- Maintains session-based caching to avoid duplicate results
|
|
867
|
+
|
|
868
|
+
### Advanced Configuration {#advanced-configuration}
|
|
869
|
+
|
|
870
|
+
#### Custom Search Paths
|
|
871
|
+
|
|
872
|
+
You can configure the MCP server to search specific directories by default:
|
|
873
|
+
|
|
874
|
+
```json
|
|
875
|
+
{
|
|
876
|
+
"mcpServers": {
|
|
877
|
+
"probe": {
|
|
878
|
+
"command": "npx",
|
|
879
|
+
"args": [
|
|
880
|
+
"-y",
|
|
881
|
+
"@probelabs/probe@latest"
|
|
882
|
+
],
|
|
883
|
+
"env": {
|
|
884
|
+
"PROBE_DEFAULT_PATHS": "/path/to/project1,/path/to/project2"
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
```
|
|
890
|
+
|
|
891
|
+
#### Limiting Results
|
|
892
|
+
|
|
893
|
+
You can set default limits for search results:
|
|
894
|
+
|
|
895
|
+
```json
|
|
896
|
+
{
|
|
897
|
+
"mcpServers": {
|
|
898
|
+
"probe": {
|
|
899
|
+
"command": "npx",
|
|
900
|
+
"args": [
|
|
901
|
+
"-y",
|
|
902
|
+
"@probelabs/probe@latest"
|
|
903
|
+
],
|
|
904
|
+
"env": {
|
|
905
|
+
"PROBE_MAX_TOKENS": "20000"
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
#### Custom Binary Path
|
|
913
|
+
|
|
914
|
+
If you have a custom build of the Probe binary, you can specify its path:
|
|
915
|
+
|
|
916
|
+
```json
|
|
917
|
+
{
|
|
918
|
+
"mcpServers": {
|
|
919
|
+
"probe": {
|
|
920
|
+
"command": "npx",
|
|
921
|
+
"args": [
|
|
922
|
+
"-y",
|
|
923
|
+
"@probelabs/probe@latest"
|
|
924
|
+
],
|
|
925
|
+
"env": {
|
|
926
|
+
"PROBE_PATH": "/path/to/custom/probe"
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
#### Debug Mode
|
|
934
|
+
|
|
935
|
+
Enable debug mode for detailed logging:
|
|
936
|
+
|
|
937
|
+
```json
|
|
938
|
+
{
|
|
939
|
+
"mcpServers": {
|
|
940
|
+
"probe": {
|
|
941
|
+
"command": "npx",
|
|
942
|
+
"args": [
|
|
943
|
+
"-y",
|
|
944
|
+
"@probelabs/probe@latest"
|
|
945
|
+
],
|
|
946
|
+
"env": {
|
|
947
|
+
"DEBUG": "1"
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
### Troubleshooting {#troubleshooting}
|
|
955
|
+
|
|
956
|
+
If you encounter issues with the MCP server:
|
|
957
|
+
|
|
958
|
+
1. **Check Installation**: Ensure the Probe binary was downloaded correctly during package installation
|
|
959
|
+
2. **Verify Configuration**: Double-check your MCP configuration file for errors
|
|
960
|
+
3. **Check Permissions**: Make sure the AI editor has permission to execute the MCP server
|
|
961
|
+
4. **Check Logs**: Look for error messages in your AI editor's logs
|
|
962
|
+
5. **Update Packages**: Ensure you're using the latest version of the `@probelabs/probe@latest` package
|
|
963
|
+
6. **Manual Binary Download**: If the automatic download failed, you can manually download the binary from [GitHub Releases](https://github.com/probelabs/probe/releases) and place it in the `node_modules/@probelabs/probe/bin` directory
|
|
964
|
+
|
|
965
|
+
#### Common Issues and Solutions
|
|
966
|
+
|
|
967
|
+
| Issue | Solution |
|
|
968
|
+
|-------|----------|
|
|
969
|
+
| "Binary not found" error | Set the `PROBE_PATH` environment variable to the location of your Probe binary |
|
|
970
|
+
| "Permission denied" error | Make sure the binary is executable (`chmod +x /path/to/probe`) |
|
|
971
|
+
| Tool calls timeout | Increase the timeout value in your AI editor's configuration |
|
|
972
|
+
| Empty search results | Check your query syntax and try a simpler query |
|
|
973
|
+
| "Network error" during binary download | Check your internet connection and firewall settings |
|
|
974
|
+
|
|
975
|
+
## Node.js SDK {#nodejs-sdk}
|
|
976
|
+
|
|
977
|
+
### Overview {#sdk-overview}
|
|
978
|
+
|
|
979
|
+
The Node.js SDK provides programmatic access to Probe's powerful code search capabilities. It allows you to integrate Probe into your Node.js applications, build custom tools, and create AI-powered code assistants.
|
|
980
|
+
|
|
981
|
+
Key benefits:
|
|
982
|
+
|
|
983
|
+
- **Programmatic Access**: Use Probe's capabilities directly from your Node.js code
|
|
984
|
+
- **AI Integration**: Ready-to-use tools for Vercel AI SDK, LangChain, and other AI frameworks
|
|
985
|
+
- **Cross-Platform**: Works on Windows, macOS, and Linux
|
|
986
|
+
- **Automatic Binary Management**: Handles downloading and managing the Probe binary
|
|
987
|
+
- **Type Safety**: Includes TypeScript type definitions
|
|
988
|
+
|
|
989
|
+
### Installation {#sdk-installation}
|
|
990
|
+
|
|
991
|
+
#### Local Installation
|
|
992
|
+
|
|
993
|
+
```bash
|
|
994
|
+
npm install @probelabs/probe@latest
|
|
995
|
+
```
|
|
996
|
+
|
|
997
|
+
#### Global Installation
|
|
998
|
+
|
|
999
|
+
```bash
|
|
1000
|
+
npm install -g @probelabs/probe@latest
|
|
1001
|
+
```
|
|
1002
|
+
|
|
1003
|
+
During installation, the package will automatically download the appropriate probe binary for your platform.
|
|
1004
|
+
|
|
1005
|
+
### Core Functions {#core-functions}
|
|
1006
|
+
|
|
1007
|
+
The SDK provides three main functions:
|
|
1008
|
+
|
|
1009
|
+
#### search
|
|
1010
|
+
|
|
1011
|
+
Search for patterns in your codebase using Elasticsearch-like query syntax.
|
|
1012
|
+
|
|
1013
|
+
```javascript
|
|
1014
|
+
import { search } from '@probelabs/probe';
|
|
1015
|
+
|
|
1016
|
+
const searchResults = await search({
|
|
1017
|
+
path: '/path/to/your/project',
|
|
1018
|
+
query: 'function',
|
|
1019
|
+
maxResults: 10
|
|
1020
|
+
});
|
|
1021
|
+
```
|
|
1022
|
+
|
|
1023
|
+
#### query
|
|
1024
|
+
|
|
1025
|
+
Find specific code structures using tree-sitter patterns.
|
|
1026
|
+
|
|
1027
|
+
```javascript
|
|
1028
|
+
import { query } from '@probelabs/probe';
|
|
1029
|
+
|
|
1030
|
+
const queryResults = await query({
|
|
1031
|
+
path: '/path/to/your/project',
|
|
1032
|
+
pattern: 'function $NAME($$$PARAMS) $$$BODY',
|
|
1033
|
+
language: 'javascript'
|
|
1034
|
+
});
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
#### extract
|
|
1038
|
+
|
|
1039
|
+
Extract code blocks from files based on file paths and line numbers.
|
|
1040
|
+
|
|
1041
|
+
```javascript
|
|
1042
|
+
import { extract } from '@probelabs/probe';
|
|
1043
|
+
|
|
1044
|
+
const extractResults = await extract({
|
|
1045
|
+
files: ['/path/to/your/project/src/main.js:42']
|
|
1046
|
+
});
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
### AI Tools Integration {#ai-tools-integration}
|
|
1050
|
+
|
|
1051
|
+
The SDK provides built-in tools for integrating with AI frameworks:
|
|
1052
|
+
|
|
1053
|
+
#### Vercel AI SDK Integration
|
|
1054
|
+
|
|
1055
|
+
```javascript
|
|
1056
|
+
import { generateText } from 'ai';
|
|
1057
|
+
import { tools } from '@probelabs/probe';
|
|
1058
|
+
|
|
1059
|
+
// Use the pre-built tools with Vercel AI SDK
|
|
1060
|
+
async function chatWithAI(userMessage) {
|
|
1061
|
+
const result = await generateText({
|
|
1062
|
+
model: provider(modelName),
|
|
1063
|
+
messages: [{ role: 'user', content: userMessage }],
|
|
1064
|
+
system: "You are a code intelligence assistant. Use the provided tools to search and analyze code.",
|
|
1065
|
+
tools: {
|
|
1066
|
+
search: tools.searchTool,
|
|
1067
|
+
query: tools.queryTool,
|
|
1068
|
+
extract: tools.extractTool
|
|
1069
|
+
},
|
|
1070
|
+
maxSteps: 15,
|
|
1071
|
+
temperature: 0.7
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
return result.text;
|
|
1075
|
+
}
|
|
1076
|
+
```
|
|
1077
|
+
|
|
1078
|
+
#### LangChain Integration
|
|
1079
|
+
|
|
1080
|
+
```javascript
|
|
1081
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
1082
|
+
import { tools } from '@probelabs/probe';
|
|
1083
|
+
|
|
1084
|
+
// Create the LangChain tools
|
|
1085
|
+
const searchTool = tools.createSearchTool();
|
|
1086
|
+
const queryTool = tools.createQueryTool();
|
|
1087
|
+
const extractTool = tools.createExtractTool();
|
|
1088
|
+
|
|
1089
|
+
// Create a ChatOpenAI instance with tools
|
|
1090
|
+
const model = new ChatOpenAI({
|
|
1091
|
+
modelName: "gpt-4o",
|
|
1092
|
+
temperature: 0.7
|
|
1093
|
+
}).withTools([searchTool, queryTool, extractTool]);
|
|
1094
|
+
|
|
1095
|
+
// Use the model with tools
|
|
1096
|
+
async function chatWithAI(userMessage) {
|
|
1097
|
+
const result = await model.invoke([
|
|
1098
|
+
{ role: "system", content: "You are a code intelligence assistant. Use the provided tools to search and analyze code." },
|
|
1099
|
+
{ role: "user", content: userMessage }
|
|
1100
|
+
]);
|
|
1101
|
+
|
|
1102
|
+
return result.content;
|
|
1103
|
+
}
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
#### Default System Message
|
|
1107
|
+
|
|
1108
|
+
The package provides a default system message that you can use with your AI assistants:
|
|
1109
|
+
|
|
1110
|
+
```javascript
|
|
1111
|
+
import { tools } from '@probelabs/probe';
|
|
1112
|
+
|
|
1113
|
+
// Use the default system message in your AI application
|
|
1114
|
+
const systemMessage = tools.DEFAULT_SYSTEM_MESSAGE;
|
|
1115
|
+
|
|
1116
|
+
// Example with Vercel AI SDK
|
|
1117
|
+
const result = await generateText({
|
|
1118
|
+
model: provider(modelName),
|
|
1119
|
+
messages: [{ role: 'user', content: userMessage }],
|
|
1120
|
+
system: tools.DEFAULT_SYSTEM_MESSAGE,
|
|
1121
|
+
tools: {
|
|
1122
|
+
search: tools.searchTool,
|
|
1123
|
+
query: tools.queryTool,
|
|
1124
|
+
extract: tools.extractTool
|
|
1125
|
+
}
|
|
1126
|
+
});
|
|
1127
|
+
```
|
|
1128
|
+
|
|
1129
|
+
### Examples {#examples}
|
|
1130
|
+
|
|
1131
|
+
#### Basic Search Example
|
|
1132
|
+
|
|
1133
|
+
```javascript
|
|
1134
|
+
import { search } from '@probelabs/probe';
|
|
1135
|
+
|
|
1136
|
+
async function basicSearchExample() {
|
|
1137
|
+
try {
|
|
1138
|
+
const results = await search({
|
|
1139
|
+
path: '/path/to/your/project',
|
|
1140
|
+
query: 'function',
|
|
1141
|
+
maxResults: 5
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
console.log('Search results:');
|
|
1145
|
+
console.log(results);
|
|
1146
|
+
} catch (error) {
|
|
1147
|
+
console.error('Search error:', error);
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
#### Advanced Search with Multiple Options
|
|
1153
|
+
|
|
1154
|
+
```javascript
|
|
1155
|
+
import { search } from '@probelabs/probe';
|
|
1156
|
+
|
|
1157
|
+
async function advancedSearchExample() {
|
|
1158
|
+
try {
|
|
1159
|
+
const results = await search({
|
|
1160
|
+
path: '/path/to/your/project',
|
|
1161
|
+
query: 'config AND (parse OR tokenize)',
|
|
1162
|
+
ignore: ['node_modules', 'dist'],
|
|
1163
|
+
reranker: 'hybrid',
|
|
1164
|
+
frequencySearch: true,
|
|
1165
|
+
maxResults: 10,
|
|
1166
|
+
maxTokens: 20000,
|
|
1167
|
+
allowTests: false
|
|
1168
|
+
});
|
|
1169
|
+
|
|
1170
|
+
console.log('Advanced search results:');
|
|
1171
|
+
console.log(results);
|
|
1172
|
+
} catch (error) {
|
|
1173
|
+
console.error('Advanced search error:', error);
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
```
|
|
1177
|
+
|
|
1178
|
+
#### Query for Specific Code Structures
|
|
1179
|
+
|
|
1180
|
+
```javascript
|
|
1181
|
+
import { query } from '@probelabs/probe';
|
|
1182
|
+
|
|
1183
|
+
async function queryExample() {
|
|
1184
|
+
try {
|
|
1185
|
+
// Find all JavaScript functions
|
|
1186
|
+
const jsResults = await query({
|
|
1187
|
+
path: '/path/to/your/project',
|
|
1188
|
+
pattern: 'function $NAME($$$PARAMS) $$$BODY',
|
|
1189
|
+
language: 'javascript',
|
|
1190
|
+
maxResults: 5
|
|
1191
|
+
});
|
|
1192
|
+
|
|
1193
|
+
console.log('JavaScript functions:');
|
|
1194
|
+
console.log(jsResults);
|
|
1195
|
+
|
|
1196
|
+
// Find all Rust structs
|
|
1197
|
+
const rustResults = await query({
|
|
1198
|
+
path: '/path/to/your/project',
|
|
1199
|
+
pattern: 'struct $NAME $$$BODY',
|
|
1200
|
+
language: 'rust',
|
|
1201
|
+
maxResults: 5
|
|
1202
|
+
});
|
|
1203
|
+
|
|
1204
|
+
console.log('Rust structs:');
|
|
1205
|
+
console.log(rustResults);
|
|
1206
|
+
} catch (error) {
|
|
1207
|
+
console.error('Query error:', error);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
```
|
|
1211
|
+
|
|
1212
|
+
#### Extract Code Blocks
|
|
1213
|
+
|
|
1214
|
+
```javascript
|
|
1215
|
+
import { extract } from '@probelabs/probe';
|
|
1216
|
+
|
|
1217
|
+
async function extractExample() {
|
|
1218
|
+
try {
|
|
1219
|
+
const results = await extract({
|
|
1220
|
+
files: [
|
|
1221
|
+
'/path/to/your/project/src/main.js',
|
|
1222
|
+
'/path/to/your/project/src/utils.js:42' // Extract from line 42
|
|
1223
|
+
],
|
|
1224
|
+
contextLines: 2,
|
|
1225
|
+
format: 'markdown'
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
console.log('Extracted code:');
|
|
1229
|
+
console.log(results);
|
|
1230
|
+
} catch (error) {
|
|
1231
|
+
console.error('Extract error:', error);
|
|
1232
|
+
}
|
|
1233
|
+
}
|
|
1234
|
+
```
|
|
1235
|
+
|
|
1236
|
+
#### Building a Custom AI Assistant
|
|
1237
|
+
|
|
1238
|
+
```javascript
|
|
1239
|
+
import { search, query, extract } from '@probelabs/probe';
|
|
1240
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
1241
|
+
import { PromptTemplate } from '@langchain/core/prompts';
|
|
1242
|
+
import { StringOutputParser } from '@langchain/core/output_parsers';
|
|
1243
|
+
|
|
1244
|
+
// Create a custom AI assistant that can search code
|
|
1245
|
+
async function createCodeAssistant() {
|
|
1246
|
+
// Create a chat model
|
|
1247
|
+
const model = new ChatOpenAI({
|
|
1248
|
+
modelName: "gpt-4o",
|
|
1249
|
+
temperature: 0.7
|
|
1250
|
+
});
|
|
1251
|
+
|
|
1252
|
+
// Create a prompt template
|
|
1253
|
+
const promptTemplate = PromptTemplate.fromTemplate(`
|
|
1254
|
+
You are a code assistant. I'll provide you with a question and some code search results.
|
|
1255
|
+
Please analyze the code and answer the question.
|
|
1256
|
+
|
|
1257
|
+
Question: {question}
|
|
1258
|
+
|
|
1259
|
+
Code search results:
|
|
1260
|
+
{searchResults}
|
|
1261
|
+
|
|
1262
|
+
Your analysis:
|
|
1263
|
+
`);
|
|
1264
|
+
|
|
1265
|
+
// Create a chain
|
|
1266
|
+
const chain = promptTemplate
|
|
1267
|
+
.pipe(model)
|
|
1268
|
+
.pipe(new StringOutputParser());
|
|
1269
|
+
|
|
1270
|
+
// Function to answer questions about code
|
|
1271
|
+
async function answerCodeQuestion(question, codebasePath) {
|
|
1272
|
+
// Search for relevant code
|
|
1273
|
+
const searchResults = await search({
|
|
1274
|
+
path: codebasePath,
|
|
1275
|
+
query: question,
|
|
1276
|
+
maxResults: 5,
|
|
1277
|
+
maxTokens: 10000
|
|
1278
|
+
});
|
|
1279
|
+
|
|
1280
|
+
// Get the answer from the AI
|
|
1281
|
+
const answer = await chain.invoke({
|
|
1282
|
+
question,
|
|
1283
|
+
searchResults
|
|
1284
|
+
});
|
|
1285
|
+
|
|
1286
|
+
return answer;
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
return { answerCodeQuestion };
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// Usage
|
|
1293
|
+
const assistant = await createCodeAssistant();
|
|
1294
|
+
const answer = await assistant.answerCodeQuestion(
|
|
1295
|
+
"How is authentication implemented?",
|
|
1296
|
+
"/path/to/your/project"
|
|
1297
|
+
);
|
|
1298
|
+
console.log(answer);
|
|
1299
|
+
```
|
|
1300
|
+
|
|
1301
|
+
### API Reference {#api-reference}
|
|
1302
|
+
|
|
1303
|
+
#### Search
|
|
1304
|
+
|
|
1305
|
+
```javascript
|
|
1306
|
+
import { search } from '@probelabs/probe';
|
|
1307
|
+
|
|
1308
|
+
const results = await search({
|
|
1309
|
+
path: '/path/to/your/project',
|
|
1310
|
+
query: 'function',
|
|
1311
|
+
// Optional parameters
|
|
1312
|
+
filesOnly: false,
|
|
1313
|
+
ignore: ['node_modules', 'dist'],
|
|
1314
|
+
excludeFilenames: false,
|
|
1315
|
+
reranker: 'hybrid',
|
|
1316
|
+
frequencySearch: true,
|
|
1317
|
+
exact: false,
|
|
1318
|
+
maxResults: 10,
|
|
1319
|
+
maxBytes: 1000000,
|
|
1320
|
+
maxTokens: 40000,
|
|
1321
|
+
allowTests: false,
|
|
1322
|
+
noMerge: false,
|
|
1323
|
+
mergeThreshold: 5,
|
|
1324
|
+
json: false,
|
|
1325
|
+
binaryOptions: {
|
|
1326
|
+
forceDownload: false,
|
|
1327
|
+
version: '1.0.0'
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
```
|
|
1331
|
+
|
|
1332
|
+
##### Parameters
|
|
1333
|
+
|
|
1334
|
+
- `path` (required): Path to search in
|
|
1335
|
+
- `query` (required): Search query or queries (string or array of strings)
|
|
1336
|
+
- `filesOnly`: Only output file paths
|
|
1337
|
+
- `ignore`: Patterns to ignore (array of strings)
|
|
1338
|
+
- `excludeFilenames`: Exclude filenames from search
|
|
1339
|
+
- `reranker`: Reranking method ('hybrid', 'hybrid2', 'bm25', 'tfidf')
|
|
1340
|
+
- `frequencySearch`: Use frequency-based search
|
|
1341
|
+
- `exact`: Use exact matching
|
|
1342
|
+
- `maxResults`: Maximum number of results
|
|
1343
|
+
- `maxBytes`: Maximum bytes to return
|
|
1344
|
+
- `maxTokens`: Maximum tokens to return
|
|
1345
|
+
- `allowTests`: Include test files
|
|
1346
|
+
- `noMerge`: Don't merge adjacent blocks
|
|
1347
|
+
- `mergeThreshold`: Merge threshold
|
|
1348
|
+
- `json`: Return results as parsed JSON instead of string
|
|
1349
|
+
- `binaryOptions`: Options for getting the binary
|
|
1350
|
+
- `forceDownload`: Force download even if binary exists
|
|
1351
|
+
- `version`: Specific version to download
|
|
1352
|
+
|
|
1353
|
+
#### Query
|
|
1354
|
+
|
|
1355
|
+
```javascript
|
|
1356
|
+
import { query } from '@probelabs/probe';
|
|
1357
|
+
|
|
1358
|
+
const results = await query({
|
|
1359
|
+
path: '/path/to/your/project',
|
|
1360
|
+
pattern: 'function $NAME($$$PARAMS) $$$BODY',
|
|
1361
|
+
// Optional parameters
|
|
1362
|
+
language: 'javascript',
|
|
1363
|
+
ignore: ['node_modules', 'dist'],
|
|
1364
|
+
allowTests: false,
|
|
1365
|
+
maxResults: 10,
|
|
1366
|
+
format: 'markdown',
|
|
1367
|
+
json: false,
|
|
1368
|
+
binaryOptions: {
|
|
1369
|
+
forceDownload: false,
|
|
1370
|
+
version: '1.0.0'
|
|
1371
|
+
}
|
|
1372
|
+
});
|
|
1373
|
+
```
|
|
1374
|
+
|
|
1375
|
+
##### Parameters
|
|
1376
|
+
|
|
1377
|
+
- `path` (required): Path to search in
|
|
1378
|
+
- `pattern` (required): The ast-grep pattern to search for
|
|
1379
|
+
- `language`: Programming language to search in
|
|
1380
|
+
- `ignore`: Patterns to ignore (array of strings)
|
|
1381
|
+
- `allowTests`: Include test files
|
|
1382
|
+
- `maxResults`: Maximum number of results
|
|
1383
|
+
- `format`: Output format ('markdown', 'plain', 'json', 'color')
|
|
1384
|
+
- `json`: Return results as parsed JSON instead of string
|
|
1385
|
+
- `binaryOptions`: Options for getting the binary
|
|
1386
|
+
- `forceDownload`: Force download even if binary exists
|
|
1387
|
+
- `version`: Specific version to download
|
|
1388
|
+
|
|
1389
|
+
#### Extract
|
|
1390
|
+
|
|
1391
|
+
```javascript
|
|
1392
|
+
import { extract } from '@probelabs/probe';
|
|
1393
|
+
|
|
1394
|
+
const results = await extract({
|
|
1395
|
+
files: [
|
|
1396
|
+
'/path/to/your/project/src/main.js',
|
|
1397
|
+
'/path/to/your/project/src/utils.js:42' // Extract from line 42
|
|
1398
|
+
],
|
|
1399
|
+
// Optional parameters
|
|
1400
|
+
allowTests: false,
|
|
1401
|
+
contextLines: 2,
|
|
1402
|
+
format: 'markdown',
|
|
1403
|
+
json: false,
|
|
1404
|
+
binaryOptions: {
|
|
1405
|
+
forceDownload: false,
|
|
1406
|
+
version: '1.0.0'
|
|
1407
|
+
}
|
|
1408
|
+
});
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
##### Parameters
|
|
1412
|
+
|
|
1413
|
+
- `files` (required): Files to extract from (can include line numbers with colon, e.g., "/path/to/file.rs:10")
|
|
1414
|
+
- `allowTests`: Include test files
|
|
1415
|
+
- `contextLines`: Number of context lines to include
|
|
1416
|
+
- `format`: Output format ('markdown', 'plain', 'json')
|
|
1417
|
+
- `prompt`: System prompt template for LLM models ('engineer', 'architect', or path to file)
|
|
1418
|
+
- `instructions`: User instructions for LLM models
|
|
1419
|
+
- `json`: Return results as parsed JSON instead of string
|
|
1420
|
+
- `binaryOptions`: Options for getting the binary
|
|
1421
|
+
- `forceDownload`: Force download even if binary exists
|
|
1422
|
+
- `version`: Specific version to download
|
|
1423
|
+
|
|
1424
|
+
#### LLM Integration with Extract
|
|
1425
|
+
|
|
1426
|
+
```javascript
|
|
1427
|
+
import { extract } from '@probelabs/probe';
|
|
1428
|
+
|
|
1429
|
+
// Extract code with engineer prompt template
|
|
1430
|
+
const results = await extract({
|
|
1431
|
+
files: ['/path/to/your/project/src/auth.js#authenticate'],
|
|
1432
|
+
prompt: 'engineer',
|
|
1433
|
+
instructions: 'Explain this authentication function',
|
|
1434
|
+
format: 'json'
|
|
1435
|
+
});
|
|
1436
|
+
|
|
1437
|
+
// Extract code with architect prompt template
|
|
1438
|
+
const results = await extract({
|
|
1439
|
+
files: ['/path/to/your/project/src/auth.js'],
|
|
1440
|
+
prompt: 'architect',
|
|
1441
|
+
instructions: 'Analyze this authentication module',
|
|
1442
|
+
format: 'json'
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
// Extract code with custom prompt template
|
|
1446
|
+
const results = await extract({
|
|
1447
|
+
files: ['/path/to/your/project/src/api.js:42'],
|
|
1448
|
+
prompt: '/path/to/custom/prompt.txt',
|
|
1449
|
+
instructions: 'Refactor this code',
|
|
1450
|
+
format: 'json'
|
|
1451
|
+
});
|
|
1452
|
+
```
|
|
1453
|
+
|
|
1454
|
+
The `prompt` and `instructions` parameters are particularly useful for AI integration workflows, as they allow you to include standardized prompts and specific instructions in the extraction output. This makes it easier to create consistent AI prompting patterns and provide context for code analysis.
|
|
1455
|
+
|
|
1456
|
+
#### Binary Management
|
|
1457
|
+
|
|
1458
|
+
```javascript
|
|
1459
|
+
import { getBinaryPath, setBinaryPath } from '@probelabs/probe';
|
|
1460
|
+
|
|
1461
|
+
// Get the path to the probe binary
|
|
1462
|
+
const binaryPath = await getBinaryPath({
|
|
1463
|
+
forceDownload: false,
|
|
1464
|
+
version: '1.0.0'
|
|
1465
|
+
});
|
|
1466
|
+
|
|
1467
|
+
// Manually set the path to the probe binary
|
|
1468
|
+
setBinaryPath('/path/to/probe/binary');
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
#### AI Tools
|
|
1472
|
+
|
|
1473
|
+
```javascript
|
|
1474
|
+
import { tools } from '@probelabs/probe';
|
|
1475
|
+
|
|
1476
|
+
// Vercel AI SDK tools
|
|
1477
|
+
const { searchTool, queryTool, extractTool } = tools;
|
|
1478
|
+
|
|
1479
|
+
// LangChain tools
|
|
1480
|
+
const searchLangChainTool = tools.createSearchTool();
|
|
1481
|
+
const queryLangChainTool = tools.createQueryTool();
|
|
1482
|
+
const extractLangChainTool = tools.createExtractTool();
|
|
1483
|
+
|
|
1484
|
+
// Access schemas
|
|
1485
|
+
const { searchSchema, querySchema, extractSchema } = tools;
|
|
1486
|
+
|
|
1487
|
+
// Access default system message
|
|
1488
|
+
const systemMessage = tools.DEFAULT_SYSTEM_MESSAGE;
|