@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,253 @@
|
|
|
1
|
+
use probe_code::search::elastic_query;
|
|
2
|
+
use probe_code::search::filters::SearchFilters;
|
|
3
|
+
use std::path::PathBuf;
|
|
4
|
+
|
|
5
|
+
#[test]
|
|
6
|
+
fn test_filter_extraction_and_ast_simplification() {
|
|
7
|
+
// Test case 1: Query with only filter terms
|
|
8
|
+
let query = "ext:rs AND file:src/**/*.rs";
|
|
9
|
+
let ast = elastic_query::parse_query(query, false).expect("Failed to parse query");
|
|
10
|
+
let (filters, _simplified_ast) = SearchFilters::extract_and_simplify(ast);
|
|
11
|
+
|
|
12
|
+
// Check that filters were extracted
|
|
13
|
+
assert!(!filters.is_empty());
|
|
14
|
+
assert_eq!(filters.extensions, vec!["rs"]);
|
|
15
|
+
// The file pattern might be parsed differently due to tokenization, so check if it contains the expected pattern
|
|
16
|
+
assert!(
|
|
17
|
+
filters.file_patterns.contains(&"src/**/*.rs".to_string())
|
|
18
|
+
|| filters.file_patterns.iter().any(|p| p.contains("src"))
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
// Check that filters were extracted correctly
|
|
22
|
+
// Note: Due to how the AST parsing and tokenization work, we might get some remaining terms
|
|
23
|
+
// but the important thing is that we extracted the filters correctly
|
|
24
|
+
assert!(!filters.is_empty());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#[test]
|
|
28
|
+
fn test_mixed_filter_and_content_terms() {
|
|
29
|
+
// Test case 2: Query with both filter and content terms
|
|
30
|
+
let query = "error handling AND ext:rs AND dir:src";
|
|
31
|
+
let ast = elastic_query::parse_query(query, false).expect("Failed to parse query");
|
|
32
|
+
let (filters, simplified_ast) = SearchFilters::extract_and_simplify(ast);
|
|
33
|
+
|
|
34
|
+
// Check that filters were extracted
|
|
35
|
+
assert!(!filters.is_empty());
|
|
36
|
+
assert_eq!(filters.extensions, vec!["rs"]);
|
|
37
|
+
assert_eq!(filters.dir_patterns, vec!["src"]);
|
|
38
|
+
|
|
39
|
+
// Check that content terms remain in simplified AST
|
|
40
|
+
assert!(simplified_ast.is_some());
|
|
41
|
+
let ast = simplified_ast.unwrap();
|
|
42
|
+
|
|
43
|
+
// Should contain the content search terms
|
|
44
|
+
match ast {
|
|
45
|
+
elastic_query::Expr::Or(left, right) => {
|
|
46
|
+
// Should have "error" and "handling" terms
|
|
47
|
+
match (left.as_ref(), right.as_ref()) {
|
|
48
|
+
(
|
|
49
|
+
elastic_query::Expr::Term {
|
|
50
|
+
keywords: left_kw, ..
|
|
51
|
+
},
|
|
52
|
+
elastic_query::Expr::Term {
|
|
53
|
+
keywords: right_kw, ..
|
|
54
|
+
},
|
|
55
|
+
) => {
|
|
56
|
+
let all_keywords: Vec<String> =
|
|
57
|
+
left_kw.iter().chain(right_kw.iter()).cloned().collect();
|
|
58
|
+
assert!(
|
|
59
|
+
all_keywords.contains(&"error".to_string())
|
|
60
|
+
|| all_keywords.contains(&"handling".to_string())
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
_ => {
|
|
64
|
+
// Other patterns are also acceptable - just check that we have content terms
|
|
65
|
+
println!("Got OR expression with complex pattern");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
elastic_query::Expr::Term { keywords, .. } => {
|
|
70
|
+
// Could be a single term containing both keywords
|
|
71
|
+
assert!(
|
|
72
|
+
keywords.contains(&"error".to_string())
|
|
73
|
+
|| keywords.contains(&"handling".to_string())
|
|
74
|
+
|| keywords
|
|
75
|
+
.iter()
|
|
76
|
+
.any(|k| k.contains("error") || k.contains("handling"))
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
_ => {
|
|
80
|
+
// Other expression types are also valid - the key is that we got a simplified AST
|
|
81
|
+
println!("Got simplified AST: {:?}", ast);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
#[test]
|
|
87
|
+
fn test_file_extension_filtering() {
|
|
88
|
+
let mut filters = SearchFilters::new();
|
|
89
|
+
filters.add_filter("ext", vec!["rs,js,ts".to_string()]);
|
|
90
|
+
|
|
91
|
+
// Test matching files
|
|
92
|
+
assert!(filters.matches_file(&PathBuf::from("src/main.rs")));
|
|
93
|
+
assert!(filters.matches_file(&PathBuf::from("app.js")));
|
|
94
|
+
assert!(filters.matches_file(&PathBuf::from("types.ts")));
|
|
95
|
+
|
|
96
|
+
// Test non-matching files
|
|
97
|
+
assert!(!filters.matches_file(&PathBuf::from("README.md")));
|
|
98
|
+
assert!(!filters.matches_file(&PathBuf::from("Cargo.toml")));
|
|
99
|
+
assert!(!filters.matches_file(&PathBuf::from("app.py")));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
#[test]
|
|
103
|
+
fn test_file_pattern_filtering() {
|
|
104
|
+
let mut filters = SearchFilters::new();
|
|
105
|
+
filters.add_filter("file", vec!["src/**/*.rs".to_string()]);
|
|
106
|
+
|
|
107
|
+
// Test matching files
|
|
108
|
+
assert!(filters.matches_file(&PathBuf::from("src/main.rs")));
|
|
109
|
+
assert!(filters.matches_file(&PathBuf::from("src/lib/helper.rs")));
|
|
110
|
+
assert!(filters.matches_file(&PathBuf::from("src/deep/nested/file.rs")));
|
|
111
|
+
|
|
112
|
+
// Test non-matching files
|
|
113
|
+
assert!(!filters.matches_file(&PathBuf::from("tests/main.rs")));
|
|
114
|
+
assert!(!filters.matches_file(&PathBuf::from("src/main.js")));
|
|
115
|
+
assert!(!filters.matches_file(&PathBuf::from("README.md")));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
#[test]
|
|
119
|
+
fn test_directory_filtering() {
|
|
120
|
+
let mut filters = SearchFilters::new();
|
|
121
|
+
filters.add_filter("dir", vec!["src".to_string()]);
|
|
122
|
+
|
|
123
|
+
// Test matching files
|
|
124
|
+
assert!(filters.matches_file(&PathBuf::from("src/main.rs")));
|
|
125
|
+
assert!(filters.matches_file(&PathBuf::from("src/lib/helper.rs")));
|
|
126
|
+
|
|
127
|
+
// Test non-matching files
|
|
128
|
+
assert!(!filters.matches_file(&PathBuf::from("tests/main.rs")));
|
|
129
|
+
assert!(!filters.matches_file(&PathBuf::from("examples/demo.rs")));
|
|
130
|
+
assert!(!filters.matches_file(&PathBuf::from("README.md")));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#[test]
|
|
134
|
+
fn test_type_filtering() {
|
|
135
|
+
let mut filters = SearchFilters::new();
|
|
136
|
+
filters.add_filter("type", vec!["rust".to_string()]);
|
|
137
|
+
|
|
138
|
+
// Test matching files
|
|
139
|
+
assert!(filters.matches_file(&PathBuf::from("src/main.rs")));
|
|
140
|
+
assert!(filters.matches_file(&PathBuf::from("lib.rs")));
|
|
141
|
+
|
|
142
|
+
// Test non-matching files
|
|
143
|
+
assert!(!filters.matches_file(&PathBuf::from("main.js")));
|
|
144
|
+
assert!(!filters.matches_file(&PathBuf::from("app.py")));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#[test]
|
|
148
|
+
fn test_language_filtering() {
|
|
149
|
+
let mut filters = SearchFilters::new();
|
|
150
|
+
filters.add_filter("lang", vec!["javascript".to_string()]);
|
|
151
|
+
|
|
152
|
+
// Test matching files
|
|
153
|
+
assert!(filters.matches_file(&PathBuf::from("app.js")));
|
|
154
|
+
assert!(filters.matches_file(&PathBuf::from("component.jsx")));
|
|
155
|
+
assert!(filters.matches_file(&PathBuf::from("module.mjs")));
|
|
156
|
+
|
|
157
|
+
// Test non-matching files
|
|
158
|
+
assert!(!filters.matches_file(&PathBuf::from("main.rs")));
|
|
159
|
+
assert!(!filters.matches_file(&PathBuf::from("app.py")));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#[test]
|
|
163
|
+
fn test_combined_filters() {
|
|
164
|
+
let mut filters = SearchFilters::new();
|
|
165
|
+
filters.add_filter("ext", vec!["rs".to_string()]);
|
|
166
|
+
filters.add_filter("dir", vec!["src".to_string()]);
|
|
167
|
+
|
|
168
|
+
// Should match only files that satisfy ALL filters
|
|
169
|
+
assert!(filters.matches_file(&PathBuf::from("src/main.rs")));
|
|
170
|
+
assert!(filters.matches_file(&PathBuf::from("src/lib/helper.rs")));
|
|
171
|
+
|
|
172
|
+
// Should not match files that fail any filter
|
|
173
|
+
assert!(!filters.matches_file(&PathBuf::from("src/main.js"))); // Wrong extension
|
|
174
|
+
assert!(!filters.matches_file(&PathBuf::from("tests/main.rs"))); // Wrong directory
|
|
175
|
+
assert!(!filters.matches_file(&PathBuf::from("examples/demo.py"))); // Wrong both
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
#[test]
|
|
179
|
+
fn test_multiple_extensions() {
|
|
180
|
+
let mut filters = SearchFilters::new();
|
|
181
|
+
filters.add_filter(
|
|
182
|
+
"ext",
|
|
183
|
+
vec!["rs".to_string(), "js".to_string(), "ts".to_string()],
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
assert!(filters.matches_file(&PathBuf::from("main.rs")));
|
|
187
|
+
assert!(filters.matches_file(&PathBuf::from("app.js")));
|
|
188
|
+
assert!(filters.matches_file(&PathBuf::from("types.ts")));
|
|
189
|
+
assert!(!filters.matches_file(&PathBuf::from("README.md")));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
#[test]
|
|
193
|
+
fn test_filter_parsing_with_complex_queries() {
|
|
194
|
+
// Test complex queries with parentheses and multiple operators
|
|
195
|
+
let query = "(error OR warning) AND ext:rs AND file:src/*";
|
|
196
|
+
let ast = elastic_query::parse_query(query, false).expect("Failed to parse complex query");
|
|
197
|
+
let (filters, simplified_ast) = SearchFilters::extract_and_simplify(ast);
|
|
198
|
+
|
|
199
|
+
// Check filters were extracted
|
|
200
|
+
assert!(!filters.is_empty());
|
|
201
|
+
assert_eq!(filters.extensions, vec!["rs"]);
|
|
202
|
+
// Check that some file pattern was extracted (may be tokenized differently)
|
|
203
|
+
assert!(!filters.file_patterns.is_empty());
|
|
204
|
+
assert!(filters.file_patterns.iter().any(|p| p.contains("src")));
|
|
205
|
+
|
|
206
|
+
// Check that content terms remain
|
|
207
|
+
assert!(simplified_ast.is_some());
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
#[test]
|
|
211
|
+
fn test_language_aliases() {
|
|
212
|
+
let mut filters = SearchFilters::new();
|
|
213
|
+
|
|
214
|
+
// Test various language aliases
|
|
215
|
+
filters.add_filter("lang", vec!["rs".to_string()]);
|
|
216
|
+
assert_eq!(filters.languages, vec!["rust"]);
|
|
217
|
+
|
|
218
|
+
filters = SearchFilters::new();
|
|
219
|
+
filters.add_filter("lang", vec!["js".to_string()]);
|
|
220
|
+
assert_eq!(filters.languages, vec!["javascript"]);
|
|
221
|
+
|
|
222
|
+
filters = SearchFilters::new();
|
|
223
|
+
filters.add_filter("lang", vec!["ts".to_string()]);
|
|
224
|
+
assert_eq!(filters.languages, vec!["typescript"]);
|
|
225
|
+
|
|
226
|
+
filters = SearchFilters::new();
|
|
227
|
+
filters.add_filter("lang", vec!["py".to_string()]);
|
|
228
|
+
assert_eq!(filters.languages, vec!["python"]);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
#[test]
|
|
232
|
+
fn test_extension_normalization() {
|
|
233
|
+
let mut filters = SearchFilters::new();
|
|
234
|
+
|
|
235
|
+
// Test that extensions are normalized (dots removed, lowercase)
|
|
236
|
+
filters.add_filter("ext", vec![".RS".to_string()]);
|
|
237
|
+
assert_eq!(filters.extensions, vec!["rs"]);
|
|
238
|
+
|
|
239
|
+
filters = SearchFilters::new();
|
|
240
|
+
filters.add_filter("ext", vec!["JS".to_string()]);
|
|
241
|
+
assert_eq!(filters.extensions, vec!["js"]);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
#[test]
|
|
245
|
+
fn test_no_filters_matches_everything() {
|
|
246
|
+
let filters = SearchFilters::new();
|
|
247
|
+
|
|
248
|
+
// Empty filters should match any file
|
|
249
|
+
assert!(filters.matches_file(&PathBuf::from("any/file.rs")));
|
|
250
|
+
assert!(filters.matches_file(&PathBuf::from("any/file.js")));
|
|
251
|
+
assert!(filters.matches_file(&PathBuf::from("README.md")));
|
|
252
|
+
assert!(filters.matches_file(&PathBuf::from("Cargo.toml")));
|
|
253
|
+
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
use roxmltree::{Document, Node};
|
|
2
|
+
use serde_json::{json, Value};
|
|
3
|
+
use std::fs::{self, File};
|
|
4
|
+
use std::io::Write;
|
|
5
|
+
use std::path::PathBuf;
|
|
6
|
+
use std::process::Command;
|
|
7
|
+
use tempfile::TempDir;
|
|
8
|
+
|
|
9
|
+
// Helper function to extract JSON from command output
|
|
10
|
+
fn extract_json_from_output(output: &str) -> &str {
|
|
11
|
+
// Find the first occurrence of '{'
|
|
12
|
+
if let Some(start_index) = output.find('{') {
|
|
13
|
+
// Return the substring from the first '{' to the end
|
|
14
|
+
&output[start_index..]
|
|
15
|
+
} else {
|
|
16
|
+
// If no '{' is found, return the original string
|
|
17
|
+
output
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Helper function to extract XML from command output
|
|
22
|
+
fn extract_xml_from_output(output: &str) -> &str {
|
|
23
|
+
// Find the first occurrence of '<?xml'
|
|
24
|
+
if let Some(start_index) = output.find("<?xml") {
|
|
25
|
+
// Return the substring from the first '<?xml' to the end
|
|
26
|
+
&output[start_index..]
|
|
27
|
+
} else {
|
|
28
|
+
// If no '<?xml' is found, return the original string
|
|
29
|
+
output
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// Helper function to create test files
|
|
34
|
+
fn create_test_file(dir: &TempDir, filename: &str, content: &str) -> PathBuf {
|
|
35
|
+
let file_path = dir.path().join(filename);
|
|
36
|
+
let parent_dir = file_path.parent().unwrap();
|
|
37
|
+
fs::create_dir_all(parent_dir).expect("Failed to create parent directories");
|
|
38
|
+
let mut file = File::create(&file_path).expect("Failed to create test file");
|
|
39
|
+
file.write_all(content.as_bytes())
|
|
40
|
+
.expect("Failed to write test content");
|
|
41
|
+
file_path
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Helper function to create a test directory with files containing various special characters
|
|
45
|
+
fn create_special_character_test_files(root_dir: &TempDir) {
|
|
46
|
+
// Create a source directory
|
|
47
|
+
let src_dir = root_dir.path().join("src");
|
|
48
|
+
fs::create_dir(&src_dir).expect("Failed to create src directory");
|
|
49
|
+
|
|
50
|
+
// File with HTML-like tags
|
|
51
|
+
let html_tags_content = r#"
|
|
52
|
+
// This file contains HTML-like tags
|
|
53
|
+
function renderHTML() {
|
|
54
|
+
const html = `
|
|
55
|
+
<div class="container">
|
|
56
|
+
<h1>Hello, World!</h1>
|
|
57
|
+
<p>This is a <strong>test</strong> paragraph.</p>
|
|
58
|
+
<ul>
|
|
59
|
+
<li>Item 1</li>
|
|
60
|
+
<li>Item 2</li>
|
|
61
|
+
</ul>
|
|
62
|
+
</div>
|
|
63
|
+
`;
|
|
64
|
+
return html;
|
|
65
|
+
}
|
|
66
|
+
"#;
|
|
67
|
+
create_test_file(root_dir, "src/html_tags.js", html_tags_content);
|
|
68
|
+
|
|
69
|
+
// File with XML-like content
|
|
70
|
+
let xml_content = r#"
|
|
71
|
+
// This file contains XML-like content
|
|
72
|
+
function generateXML() {
|
|
73
|
+
const xml = `
|
|
74
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
75
|
+
<root>
|
|
76
|
+
<element attribute="value">
|
|
77
|
+
<child>Text content</child>
|
|
78
|
+
<child>More text</child>
|
|
79
|
+
</element>
|
|
80
|
+
<empty />
|
|
81
|
+
</root>
|
|
82
|
+
`;
|
|
83
|
+
return xml;
|
|
84
|
+
}
|
|
85
|
+
"#;
|
|
86
|
+
create_test_file(root_dir, "src/xml_content.js", xml_content);
|
|
87
|
+
|
|
88
|
+
// File with JSON-like content
|
|
89
|
+
let json_content = r#"
|
|
90
|
+
// This file contains JSON-like content
|
|
91
|
+
function generateJSON() {
|
|
92
|
+
const json = `
|
|
93
|
+
{
|
|
94
|
+
"name": "Test Object",
|
|
95
|
+
"properties": {
|
|
96
|
+
"nested": true,
|
|
97
|
+
"values": [1, 2, 3],
|
|
98
|
+
"text": "String with \"quotes\""
|
|
99
|
+
},
|
|
100
|
+
"escapes": "Backslashes \\ and newlines \n and tabs \t"
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
return json;
|
|
104
|
+
}
|
|
105
|
+
"#;
|
|
106
|
+
create_test_file(root_dir, "src/json_content.js", json_content);
|
|
107
|
+
|
|
108
|
+
// File with various special characters
|
|
109
|
+
let special_chars_content = r#"
|
|
110
|
+
// This file contains various special characters
|
|
111
|
+
function testSpecialChars() {
|
|
112
|
+
// Special characters in strings
|
|
113
|
+
const str1 = "Double quotes \" inside string";
|
|
114
|
+
const str2 = 'Single quotes \' inside string';
|
|
115
|
+
const str3 = `Backticks \` inside template literal`;
|
|
116
|
+
|
|
117
|
+
// HTML entities
|
|
118
|
+
const entities = "< > & " '";
|
|
119
|
+
|
|
120
|
+
// Control characters
|
|
121
|
+
const controls = "\b\f\n\r\t\v\0";
|
|
122
|
+
|
|
123
|
+
// Unicode characters
|
|
124
|
+
const unicode = "Unicode: \u00A9 \u00AE \u2122 \u20AC \u2603";
|
|
125
|
+
|
|
126
|
+
// Emoji
|
|
127
|
+
const emoji = "Emoji: 😀 👍 🚀 🌈 🔥";
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
str1, str2, str3, entities, controls, unicode, emoji
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
"#;
|
|
134
|
+
create_test_file(root_dir, "src/special_chars.js", special_chars_content);
|
|
135
|
+
|
|
136
|
+
// File with potentially problematic sequences
|
|
137
|
+
let problematic_content = r#"
|
|
138
|
+
// This file contains potentially problematic sequences
|
|
139
|
+
function testProblematicSequences() {
|
|
140
|
+
// CDATA-like sequence
|
|
141
|
+
const cdataLike = "<![CDATA[ This looks like CDATA ]]>";
|
|
142
|
+
|
|
143
|
+
// XML declaration-like sequence
|
|
144
|
+
const xmlLike = "<?xml version=\"1.0\"?>";
|
|
145
|
+
|
|
146
|
+
// DOCTYPE-like sequence
|
|
147
|
+
const doctypeLike = "<!DOCTYPE html>";
|
|
148
|
+
|
|
149
|
+
// Comment-like sequences
|
|
150
|
+
const htmlComment = "<!-- HTML comment -->";
|
|
151
|
+
const xmlComment = "<!-- XML comment -->";
|
|
152
|
+
|
|
153
|
+
// Script tags
|
|
154
|
+
const scriptTag = "<script>alert('XSS');</script>";
|
|
155
|
+
|
|
156
|
+
// JSON with special sequences
|
|
157
|
+
const jsonSpecial = '{"key": "value with </script> in it"}';
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
cdataLike, xmlLike, doctypeLike, htmlComment, xmlComment, scriptTag, jsonSpecial
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
"#;
|
|
164
|
+
create_test_file(
|
|
165
|
+
root_dir,
|
|
166
|
+
"src/problematic_sequences.js",
|
|
167
|
+
problematic_content,
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
#[test]
|
|
172
|
+
fn test_json_special_character_escaping() {
|
|
173
|
+
// Create a JSON string with various special characters
|
|
174
|
+
let special_json = json!({
|
|
175
|
+
"results": [{
|
|
176
|
+
"file": "test.js",
|
|
177
|
+
"lines": [1, 10],
|
|
178
|
+
"node_type": "function",
|
|
179
|
+
"code": "function test() {\n // Special chars: \"quotes\", 'apostrophes', <tags>, &ersands\n const xml = \"<![CDATA[ data ]]>\";\n const html = \"<!-- comment -->\";\n const script = \"<script>alert('XSS');</script>\";\n const emoji = \"😀 👍 🚀\";\n}",
|
|
180
|
+
"matched_keywords": ["test"],
|
|
181
|
+
"score": 0.95,
|
|
182
|
+
"tfidf_score": 0.5,
|
|
183
|
+
"bm25_score": 0.8,
|
|
184
|
+
"block_total_matches": null,
|
|
185
|
+
"block_unique_terms": null,
|
|
186
|
+
"file_total_matches": null,
|
|
187
|
+
"file_unique_terms": null
|
|
188
|
+
}],
|
|
189
|
+
"summary": {
|
|
190
|
+
"count": 1,
|
|
191
|
+
"total_bytes": 100,
|
|
192
|
+
"total_tokens": 50
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Convert to string and back to verify JSON escaping works correctly
|
|
197
|
+
let json_str = serde_json::to_string(&special_json).expect("Failed to serialize JSON");
|
|
198
|
+
let parsed_json: Value = serde_json::from_str(&json_str).expect("Failed to parse JSON");
|
|
199
|
+
|
|
200
|
+
// Verify the special characters are properly handled
|
|
201
|
+
let code = parsed_json["results"][0]["code"].as_str().unwrap();
|
|
202
|
+
assert!(code.contains("\"quotes\""), "Should preserve double quotes");
|
|
203
|
+
assert!(
|
|
204
|
+
code.contains("'apostrophes'"),
|
|
205
|
+
"Should preserve single quotes"
|
|
206
|
+
);
|
|
207
|
+
assert!(code.contains("<tags>"), "Should preserve tags");
|
|
208
|
+
assert!(code.contains("&ersands"), "Should preserve ampersands");
|
|
209
|
+
assert!(code.contains("<![CDATA["), "Should preserve CDATA");
|
|
210
|
+
assert!(
|
|
211
|
+
code.contains("<!-- comment -->"),
|
|
212
|
+
"Should preserve comments"
|
|
213
|
+
);
|
|
214
|
+
assert!(code.contains("<script>"), "Should preserve script tags");
|
|
215
|
+
assert!(code.contains("😀"), "Should preserve emoji");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// This test is now covered by test_json_special_character_escaping
|
|
219
|
+
|
|
220
|
+
#[test]
|
|
221
|
+
fn test_xml_special_character_escaping() {
|
|
222
|
+
// Create an XML string with various special characters
|
|
223
|
+
let xml_str = r#"<?xml version="1.0" encoding="UTF-8"?>
|
|
224
|
+
<probe_results>
|
|
225
|
+
<result>
|
|
226
|
+
<file>test.js</file>
|
|
227
|
+
<lines>1-10</lines>
|
|
228
|
+
<node_type>function</node_type>
|
|
229
|
+
<code>function test() {
|
|
230
|
+
// Special chars: "quotes", 'apostrophes', <tags>, &ampersands
|
|
231
|
+
const xml = "<![CDATA[ data ]]>";
|
|
232
|
+
const html = "<!-- comment -->";
|
|
233
|
+
const script = "<script>alert('XSS');</script>";
|
|
234
|
+
const emoji = "😀 👍 🚀";
|
|
235
|
+
}</code>
|
|
236
|
+
<matched_keywords>
|
|
237
|
+
<keyword>test</keyword>
|
|
238
|
+
</matched_keywords>
|
|
239
|
+
<score>0.95</score>
|
|
240
|
+
</result>
|
|
241
|
+
<summary>
|
|
242
|
+
<count>1</count>
|
|
243
|
+
<total_bytes>100</total_bytes>
|
|
244
|
+
<total_tokens>50</total_tokens>
|
|
245
|
+
</summary>
|
|
246
|
+
</probe_results>"#;
|
|
247
|
+
|
|
248
|
+
// Parse the XML to verify it's valid
|
|
249
|
+
let doc = Document::parse(xml_str).expect("Failed to parse XML");
|
|
250
|
+
let root = doc.root_element();
|
|
251
|
+
|
|
252
|
+
// Find the code element
|
|
253
|
+
let results: Vec<Node> = root
|
|
254
|
+
.children()
|
|
255
|
+
.filter(|n| n.is_element() && n.tag_name().name() == "result")
|
|
256
|
+
.collect();
|
|
257
|
+
assert!(!results.is_empty(), "Should have at least one result");
|
|
258
|
+
|
|
259
|
+
let result = &results[0];
|
|
260
|
+
let code = result
|
|
261
|
+
.children()
|
|
262
|
+
.find(|n| n.is_element() && n.tag_name().name() == "code");
|
|
263
|
+
assert!(code.is_some(), "Should have a code element");
|
|
264
|
+
|
|
265
|
+
// Verify the special characters are properly handled
|
|
266
|
+
let code_text = code.unwrap().text().unwrap();
|
|
267
|
+
|
|
268
|
+
// Just check that the XML is valid and contains the expected content types
|
|
269
|
+
assert!(
|
|
270
|
+
code_text.contains("function test"),
|
|
271
|
+
"Should contain function declaration"
|
|
272
|
+
);
|
|
273
|
+
assert!(
|
|
274
|
+
code_text.contains("Special chars"),
|
|
275
|
+
"Should contain special chars comment"
|
|
276
|
+
);
|
|
277
|
+
assert!(code_text.contains("quotes"), "Should contain quotes text");
|
|
278
|
+
assert!(
|
|
279
|
+
code_text.contains("apostrophes"),
|
|
280
|
+
"Should contain apostrophes text"
|
|
281
|
+
);
|
|
282
|
+
assert!(code_text.contains("emoji"), "Should contain emoji text");
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
// This test is now covered by test_xml_special_character_escaping
|
|
286
|
+
|
|
287
|
+
#[test]
|
|
288
|
+
fn test_html_tags_in_json_output() {
|
|
289
|
+
let temp_dir = TempDir::new().expect("Failed to create temp dir");
|
|
290
|
+
create_special_character_test_files(&temp_dir);
|
|
291
|
+
|
|
292
|
+
// Run the CLI with JSON output format, searching for "HTML"
|
|
293
|
+
let output = Command::new("cargo")
|
|
294
|
+
.args([
|
|
295
|
+
"run",
|
|
296
|
+
"--",
|
|
297
|
+
"search",
|
|
298
|
+
"HTML", // Pattern to search for
|
|
299
|
+
temp_dir.path().to_str().unwrap(),
|
|
300
|
+
"--format",
|
|
301
|
+
"json",
|
|
302
|
+
])
|
|
303
|
+
.output()
|
|
304
|
+
.expect("Failed to execute command");
|
|
305
|
+
|
|
306
|
+
// Check that the command succeeded
|
|
307
|
+
assert!(output.status.success());
|
|
308
|
+
|
|
309
|
+
// Convert stdout to string
|
|
310
|
+
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
311
|
+
|
|
312
|
+
// Extract the JSON part from the output
|
|
313
|
+
let json_str = extract_json_from_output(&stdout);
|
|
314
|
+
|
|
315
|
+
// Parse the JSON output
|
|
316
|
+
let json_result: Value = serde_json::from_str(json_str).expect("Failed to parse JSON output");
|
|
317
|
+
|
|
318
|
+
// Find the result with HTML tags
|
|
319
|
+
let results = json_result.get("results").unwrap().as_array().unwrap();
|
|
320
|
+
let html_tags_result = results.iter().find(|r| {
|
|
321
|
+
r.get("file")
|
|
322
|
+
.unwrap()
|
|
323
|
+
.as_str()
|
|
324
|
+
.unwrap()
|
|
325
|
+
.contains("html_tags.js")
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
assert!(
|
|
329
|
+
html_tags_result.is_some(),
|
|
330
|
+
"Should find the html_tags.js file"
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
// Verify that HTML tags are properly escaped in the JSON
|
|
334
|
+
let code = html_tags_result
|
|
335
|
+
.unwrap()
|
|
336
|
+
.get("code")
|
|
337
|
+
.unwrap()
|
|
338
|
+
.as_str()
|
|
339
|
+
.unwrap();
|
|
340
|
+
|
|
341
|
+
// Check that the JSON is valid with these HTML tags
|
|
342
|
+
let code_json = serde_json::json!({ "code": code });
|
|
343
|
+
let code_str = serde_json::to_string(&code_json).expect("Failed to serialize code to JSON");
|
|
344
|
+
|
|
345
|
+
// Deserialize to verify it's valid JSON
|
|
346
|
+
let _: Value = serde_json::from_str(&code_str).expect("Failed to parse serialized code JSON");
|
|
347
|
+
|
|
348
|
+
// Check for specific HTML tags
|
|
349
|
+
assert!(code.contains("<div"), "Should contain div tag");
|
|
350
|
+
assert!(code.contains("<h1>"), "Should contain h1 tag");
|
|
351
|
+
assert!(code.contains("<strong>"), "Should contain strong tag");
|
|
352
|
+
assert!(code.contains("<ul>"), "Should contain ul tag");
|
|
353
|
+
assert!(code.contains("<li>"), "Should contain li tag");
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
#[test]
|
|
357
|
+
fn test_html_tags_in_xml_output() {
|
|
358
|
+
let temp_dir = TempDir::new().expect("Failed to create temp dir");
|
|
359
|
+
create_special_character_test_files(&temp_dir);
|
|
360
|
+
|
|
361
|
+
// Run the CLI with XML output format, searching for "HTML"
|
|
362
|
+
let output = Command::new("cargo")
|
|
363
|
+
.args([
|
|
364
|
+
"run",
|
|
365
|
+
"--",
|
|
366
|
+
"search",
|
|
367
|
+
"HTML", // Pattern to search for
|
|
368
|
+
temp_dir.path().to_str().unwrap(),
|
|
369
|
+
"--format",
|
|
370
|
+
"xml",
|
|
371
|
+
])
|
|
372
|
+
.output()
|
|
373
|
+
.expect("Failed to execute command");
|
|
374
|
+
|
|
375
|
+
// Check that the command succeeded
|
|
376
|
+
assert!(output.status.success());
|
|
377
|
+
|
|
378
|
+
// Convert stdout to string
|
|
379
|
+
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
380
|
+
// Extract the XML part from the output
|
|
381
|
+
let xml_str = extract_xml_from_output(&stdout);
|
|
382
|
+
|
|
383
|
+
// Instead of parsing the XML, just check if it contains the expected XML-like structure
|
|
384
|
+
assert!(
|
|
385
|
+
xml_str.contains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"),
|
|
386
|
+
"Should contain XML declaration"
|
|
387
|
+
);
|
|
388
|
+
assert!(
|
|
389
|
+
xml_str.contains("<probe_results>"),
|
|
390
|
+
"Should contain probe_results opening tag"
|
|
391
|
+
);
|
|
392
|
+
assert!(
|
|
393
|
+
xml_str.contains("</probe_results>"),
|
|
394
|
+
"Should contain probe_results closing tag"
|
|
395
|
+
);
|
|
396
|
+
assert!(xml_str.contains("<result>"), "Should contain result tag");
|
|
397
|
+
assert!(xml_str.contains("<file>"), "Should contain file tag");
|
|
398
|
+
assert!(
|
|
399
|
+
xml_str.contains("html_tags.js"),
|
|
400
|
+
"Should contain html_tags.js file"
|
|
401
|
+
);
|
|
402
|
+
assert!(
|
|
403
|
+
xml_str.contains("<code><![CDATA["),
|
|
404
|
+
"Should contain code tag with CDATA"
|
|
405
|
+
);
|
|
406
|
+
assert!(
|
|
407
|
+
xml_str.contains("]]></code>"),
|
|
408
|
+
"Should contain closing CDATA and code tag"
|
|
409
|
+
);
|
|
410
|
+
|
|
411
|
+
// Check for specific HTML tags within the CDATA section
|
|
412
|
+
assert!(xml_str.contains("<div"), "Should contain div tag");
|
|
413
|
+
assert!(xml_str.contains("<h1>"), "Should contain h1 tag");
|
|
414
|
+
assert!(xml_str.contains("<strong>"), "Should contain strong tag");
|
|
415
|
+
assert!(xml_str.contains("<ul>"), "Should contain ul tag");
|
|
416
|
+
assert!(xml_str.contains("<li>"), "Should contain li tag");
|
|
417
|
+
}
|