Commit graph

84 commits

Author SHA1 Message Date
KJ7LNW
d7ad9470e2
Tree-sitter Enhancements: TSX, TypeScript, JSON, and Markdown Support (#2169)
* feat: add Tree-sitter TSX query support

Added support for parsing TSX files with Tree-sitter:
- Created TSX query patterns for React components and functions
- Fixed field name issues by using direct node matching
- Added comprehensive documentation about TSX component structure
- Created a debug tool to inspect the actual tree structure
- Added test coverage for TSX parsing
- Embedded test fixture directly in the test file

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* refactor: combine TypeScript and TSX queries

Reduce duplication by:
- Import TypeScript queries from typescript.ts
- Keep only TSX-specific component and JSX queries
- Update documentation to reflect combined approach

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* test: update integration for parse definitions

- Adjusted logParseResult to call the actual parse definitions function using WASM from initializeWorkingParser.
- Patched TreeSitter initialization to resolve the WASM path correctly and bypass redundant init() calls.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* test: should successfully call parseSourceCodeDefinitionsForFile

Mock loadRequiredLanguageParsers to use real parser instance from initializeTreeSitter,
ensuring proper interaction between parseSourceCodeDefinitionsForFile and its dependencies.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* test: improve test structure for parseSourceCodeDefinitions

- Combine component parsing tests into a single test case
- Update test assertions to match actual parser output
- Fix interface and component definition tests to use VSCodeCheckbox as sample

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: improve React component detection in tree-sitter

- Add tests for complex TSX structures (nested components, HOCs)
- Enhance TSX queries to better detect React components
- Document current limitations in test file

* feat: improve React component detection in TSX files

Make TSX/React component detection more generic and robust by:
- Implementing structural pattern matching instead of specific React wrapper functions
- Adding configurable line threshold for React component inclusion (MIN_COMPONENT_LINES)
- Adding robust HTML element filtering with regex patterns
- Improving React component name handling for nested components
- Ensuring proper context handling for multi-line React components

Also update mock captures in tree-sitter tests to span at least 4 lines
to meet the MIN_COMPONENT_LINES threshold.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* refactor: use testParseSourceCodeDefinitions in logParseResult

- Moved testParseSourceCodeDefinitions function to top level
- Updated logParseResult to use testParseSourceCodeDefinitions
- Removed duplicate function from describe block
- Added console.log for debugging output

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* refactor: improve React component detection output format

- Remove individual line output for components that don't meet MIN_COMPONENT_LINES threshold
- Update tests to match the new behavior where lines < MIN_COMPONENT_LINES are skipped
- Maintain range output (e.g., 1--4) for component definitions
- Preserve context for larger definitions as ranges only

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: add switch/case statement support to tree-sitter TypeScript parser

- Added node patterns in typescript.ts query to capture switch statements, case clauses, and default clauses
- Modified index.ts to avoid duplicate line ranges in the output
- Added test for switch/case statements with complex case blocks
- Fixed line range tracking to prevent duplicate output

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: add support for enum declarations in tree-sitter TypeScript parser

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: add support for namespace declarations in tree-sitter TypeScript parser

Added query pattern for namespace declarations (internal_module nodes) in the TypeScript parser.
This allows the parser to identify and extract namespace declarations from TypeScript code.

- Added test case to verify namespace parsing functionality
- Added query pattern to capture namespace declarations in typescript.ts

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: add decorator pattern support to tree-sitter TypeScript parser

- Added support for parsing complex decorators with arguments
- Added test case for Component decorator pattern
- Enhanced TypeScript queries to capture decorator definitions

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: add generic type declaration support to tree-sitter TypeScript parser

- Added support for parsing generic types with constraints
- Added test case for Dictionary<K extends string | number, V> pattern
- Enhanced TypeScript queries to capture generic type definitions

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* test: add conditional type support to tree-sitter TypeScript parser

- Added test case for conditional type patterns like ReturnType<T>
- Verified that conditional types with infer keyword are already supported
- Enhanced inspectTreeStructure with detailed node inspection for debugging

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* test: add template literal type support to tree-sitter TypeScript parser

- Added test case for template literal type patterns like EventName<T>
- Verified that template literal types are already partially supported
- Confirmed support for complex template literal patterns in conditional types

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: implement tree-sitter compatible markdown processor

Adds a special case implementation for markdown files that:
- Parses markdown headers and section line ranges
- Returns captures in a format compatible with tree-sitter
- Integrates with the existing parseFile function
- Includes comprehensive tests for the implementation

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* fix: markdown parser not detecting sections with horizontal rules

The markdownParser was incorrectly interpreting horizontal rules (---) as setext headers when they appeared after non-header text. This caused some sections to be missed in the output.

This fix:
- Makes setext header detection more strict by requiring at least 3 = or - characters
- Adds validation for the text line before a potential setext header
- Ensures horizontal rules are not confused with setext headers

Added a test case to verify the fix works correctly with horizontal rules.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* refactor: move helper functions to dedicated file

Move test helper functions from parseSourceCodeDefinitions.test.ts to a new helpers.ts file.
Rename test file to parseSourceCodeDefinitions.tsx.test.ts to indicate it's for TSX tests.
This improves code organization by separating test helpers from test cases.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* feat: enable JSON structure display in list_code_definitions

This change allows list_code_definitions to show JSON structures by:
- Moving JSON query patterns into the JavaScript query file
- Using the JavaScript parser for JSON files
- Removing the separate JSON parser implementation
- Adding comprehensive tests for JSON parsing

Example output for a JSON file:
# test.json
0--90 | {
1--9 |   "server": {
4--8 |     "ssl": {
10--45 |   "database": {
11--24 |     "primary": {
14--18 |       "credentials": {
19--23 |       "pool": {
25--44 |     "replicas": [
26--43 |       {
30--42 |         "status": {
33--41 |           "metrics": {
36--40 |             "connections": {
46--73 |   "features": {
47--72 |     "auth": {
48--71 |       "providers": {
49--53 |         "local": {
54--70 |         "oauth": {
56--69 |           "providers": [
57--68 |             {

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* fix: Add compile step to CI workflow to ensure WASM files are available

The TreeSitter tests were failing in CI because the WASM files weren't being copied to the dist directory before running the tests. This adds an explicit compile step to ensure the WASM files are properly built and copied.

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

* fix: improve tree-sitter test type safety and debug logging

- Replace 'any' types with proper Parser types in helpers.ts
- Add centralized DEBUG flag and debugLog function in helpers.ts
- Update all console.log statements to use debugLog across all test files
- This change appeases @ellipsis-dev by improving type safety and
  providing a clean way to control debug logging

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>

---------

Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
2025-03-31 23:34:06 -05:00
Steven T. Cramer
b9f4695d12
Fix Tests to run properly on Windows (#1963)
* fix: remove -p flag from test script to prevent git operation errors

The -p flag in npm-run-all was causing tests to run in parallel, which led to 'Cannot log after tests are done' errors with git operations. These errors don't appear when running test:extension alone.

The issue occurs because git-based tests create temporary directories and run async operations that can interfere with each other when executed in parallel. Running tests sequentially resolves this cleanly.

While it might increase total test time slightly, it ensures more reliable and consistent test results.

* refactor(terminal): improve mock streams and fix test issues

- Create shell-specific mock streams (bash, cmd, pwsh) with proper line ending handling
- Fix open handles in tests by properly managing timeouts
- Standardize stderr redirection across all shell implementations using stdio option
- Improve test reliability and output cleanliness

* fix(tests): add skipVerification option to PowerShell tests to debug Linux issues

* fix(tests): use explicit variable name in PowerShell test to fix Linux compatibility

* Refactor terminal tests to use purpose-based approach instead of command mapping

* Remove reference to non-existent test file

* fix: use printf instead of echo -e for more consistent behavior across platforms

* fix: use single quotes for PowerShell commands to preserve variables on Linux

* Update code-qa workflow to run tests on both Windows and Ubuntu

* fix: use platform-specific PowerShell command execution for Linux and Windows

* Fix toggleToolAlwaysAllow to handle path normalization for cross-platform compatibility

* Fix McpHub tests to handle normalized paths on Windows

* Suppress console.error messages in McpHub tests

* fix: make Bedrock ARN regex patterns Windows-compatible

Fixed an issue where AWS Bedrock tests were timing out on Windows but passing on Linux. The root cause was path separator handling in regex patterns used for model ID extraction from ARNs.

1. Updated model ID extraction regex to handle both forward slashes (Linux) and backslashes (Windows)
2. Modified ARN matching regex to be platform-independent
3. Ensured consistent region prefix handling for all supported regions

This change maintains functionality while ensuring cross-platform compatibility.

* fix: make WorkspaceTracker test cross-platform compatible

Fixed an issue where the WorkspaceTracker test 'should initialize with workspace files' was failing on Windows but passing on Linux. The problem was in the mock implementation of toRelativePath that only handled forward slashes.

- Updated the toRelativePath mock to use path.relative which properly handles platform-specific path separators
- Ensured all paths are converted to forward slashes for consistency in test assertions
- The fix maintains cross-platform compatibility while preserving the test's intent

* fix: make WorkspaceTracker tests cross-platform compatible

Fixed cross-platform compatibility issues in the WorkspaceTracker tests that were causing failures on Windows but passing on Linux:

1. Updated the toRelativePath mock implementation to:
   - Use path.relative which properly handles platform-specific path separators
   - Convert paths to forward slashes for consistency in test assertions

2. Enhanced the 'should not update file paths' test to be platform-agnostic by:
   - Using more flexible assertions that don't depend on specific path formats
   - Checking file path length and content rather than exact string matches
   - Properly typed the test assertions to fix TypeScript errors

These changes preserve the test intent while ensuring they run successfully across different operating systems.

* fix: make McpHub tests cross-platform compatible

Fixed cross-platform compatibility issues in the McpHub tests that were causing failures on Windows but passing on Linux:

1. Made the toggleToolAlwaysAllow tests more platform-agnostic by:
   - No longer relying on specific path formats which differ between Windows and Linux
   - Using the last write call instead of searching for a specific path string
   - Adding more robust assertions that verify structure instead of exact path matches
   - Properly handling array existence checks

2. These tests would fail on Windows because paths are formatted with backslashes instead of
   forward slashes, causing path equality checks to fail.

The changes maintain test intent while ensuring cross-platform compatibility.

* handle escaping of slash and quote

* fix: ensure consistent line endings in git fallback strategy

Fixed an issue where tests would fail on GitHub Windows runners but pass on local Windows machines due to line ending differences. The fix ensures consistent line ending handling by:

1. Normalizing CRLF to LF when reading files in the git fallback strategy
2. Disabling Git's automatic line ending conversion
3. Maintaining consistent line ending usage throughout text operations

* feat: run tests sequentially on Windows, parallel otherwise
2025-03-31 23:17:56 -05:00
Patrick Decat
e694a2b8b5
ci: fix changelog extraction (#1810) 2025-03-20 07:27:41 -04:00
Chris Estreich
70a5d2b48c
Require node v20 everywhere (#922) 2025-03-19 10:46:40 -07:00
Patrick Decat
d8ab111043
ci: update GitHub Actions publish workflow to automatically create GitHub Releases (#1803) 2025-03-19 07:36:45 -04:00
Matt Rubens
d644c9de5a Add all changed files in update-contributors 2025-03-17 13:21:07 -04:00
Matt Rubens
94f176b9bc Change update-contributors script to use a single branch 2025-03-17 12:58:26 -04:00
Matt Rubens
61339ee855 Add find-missing-translations as a CI check 2025-03-17 09:36:39 -04:00
Matt Rubens
dc4efd6a1a
Update update-contributors.yml 2025-03-14 00:40:47 -04:00
Matt Rubens
9bfd0c9c1b Disable husky when updating contributors 2025-03-14 00:35:38 -04:00
Matt Rubens
68cbce8017 Run prettier before checking for contributor changes 2025-03-14 00:09:57 -04:00
Matt Rubens
0bf07f46e3 Use create pull request action more 2025-03-13 23:49:58 -04:00
Matt Rubens
b0ab8e0758
Update .github/workflows/update-contributors.yml
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-03-13 23:44:28 -04:00
Matt Rubens
548f25b005 Better git logic for updating contributors in readme 2025-03-13 23:40:20 -04:00
Matt Rubens
d9ffda56ed Open a PR to update contributors 2025-03-13 23:24:48 -04:00
Matt Rubens
e068bd6a96 Add CI step to update contributors 2025-03-13 22:45:23 -04:00
Matt Rubens
b449bb66dc
Update .github/workflows/marketplace-publish.yml
Co-authored-by: Patrick Decat <pdecat@gmail.com>
2025-03-13 10:39:10 -04:00
Matt Rubens
ef944a6870
Update git config for marketplace publish 2025-03-13 10:32:31 -04:00
cte
4b6def5f31 ContextProxy fix - constructor should not be async 2025-03-11 14:24:21 -07:00
cte
7681a98842 Simplify npm install by automatically installing npm-run-all 2025-03-10 11:36:11 -07:00
Patrick Decat
f99fc59460
ci: tag after packaging but before publishing 2025-03-10 15:29:14 +01:00
Patrick Decat
70d6658ca4
ci: publish git tags to Github (resolves #444) 2025-03-10 11:56:24 +01:00
Matt Rubens
50f76584bc Add telemetry and privacy policy 2025-03-07 03:03:44 -05:00
Chris Estreich
f4a6f06a28 Fix "install dependencies" section of marketplace-publish 2025-03-01 08:18:43 -08:00
Chris Estreich
1d3f5380a8 Move integration tests into its own module 2025-02-28 21:23:11 -08:00
cte
f11c0afa1e Stabilize tests in CI 2025-02-23 02:28:10 -08:00
Matt Rubens
816847c5c0 Add Knip check for unused files 2025-02-23 01:01:51 -05:00
cte
36dd8c9ce4 PR feedback 2025-02-06 08:53:21 -08:00
cte
327e764d85 Validate vsix in publish GHA 2025-02-06 08:38:31 -08:00
Matt Rubens
c0306e3e8e Revert "Merge pull request #799 from RooVetGit/cte/package-json-cleanup"
This reverts commit 00ec57afee, reversing
changes made to b83442e899.
2025-02-06 09:48:06 -05:00
Roo Code
f913d567fa Better organize package.json, optimize tasks.json, split extension and webview linting 2025-02-05 12:15:18 -08:00
Matt Rubens
111020bb50 Removing docs (moving to another repo) 2025-02-04 23:14:57 -05:00
Matt Rubens
0bcfbd46f3 Different approach to escaping 2025-02-02 15:12:25 -05:00
Matt Rubens
7e237df2e8 Revert "Merge pull request #740 from RooVetGit/discord_fix"
This reverts commit e16e132470, reversing
changes made to 0e7e5c50be.
2025-02-02 15:03:41 -05:00
Matt Rubens
dfee716ff0 More secure webhook 2025-02-02 14:59:38 -05:00
Matt Rubens
bf799d72db Post PRs to a thread instead 2025-02-02 14:54:44 -05:00
Matt Rubens
1c5d6f33b3
Discord message cleanup 2025-02-02 01:18:20 -05:00
Matt Rubens
e036c1e33b
Exclude changeset PRs 2025-02-02 00:38:28 -05:00
Matt Rubens
e37692c241
Run discord GHA against pull_request_target 2025-02-02 00:33:26 -05:00
Matt Rubens
58111432da Make runnable on workflow dispatch 2025-02-02 00:04:27 -05:00
Matt Rubens
1d81d871bf Try a link without a preview 2025-02-01 23:56:14 -05:00
Matt Rubens
7440f86d2d
Create discord-pr-notify.yml 2025-02-01 23:39:44 -05:00
cte
5c8df59889 Confirmed that check-openrouter-api-key works; remove debugging 2025-01-31 22:08:02 -08:00
cte
ab2dd09ac6 Test what happens if the secret does not exist 2025-01-31 22:06:25 -08:00
cte
de7f67f71e One more attempt 2025-01-31 22:03:33 -08:00
cte
17fb94cb1b Secrets can't be used in conditionals, apparently 2025-01-31 21:50:06 -08:00
cte
b7cd98da54 Don't run the integration-test job if there's no API key 2025-01-31 21:44:50 -08:00
cte
2e094b409d Switch to Ubuntu; we can enable the full matrix in the future if we care 2025-01-31 16:47:43 -08:00
cte
75bf341057 Try ubuntu-latest 2025-01-31 16:43:01 -08:00
cte
5fd8d8911a Fix ENV var name 2025-01-31 15:18:20 -08:00