Skip to content

Release v0.1.0 with MCS syntax diagnostics and autocomplete features - #14

Merged
SpyC0der77 merged 3 commits into
mainfrom
do-other-stuff
Jun 8, 2026
Merged

SpyC0der77 merged 3 commits into
mainfrom
do-other-stuff

Conversation

@SpyC0der77

@SpyC0der77 SpyC0der77 commented Jun 8, 2026 •

Copy link
Copy Markdown
Owner
  • Added MCS syntax and import diagnostics via the minecraft_script lint command.
  • Implemented autocomplete for keywords, builtins, TextComponent methods, user-defined functions, and import paths.
  • Updated README to reflect new features and configuration options.
  • Enhanced the highlighter extension with new linting capabilities and improved error handling.

Summary by CodeRabbit

  • New Features

    • Added MCS syntax diagnostics using Python-based linting
    • Expanded autocomplete to cover keywords, builtins, TextComponent methods, user-defined functions, and import paths
  • Documentation

    • Updated README and CHANGELOG with new features and configuration details
  • Chores

    • Added two new settings: pythonPath for Python executable override and lintSourcePath for import resolution
    • Bumped version to 0.1.0

- Added MCS syntax and import diagnostics via the `minecraft_script lint` command.
- Implemented autocomplete for keywords, builtins, TextComponent methods, user-defined functions, and import paths.
- Updated README to reflect new features and configuration options.
- Enhanced the highlighter extension with new linting capabilities and improved error handling.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@SpyC0der77, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 23 minutes and 13 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5686f4d1-2045-45a1-ab02-5c318c5fa12b

📥 Commits

Reviewing files that changed from the base of the PR and between ee7840f and f4d8a10.

📒 Files selected for processing (7)
  • highlighter/README.md
  • highlighter/mcs-language-completion.mjs
  • highlighter/mcs-python-bridge.mjs
  • minecraft_script/lint.py
  • minecraft_script/shell_commands.py
  • tests/test_lexer.py
  • tests/test_lint.py
📝 Walkthrough

Walkthrough

Release 0.1.0 adds MCS syntax linting via external Python CLI, context-aware code completions (keywords, methods, imports, user-defined symbols), and supporting configuration. The changes span Python linting implementation and comprehensive test coverage, VS Code bridge integration, and updated documentation.

Changes

MCS Linting and Autocomplete v0.1.0

Layer / File(s) Summary
Extension manifest and configuration
highlighter/package.json
Version bumped to 0.1.0; configuration schema extended with mcsHighlighter.pythonPath and mcsHighlighter.lintSourcePath settings for Python executable and fallback import resolution.
Python linting implementation
minecraft_script/lint.py, minecraft_script/shell_commands.py
New lint.py module exports Diagnostic dataclass and lint_code function that parses MCS code via parse_code_with_imports and converts exceptions into diagnostics. New sh_lint CLI command in shell_commands.py handles --json, --stdin, and --source flags, reads code from file or stdin, runs linting, and outputs diagnostics with appropriate exit codes.
Lexer, parser, and linting test coverage
tests/_parse_helpers.py, tests/test_lexer.py, tests/test_parser.py, tests/test_lint.py
New test utilities enable tokenization and syntax error validation. Comprehensive test suite validates lexer tokenization (numbers, strings, keywords, entity selectors, comments, error cases), parser AST construction (variables, functions, conditionals, loops, imports, selectors, lists, attribute access, and error cases), and lint_code behavior with both unit and CLI integration tests.
Export hover documentation for completions
highlighter/hover-docs.mjs
KEYWORDS, BUILTINS, and METHODS maps changed from private to exported constants, enabling reuse by the completion provider.
Python linting bridge for VS Code
highlighter/mcs-python-bridge.mjs
New lintMcsDocument async function spawns the Python minecraft_script lint CLI with configured interpreter and source path, parses JSON diagnostics, and logs errors to the output channel. toMcsLanguageDiagnostic converts Python diagnostic objects (line, column, message) into VS Code Diagnostic objects with error severity.
MCS language completion provider
highlighter/mcs-language-completion.mjs
New createMcsLanguageCompletionProvider supports context-sensitive completions: import-path matching when typing after import "...", method completions when preceded by ., and general keyword/builtin/function/user-defined completions otherwise. Includes helpers to extract user symbols from document text, normalize import paths, and construct completion items with documentation.
Extension validation and completion wiring
highlighter/extension.mjs
Validation refactored to run Python linting via lintMcsDocument unconditionally and convert results via toMcsLanguageDiagnostic, then conditionally run command-parser linting only when command calls are present. Completion provider switched from command-based wiring to createMcsLanguageCompletionProvider with explicit trigger characters (., ", ', /).
Documentation and release notes
highlighter/CHANGELOG.md, highlighter/README.md, todo.md
CHANGELOG documents v0.1.0 features (linting, completions, settings); README adds linting feature description, settings documentation with Python command invocation details, and installation guidance; todo marks lexer/parser test coverage as complete.

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly Related PRs

  • SpyC0der77/Minecraft-Script#8: The Python lint_code implementation depends on parse_code_with_imports added in this PR, establishing the import-resolution foundation used by linting and diagnostics.
  • SpyC0der77/Minecraft-Script#11: This PR replaces the command-completion wiring introduced in the retrieved PR with a new language-aware completion provider (createMcsLanguageCompletionProvider) for MCS-specific completions.

🐰 Lint and complete, what a feat!
Python talking to VS Code so neat,
Diagnostics spring, completions flow,
Zero-point-one-oh, let's go! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically summarizes the main changes: a v0.1.0 release introducing MCS syntax diagnostics and autocomplete features, which aligns directly with the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch do-other-stuff

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (1)
highlighter/mcs-language-completion.mjs (1)

102-104: 💤 Low value

Consider refining the import path filter for more predictable completions.

The current filter uses completionPath.includes(normalizedPartial) as a fallback, which matches any path containing the partial string anywhere. For example, typing "./foo" would match "./bar/foobar/baz.mcs" because it contains "foo". This broad matching might lead to unexpected suggestions.

Consider restricting the filter to only prefix matching or path-segment matching for more predictable behavior:

🔍 Alternative filtering approach
-      if (normalizedPartial && !completionPath.startsWith(normalizedPartial) && !completionPath.includes(normalizedPartial)) {
+      if (normalizedPartial && !completionPath.startsWith(normalizedPartial)) {
         return undefined
       }

This would only show completions that are valid continuations of what the user has typed, which is typically more intuitive.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@highlighter/mcs-language-completion.mjs` around lines 102 - 104, The filter
currently allows any completionPath that merely includes normalizedPartial,
which yields unexpected matches; update the logic around the
normalizedPartial/completionPath check so it only accepts prefix or path-segment
matches — e.g., require completionPath.startsWith(normalizedPartial) or a
segment boundary match (completionPath === normalizedPartial or
completionPath.startsWith(normalizedPartial + "/") or
completionPath.includes("/" + normalizedPartial + "/") or
completionPath.endsWith("/" + normalizedPartial)); modify the condition that
uses normalizedPartial and completionPath (the block with normalizedPartial &&
!completionPath.startsWith(normalizedPartial) &&
!completionPath.includes(normalizedPartial)) to implement this stricter
matching.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@highlighter/mcs-language-completion.mjs`:
- Around line 71-79: collectUserSymbols() currently returns names from both
FUNCTION_PATTERN and VARIABLE_PATTERN but the completion creation loop always
treats them as functions; update the code so you either (A) make
collectUserSymbols() return symbol objects with a type tag (e.g., {name, kind:
'function'|'variable'}) by checking FUNCTION_PATTERN and VARIABLE_PATTERN, then
in the loop construct vscode.CompletionItem with the appropriate
vscode.CompletionItemKind (Function or Variable) and set
item.detail/item.documentation to "user function" or "user variable"
accordingly, or (B) if you prefer a minimal change, change the static wording to
a generic "user symbol" in the loop and (optionally) set CompletionItemKind to
Variable when the name matches VARIABLE_PATTERN; reference collectUserSymbols,
FUNCTION_PATTERN, VARIABLE_PATTERN, vscode.CompletionItem and
vscode.CompletionItemKind to locate the spots to change.

In `@highlighter/mcs-python-bridge.mjs`:
- Line 120: The Range end calculation uses an unnecessary Math.max that can
conflict with the earlier bounds clamp; replace the expression new
vscode.Range(line, column, line, Math.max(endColumn, column + 1)) with a simple
use of endColumn (i.e., new vscode.Range(line, column, line, endColumn)) so the
computed end comes from the already-clamped endColumn variable; locate the
occurrence in mcs-python-bridge.mjs where Range is constructed using line,
column and endColumn to make this change.
- Around line 114-117: Clamp the computed line index to the document bounds
before calling document.lineAt to avoid RangeError: compute line as
Math.min(Math.max(diagnostic.line - 1, 0), document.lineCount - 1) (using
diagnostic.line and document.lineCount), then continue using
document.lineAt(line) and adjust column/endColumn relative to the retrieved
lineText; update the existing line variable calculation in the code that
currently sets line and calls document.lineAt.

In `@highlighter/README.md`:
- Line 31: The README's sentence "or use the npm CLI after installing
`minecraft-script`" is ambiguous; update the README to either (a) replace that
clause with an explicit npm command and explain how the npm package relates to
the Python package (e.g., whether it wraps/installs the Python tool and what
command to run), or (b) remove the npm reference entirely if there is no
supported npm installation path; locate the sentence in the README that mentions
"python -m minecraft_script lint --json --stdin" and edit the phrase referencing
`minecraft-script`/npm to one clear option with a concrete npm command or a
statement that only the Python pip installation is supported.

In `@minecraft_script/lint.py`:
- Line 48: Replace the overly broad "except BaseException as error" in
minecraft_script/lint.py with "except Exception as error" to avoid catching
system-level exceptions; locate the try/except block that currently uses the
"except BaseException as error" clause and change it to "except Exception as
error". If you need to preserve explicit handling for interrupts or exits, add a
separate clause such as "except (KeyboardInterrupt, SystemExit): raise" before
the Exception handler.

In `@minecraft_script/shell_commands.py`:
- Around line 204-217: When --stdin is used and source_path stays None, replace
direct uses of source_path in result messages with a computed display name (e.g.
display_path = str(source_path) if source_path is not None else "<stdin>") and
use display_path in the print statements that report "no issues found" and the
"file:line:column: message" outputs; update the branch that sets source_path
from filtered_args and the branch that reads from stdin so both paths ensure
display_path is available and used instead of raw source_path (referencing
use_stdin, source_path, filtered_args, and the prints that currently emit
f"{source_path}:..." ).

In `@tests/test_lexer.py`:
- Around line 7-10: The test test_tokenizes_numbers shows "3.14" is split into
"3", ".", "14" (TT_NUMBER, TT_DOT, TT_NUMBER) — fix either the lexer or the
test: if decimals should be numeric literals, update the lexer (function
tokenize in minecraft_script/lexer.py and any helper that emits TT_NUMBER) to
recognize a float pattern (digits optionally followed by '.' and digits) and
emit a single TT_NUMBER token for "3.14"; if splitting is intentional, rename
the test and adjust expected values in test_tokenizes_numbers/token_types to
reflect that decimals are not numbers (or add a new test test_tokenizes_floats
asserting a single TT_NUMBER for floats). Ensure references to TT_DOT are
updated only if you change tokenization behavior.

---

Nitpick comments:
In `@highlighter/mcs-language-completion.mjs`:
- Around line 102-104: The filter currently allows any completionPath that
merely includes normalizedPartial, which yields unexpected matches; update the
logic around the normalizedPartial/completionPath check so it only accepts
prefix or path-segment matches — e.g., require
completionPath.startsWith(normalizedPartial) or a segment boundary match
(completionPath === normalizedPartial or
completionPath.startsWith(normalizedPartial + "/") or
completionPath.includes("/" + normalizedPartial + "/") or
completionPath.endsWith("/" + normalizedPartial)); modify the condition that
uses normalizedPartial and completionPath (the block with normalizedPartial &&
!completionPath.startsWith(normalizedPartial) &&
!completionPath.includes(normalizedPartial)) to implement this stricter
matching.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 180cfa96-f0c2-4efc-95e5-7a9331bb720a

📥 Commits

Reviewing files that changed from the base of the PR and between 3ba306d and ee7840f.

📒 Files selected for processing (14)
  • highlighter/CHANGELOG.md
  • highlighter/README.md
  • highlighter/extension.mjs
  • highlighter/hover-docs.mjs
  • highlighter/mcs-language-completion.mjs
  • highlighter/mcs-python-bridge.mjs
  • highlighter/package.json
  • minecraft_script/lint.py
  • minecraft_script/shell_commands.py
  • tests/_parse_helpers.py
  • tests/test_lexer.py
  • tests/test_lint.py
  • tests/test_parser.py
  • todo.md

Comment thread highlighter/mcs-language-completion.mjs Outdated
Comment thread highlighter/mcs-python-bridge.mjs Outdated
Comment thread highlighter/mcs-python-bridge.mjs Outdated
Comment thread highlighter/README.md Outdated
Comment thread minecraft_script/lint.py Outdated
Comment thread minecraft_script/shell_commands.py
Comment thread tests/test_lexer.py Outdated

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 issues found across 14 files

Tip: instead of fixing issues one by one fix them all with cubic

Re-trigger cubic

Comment thread highlighter/mcs-language-completion.mjs
Comment thread minecraft_script/lint.py Outdated
Comment thread highlighter/mcs-language-completion.mjs Outdated
Comment thread minecraft_script/lint.py Outdated
Comment thread highlighter/mcs-python-bridge.mjs
Comment thread minecraft_script/shell_commands.py
- Improved user symbol collection to differentiate between functions and variables in autocomplete suggestions.
- Updated completion item details and documentation to reflect the type of user-defined symbols.
- Refined diagnostic line calculation in the Python bridge for better accuracy.
- Enhanced README to clarify installation instructions for the Python package and npm wrapper.
- Improved error handling in linting functions to manage exceptions more effectively.
- Updated shell command outputs to display the correct source path for diagnostics.
- Added tests for tokenization of integer literals and decimal-like sequences.
@kilo-code-bot

kilo-code-bot Bot commented Jun 8, 2026 •

Copy link
Copy Markdown

Code Review Summary

Status: 0 New Issues Found | Recommendation: Address existing flagged issues before merge

Other Observations (not in diff)

Existing review comments have already identified issues in this PR, including a critical line/column swap in minecraft_script/lint.py:9 and other flagged items. No additional issues were introduced.

Files Reviewed (14 files)
  • highlighter/CHANGELOG.md - no issues
  • highlighter/README.md - no issues
  • highlighter/extension.mjs - no issues
  • highlighter/hover-docs.mjs - no issues
  • highlighter/mcs-language-completion.mjs - no new issues (existing comments)
  • highlighter/mcs-python-bridge.mjs - no new issues
  • highlighter/package.json - no issues
  • minecraft_script/lint.py - existing critical issue flagged in prior review
  • minecraft_script/shell_commands.py - no new issues (existing comments)
  • tests/_parse_helpers.py - no issues
  • tests/test_lexer.py - no issues
  • tests/test_lint.py - no issues
  • tests/test_parser.py - no issues
  • todo.md - no issues

Reviewed by laguna-m.1-20260312:free · 312,085 tokens

- Updated the import path completion function to include a range for more accurate text replacement.
- Improved the regex pattern for position extraction in linting to accommodate various error messages.
- Added new tests for diagnostic parsing from exceptions to ensure accurate line and column reporting.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="highlighter/mcs-language-completion.mjs">

<violation number="1" location="highlighter/mcs-language-completion.mjs:34">
P2: Method completion detection regressed: it checks the character before the cursor instead of the character before the current word, so `obj.met...` falls back to general completions after the first typed letter.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Fix all with cubic | Re-trigger cubic


const wordRange = document.getWordRangeAtPosition(position, /[A-Za-z_][A-Za-z0-9_-]*/)
const currentWord = wordRange ? document.getText(wordRange) : ''
const charBefore = position.character > 0 ? linePrefix[position.character - 1] : ''

@cubic-dev-ai cubic-dev-ai Bot Jun 8, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Method completion detection regressed: it checks the character before the cursor instead of the character before the current word, so obj.met... falls back to general completions after the first typed letter.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At highlighter/mcs-language-completion.mjs, line 34:

<comment>Method completion detection regressed: it checks the character before the cursor instead of the character before the current word, so `obj.met...` falls back to general completions after the first typed letter.</comment>

<file context>
@@ -18,15 +18,20 @@ export function createMcsLanguageCompletionProvider() {
-      const charBefore = wordRange && wordRange.start.character > 0
-        ? linePrefix[wordRange.start.character - 1]
-        : ''
+      const charBefore = position.character > 0 ? linePrefix[position.character - 1] : ''
 
       const items = charBefore === '.'
</file context>
Fix with cubic

@SpyC0der77
SpyC0der77 merged commit 040a3c9 into main Jun 8, 2026
6 checks passed
@SpyC0der77
SpyC0der77 deleted the do-other-stuff branch June 8, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant