From 40f7942801f3cbfa63a295fa14bc6e140adf595b Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:45:12 -0400 Subject: [PATCH] Refactor out of utils --- src/core/ClaudeDev.ts | 7 ++++--- .../context-management.ts => core/sliding-window/index.ts} | 0 src/extension.ts | 2 +- src/integrations/misc/open-file.ts | 2 +- src/services/glob/list-files.ts | 2 +- src/utils/{array-helpers.ts => array.ts} | 0 src/utils/index.ts | 5 ----- src/utils/{path-helpers.ts => path.ts} | 0 8 files changed, 7 insertions(+), 11 deletions(-) rename src/{utils/context-management.ts => core/sliding-window/index.ts} (100%) rename src/utils/{array-helpers.ts => array.ts} (100%) delete mode 100644 src/utils/index.ts rename src/utils/{path-helpers.ts => path.ts} (100%) diff --git a/src/core/ClaudeDev.ts b/src/core/ClaudeDev.ts index 38f454e..d558835 100644 --- a/src/core/ClaudeDev.ts +++ b/src/core/ClaudeDev.ts @@ -23,14 +23,15 @@ import { getApiMetrics } from "../shared/getApiMetrics" import { HistoryItem } from "../shared/HistoryItem" import { Tool, ToolName } from "../shared/Tool" import { ClaudeAskResponse } from "../shared/WebviewMessage" -import { findLast, findLastIndex, formatContentBlockToMarkdown } from "../utils" -import { truncateHalfConversation } from "../utils/context-management" +import { findLast, findLastIndex } from "../utils/array" +import { formatContentBlockToMarkdown } from "../integrations/misc/export-markdown" +import { truncateHalfConversation } from "./sliding-window" import { extractTextFromFile } from "../integrations/misc/extract-text" import { regexSearchFiles } from "../services/ripgrep" import { parseMentions } from "./mentions/context-mentions" import { UrlContentFetcher } from "../services/browser/UrlContentFetcher" import { diagnosticsToProblemsString, getNewDiagnostics } from "../integrations/diagnostics" -import { arePathsEqual } from "../utils/path-helpers" +import { arePathsEqual } from "../utils/path" const SYSTEM_PROMPT = async ( supportsImages: boolean diff --git a/src/utils/context-management.ts b/src/core/sliding-window/index.ts similarity index 100% rename from src/utils/context-management.ts rename to src/core/sliding-window/index.ts diff --git a/src/extension.ts b/src/extension.ts index 8db8d61..6d7cca9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -4,7 +4,7 @@ import * as vscode from "vscode" import { ClaudeDevProvider } from "./core/webview/ClaudeDevProvider" import delay from "delay" import { createClaudeDevAPI } from "./exports" -import "./utils/path-helpers" // necessary to have access to String.prototype.toPosix +import "./utils/path" // necessary to have access to String.prototype.toPosix /* Built using https://github.com/microsoft/vscode-webview-ui-toolkit diff --git a/src/integrations/misc/open-file.ts b/src/integrations/misc/open-file.ts index d74ac7e..45e9876 100644 --- a/src/integrations/misc/open-file.ts +++ b/src/integrations/misc/open-file.ts @@ -1,7 +1,7 @@ import * as path from "path" import * as os from "os" import * as vscode from "vscode" -import { arePathsEqual } from "../../utils/path-helpers" +import { arePathsEqual } from "../../utils/path" export async function openImage(dataUri: string) { const matches = dataUri.match(/^data:image\/([a-zA-Z]+);base64,(.+)$/) diff --git a/src/services/glob/list-files.ts b/src/services/glob/list-files.ts index 1f8b532..f7b0583 100644 --- a/src/services/glob/list-files.ts +++ b/src/services/glob/list-files.ts @@ -1,7 +1,7 @@ import { globby, Options } from "globby" import os from "os" import * as path from "path" -import { arePathsEqual } from "../../utils/path-helpers" +import { arePathsEqual } from "../../utils/path" export async function listFiles(dirPath: string, recursive: boolean, limit: number): Promise<[string[], boolean]> { const absolutePath = path.resolve(dirPath) diff --git a/src/utils/array-helpers.ts b/src/utils/array.ts similarity index 100% rename from src/utils/array-helpers.ts rename to src/utils/array.ts diff --git a/src/utils/index.ts b/src/utils/index.ts deleted file mode 100644 index 14002b8..0000000 --- a/src/utils/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from "../core/webview/getNonce" -export * from "../core/webview/getUri" -export * from "../integrations/misc/process-images" -export * from "../integrations/misc/export-markdown" -export * from "./array-helpers" diff --git a/src/utils/path-helpers.ts b/src/utils/path.ts similarity index 100% rename from src/utils/path-helpers.ts rename to src/utils/path.ts