From e7c4757271248a2450b894d527f84860df1a6300 Mon Sep 17 00:00:00 2001 From: Sarah Fortune Date: Sun, 17 Aug 2025 09:50:52 +0100 Subject: [PATCH] Update the script get-vscode-usages. (#5630) --- scripts/get-vscode-usages.sh | 26 ++++++++++++++----------- src/core/task/index.ts | 17 ---------------- src/integrations/misc/process-files.ts | 27 +++++++++++--------------- 3 files changed, 26 insertions(+), 44 deletions(-) diff --git a/scripts/get-vscode-usages.sh b/scripts/get-vscode-usages.sh index 79e17da4..26f6fed3 100755 --- a/scripts/get-vscode-usages.sh +++ b/scripts/get-vscode-usages.sh @@ -1,25 +1,30 @@ #!/usr/bin/env bash set -eu -DIR=${1:-src/} +FILES=$(git ls-files src|grep -v test|grep -v vscode|grep -v extension.ts|grep -v evals|grep -v standalone|grep -v /dev/) DEST_DIR=dist-standalone SDK_DEST=$DEST_DIR/vscode-sdk-uses.txt CSS_DEST=$DEST_DIR/vscode-css-uses.txt TMP=/tmp/vscode-sdk-uses.txt.tmp mkdir -p $DEST_DIR +if [[ ${1:-} == "-v" ]]; then + grep -Er --color=always 'vscode[?]?\.' $FILES +fi + { -git grep -h 'vscode\.' $DIR | -grep -Ev '//.*vscode' | # remove commented out code -grep -v vscode.commands.executeCommand | # executeCommand is handled separately -grep -Ev '"vscode' | # remove command strings that get included because they start with vscode -sed 's|.*vscode\.|vscode.|'| # remove everything before vscode. -sed 's/[^a-zA-Z0-9_.].*$//' | # remove everything after last identifier -grep -E '\.[a-z][^.]+$' | # remove types (last part of identifier should be lowercase) -cat > $TMP + grep -Ehr 'vscode[?]?\.' $FILES | + grep -Ev '//.*vscode' | # remove commented out code + grep -v vscode.commands.executeCommand | # executeCommand is handled separately + #grep -Ev '"vscode' | # remove command strings that get included because they start with vscode + sed 's|.*vscode|vscode|'| # remove everything before vscode. + sed 's|?||g' | # remove ? from vcode?.env?.foo + sed 's/[^a-zA-Z0-9_.?].*$//' | # remove everything after last identifier + grep -E '\.[a-z][^.]+$' | # remove types (last part of identifier should be lowercase) + cat > $TMP } { - grep -rh vscode.commands.executeCommand $DIR | + grep -hr 'vscode.commands.executeCommand' $FILES | perl -ne 'print if /["\x27"]/' | # Remove occurrences where the command is not on the same line (line doesnt contain quote chars) :( sed -n 's|.*\(vscode.commands.executeCommand[^,]*\).*|\1|p'| # Remove all params after the first one sed 's|\(".*"\).*|\1)|'| # Close the parantheses @@ -40,4 +45,3 @@ sed 's/[),"\\].*$//' | # remove from the end of the var name to the end of the l sort | uniq > $CSS_DEST } echo Wrote vscode vars used to $(realpath $CSS_DEST) - diff --git a/src/core/task/index.ts b/src/core/task/index.ts index fc7ba376..924a3927 100644 --- a/src/core/task/index.ts +++ b/src/core/task/index.ts @@ -2667,23 +2667,6 @@ export class Task { }).catch(() => {}) } - // we want to get diagnostics AFTER terminal cools down for a few reasons: terminal could be scaffolding a project, dev servers (compilers like webpack) will first re-compile and then send diagnostics, etc - /* - let diagnosticsDetails = "" - const diagnostics = await this.diagnosticsMonitor.getCurrentDiagnostics(this.didEditFile || terminalWasBusy) // if cline ran a command (ie npm install) or edited the workspace then wait a bit for updated diagnostics - for (const [uri, fileDiagnostics] of diagnostics) { - const problems = fileDiagnostics.filter((d) => d.severity === vscode.DiagnosticSeverity.Error) - if (problems.length > 0) { - diagnosticsDetails += `\n## ${path.relative(cwd, uri.fsPath)}` - for (const diagnostic of problems) { - // let severity = diagnostic.severity === vscode.DiagnosticSeverity.Error ? "Error" : "Warning" - const line = diagnostic.range.start.line + 1 // VSCode lines are 0-indexed - const source = diagnostic.source ? `[${diagnostic.source}] ` : "" - diagnosticsDetails += `\n- ${source}Line ${line}: ${diagnostic.message}` - } - } - } - */ this.taskState.didEditFile = false // reset, this lets us know when to wait for saved files to update terminals // waiting for updated diagnostics lets terminal output be the most up-to-date possible diff --git a/src/integrations/misc/process-files.ts b/src/integrations/misc/process-files.ts index 700acdc4..db51fdaf 100644 --- a/src/integrations/misc/process-files.ts +++ b/src/integrations/misc/process-files.ts @@ -1,9 +1,8 @@ -import * as vscode from "vscode" import fs from "fs/promises" import * as path from "path" import sizeOf from "image-size" import { HostProvider } from "@/hosts/host-provider" -import { ShowMessageRequest, ShowMessageType, ShowOpenDialogueRequest } from "@/shared/proto/host/window" +import { ShowMessageType } from "@/shared/proto/host/window" /** * Supports processing of images and other file types @@ -13,26 +12,22 @@ export async function selectFiles(imagesAllowed: boolean): Promise<{ images: str const IMAGE_EXTENSIONS = ["png", "jpg", "jpeg", "webp"] // supported by anthropic and openrouter const OTHER_FILE_EXTENSIONS = ["xml", "json", "txt", "log", "md", "docx", "ipynb", "pdf", "xlsx", "csv"] - const showDialogueResponse = await HostProvider.window.showOpenDialogue( - ShowOpenDialogueRequest.create({ - canSelectMany: true, - openLabel: "Select", - filters: { - files: imagesAllowed ? [...IMAGE_EXTENSIONS, ...OTHER_FILE_EXTENSIONS] : OTHER_FILE_EXTENSIONS, - }, - }), - ) + const showDialogueResponse = await HostProvider.window.showOpenDialogue({ + canSelectMany: true, + openLabel: "Select", + filters: { + files: imagesAllowed ? [...IMAGE_EXTENSIONS, ...OTHER_FILE_EXTENSIONS] : OTHER_FILE_EXTENSIONS, + }, + }) - const fileUris = showDialogueResponse.paths.map((path) => vscode.Uri.file(path)) + const filePaths = showDialogueResponse.paths - if (!fileUris || fileUris.length === 0) { + if (!filePaths || filePaths.length === 0) { return { images: [], files: [] } } - const processFilesPromises = fileUris.map(async (uri) => { - const filePath = uri.fsPath + const processFilesPromises = filePaths.map(async (filePath) => { const fileExtension = path.extname(filePath).toLowerCase().substring(1) - //const fileName = path.basename(filePath) const isImage = IMAGE_EXTENSIONS.includes(fileExtension)