Skip to content

Commit

Permalink
Vscode extension debug tools, editor focus, server control, updated f…
Browse files Browse the repository at this point in the history
…or marketplace (#332)
  • Loading branch information
bkrabach authored Feb 20, 2025
1 parent d9ea031 commit 4c14b0d
Show file tree
Hide file tree
Showing 33 changed files with 1,425 additions and 538 deletions.
3 changes: 3 additions & 0 deletions assistants/codespace-assistant/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["semanticworkbenchteam.mcp-server-vscode"]
}
1 change: 1 addition & 0 deletions assistants/codespace-assistant/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"pyright",
"pytest",
"semanticworkbench",
"semanticworkbenchteam",
"tiktoken",
"updown",
"virtualenvs",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import os

from pydantic_settings import BaseSettings

data_folder = os.environ.get("DATA_FOLDER", ".data")
log_level = os.environ.get("LOG_LEVEL", "INFO")


def load_required_env_var(env_var_name: str) -> str:
value = os.environ.get(env_var_name, "")
if not value:
raise ValueError(f"Missing required environment variable: {env_var_name}")
return value


huggingface_token = load_required_env_var("HUGGINGFACE_TOKEN")
openai_api_key = load_required_env_var("OPENAI_API_KEY")
serpapi_api_key = load_required_env_var("SERPAPI_API_KEY")


class Settings(BaseSettings):
data_folder: str = data_folder
log_level: str = log_level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
# FIXME: Pass the extract_dir into the MarkdownConverter instead of importing the settings
from ... import settings


class _CustomMarkdownify(markdownify.MarkdownConverter):
"""
A custom version of markdownify's MarkdownConverter. Changes include:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def forward_initial_exam_mode(self, file_path, question) -> str | None:
]
return self.model(messages).content

def forward(self, file_path, question: Optional[str] = None) -> str: # type: ignore
def forward(self, file_path, question: Optional[str] = None) -> str: # type: ignore
result = self.md_converter.convert(file_path)

if file_path[-4:] in [".png", ".jpg"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pathvalidate
import requests
from serpapi import GoogleSearch

from smolagents import Tool

from .cookies import COOKIES
Expand Down Expand Up @@ -253,9 +252,8 @@ def _prev_visit(url):
redacted_version = redacted_version.replace("Your browser can't play this video.", "")
web_snippets.append(redacted_version)

content = (
f"A Google search for '{query}' found {len(web_snippets)} results:\n\n## Web Results\n"
+ "\n\n".join(web_snippets)
content = f"A Google search for '{query}' found {len(web_snippets)} results:\n\n## Web Results\n" + "\n\n".join(
web_snippets
)

self._set_page_content(content)
Expand Down Expand Up @@ -329,7 +327,7 @@ def _fetch_page(self, url: str) -> None:
self.page_title = "Error 404"
self._set_page_content(f"## Error 404\n\nFile not found: {download_path}")
except requests.exceptions.RequestException as request_exception:
response_obj = getattr(request_exception, 'response', None)
response_obj = getattr(request_exception, "response", None)
if response_obj:
self.page_title = f"Error {response_obj.status_code}"
content_type = response_obj.headers.get("content-type", "")
Expand Down Expand Up @@ -432,7 +430,6 @@ def forward(self, url: str) -> Any:
with open(new_path, "wb") as f:
f.write(response.content)


return f"File was downloaded and saved under path {new_path}."


Expand Down Expand Up @@ -495,9 +492,7 @@ def forward(self) -> Any:

class PageDownTool(Tool):
name = "page_down"
description = (
"Scroll the viewport DOWN one page-length in the current webpage and return the new viewport content."
)
description = "Scroll the viewport DOWN one page-length in the current webpage and return the new viewport content."
inputs = {}
output_type = "string"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
from dotenv import load_dotenv
from huggingface_hub import InferenceClient
from PIL import Image
from transformers import AutoProcessor

from smolagents import Tool, tool
from transformers import AutoProcessor

# FIXME: Find a way to pass the settings object in, instead of importing it directly
from ... import settings
Expand Down Expand Up @@ -125,7 +124,7 @@ class VisualQATool(Tool):

client = InferenceClient("HuggingFaceM4/idefics2-8b-chatty")

def forward(self, image_path: str, question: Optional[str] = None) -> str: # type: ignore
def forward(self, image_path: str, question: Optional[str] = None) -> str: # type: ignore
output = ""
add_note = False
if not question:
Expand All @@ -140,9 +139,7 @@ def forward(self, image_path: str, question: Optional[str] = None) -> str: # typ
output = process_images_and_text(new_image_path, question, self.client)

if add_note:
output = (
f"You did not provide a particular question, so here is a detailed caption for the image: {output}"
)
output = f"You did not provide a particular question, so here is a detailed caption for the image: {output}"

return output

Expand Down
51 changes: 51 additions & 0 deletions mcp-servers/mcp-server-vscode/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: ['plugin:react/recommended', 'react-app'],
ignorePatterns: ['build', '.*.js', '*.config.js', 'node_modules'],
overrides: [],
parserOptions: {
project: './tsconfig.json',
tsconfigRootDir: __dirname,
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react', '@typescript-eslint', 'import', 'react-hooks', 'react-security'],
rules: {
'@typescript-eslint/brace-style': ['off'],
'@typescript-eslint/space-before-function-paren': [
'error',
{ anonymous: 'always', named: 'never', asyncArrow: 'always' },
],
'@typescript-eslint/semi': ['error', 'always'],
'@typescript-eslint/triple-slash-reference': ['error', { types: 'prefer-import' }],
'@typescript-eslint/indent': ['off'],
'@typescript-eslint/comma-dangle': ['error', 'always-multiline'],
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/member-delimiter-style': [
'error',
{
multiline: {
delimiter: 'semi',
requireLast: true,
},
singleline: {
delimiter: 'semi',
requireLast: false,
},
},
],
'@typescript-eslint/explicit-function-return-type': 'off',
'react/jsx-props-no-spreading': 'warn',
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'react/react-in-jsx-scope': 'off',
},
settings: {
react: {
version: 'detect',
},
},
};
2 changes: 1 addition & 1 deletion mcp-servers/mcp-server-vscode/.vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@vscode/test-cli';

export default defineConfig({
files: 'out/test/**/*.test.js',
files: 'out/test/**/*.test.js',
});
174 changes: 130 additions & 44 deletions mcp-servers/mcp-server-vscode/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,134 @@
// Place your settings in this file to overwrite default and user settings.
{
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"editor.bracketPairColorization.enabled": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.guides.bracketPairs": "active",
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"files.eol": "\n",
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"files.trimTrailingWhitespace": true,
"[json]": {
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off",
"editor.bracketPairColorization.enabled": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.guides.bracketPairs": "active",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"search.exclude": {
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
// For use with optional extension: "streetsidesoftware.code-spell-checker"
"cSpell.ignorePaths": ["ASSISTANT_BOOTSTRAP.md"],
"cSpell.words": [
"amodio",
"charliermarsh",
"dbaeumer",
"esbenp",
"fastmcp",
"modelcontextprotocol",
"nosources",
"pipx",
"toplevel",
"venv",
"vscodeignore",
"yarnrc"
]
"editor.formatOnPaste": true,
"editor.formatOnType": true,
"editor.formatOnSave": true,
"eslint.enable": true,
"eslint.options": {
"overrideConfigFile": ".eslintrc.cjs"
},
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"files.eol": "\n",
"files.exclude": {
"out": false, // set this to true to hide the "out" folder with the compiled JS files
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
},
"files.trimTrailingWhitespace": true,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
}
},
"search.exclude": {
"**/node_modules": true,
"out": true, // set this to false to include "out" folder in search results
"dist": true // set this to false to include "dist" folder in search results
},
"typescript.updateImportsOnFileMove.enabled": "always",
"better-comments.highlightPlainText": true,
"better-comments.multilineComments": true,
"better-comments.tags": [
{
"tag": "!",
"color": "#FF2D00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "?",
"color": "#3498DB",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "//",
"color": "#474747",
"strikethrough": true,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "todo",
"color": "#FF8C00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "fixme",
"color": "#FF2D00",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
},
{
"tag": "*",
"color": "#98C379",
"strikethrough": false,
"underline": false,
"backgroundColor": "transparent",
"bold": false,
"italic": false
}
],
// For use with optional extension: "streetsidesoftware.code-spell-checker"
"cSpell.ignorePaths": ["ASSISTANT_BOOTSTRAP.md"],
"cSpell.words": [
"amodio",
"charliermarsh",
"dbaeumer",
"esbenp",
"fastmcp",
"modelcontextprotocol",
"nosources",
"pipx",
"semanticworkbench",
"toplevel",
"venv",
"vscodeignore",
"yarnrc"
]
}
Loading

0 comments on commit 4c14b0d

Please sign in to comment.