Skip to content

Commit

Permalink
Feature/overhaul (#428)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy authored Jan 14, 2025
1 parent 390b73a commit b92c286
Show file tree
Hide file tree
Showing 42 changed files with 8,900 additions and 4,059 deletions.
8,545 changes: 6,771 additions & 1,774 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "twinny",
"displayName": "twinny - AI Code Completion and Chat",
"description": "Locally hosted AI code completion plugin for vscode",
"version": "3.20.4",
"version": "3.21.0",
"icon": "assets/icon.png",
"keywords": [
"code-inference",
Expand Down Expand Up @@ -511,6 +511,7 @@
"symmetry-core": "^1.0.33",
"tippy.js": "^6.3.7",
"tiptap-markdown": "^0.8.10",
"token.js": "^0.4.8",
"toxe": "^1.1.0",
"uuid": "^9.0.1",
"ws": "^8.18.0"
Expand Down
11 changes: 3 additions & 8 deletions src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export const EVENT_NAME = {
twinnyNewDocument: "twinny-new-document",
twinnyNotification: "twinny-notification",
twinnyOnCompletion: "twinny-on-completion",
twinnyOnCompletionEnd: "twinny-on-end",
twinnyOnLoading: "twinny-on-loading",
twinnyOpenDiff: "twinny-open-diff",
twinnyRerankThresholdChanged: "twinny-rerank-threshold-changed",
twinnySendLanguage: "twinny-send-language",
twinnySendLoader: "twinny-send-loader",
twinnySendRequestBody: "twinny-send-request-body",
twinnySendSymmetryMessage: "twinny-send-symmetry-message",
twinnySendSystemMessage: "twinny-send-system-message",
twinnySendTheme: "twinny-send-theme",
Expand All @@ -84,6 +84,7 @@ export const EVENT_NAME = {
twinnyStopSymmetryProvider: "twinny-stop-symmetry-provider",
twinnySymmetryModels: "twinny-symmetry-models",
twinnyTextSelection: "twinny-text-selection",
twinnyGetModels: "twinny-get-models",
}

export const TWINNY_COMMAND_NAME = {
Expand Down Expand Up @@ -121,12 +122,6 @@ export const CONVERSATION_EVENT_NAME = {
setActiveConversation: "twinny.set-active-conversation",
}

export const TOOL_EVENT_NAME = {
runAllTools: "run-all-tools",
runTool: "run-tool",
rejectTool: "run-on-tool",
}

export const PROVIDER_EVENT_NAME = {
addProvider: "twinny.add-provider",
copyProvider: "twinny.copy-provider",
Expand All @@ -153,6 +148,7 @@ export const INFERENCE_PROVIDERS_STORAGE_KEY = "twinny.inference-providers"

export const GLOBAL_STORAGE_KEY = {
autoConnectSymmetryProvider: "twinny.autoConnectSymmetryProvider",
selectedModel: "twinny.selectedModel",
}

export const WORKSPACE_STORAGE_KEY = {
Expand All @@ -177,7 +173,6 @@ export const EXTENSION_SETTING_KEY = {
export const EXTENSION_CONTEXT_NAME = {
twinnyConversationHistory: "twinnyConversationHistory",
twinnyEnableRag: "twinnyEnableRag",
twinnyEnableTools: "twinnyEnableTools",
twinnyGeneratingText: "twinnyGeneratingText",
twinnyManageProviders: "twinnyManageProviders",
twinnyManageTemplates: "twinnyManageTemplates",
Expand Down
52 changes: 26 additions & 26 deletions src/common/logger.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { Base } from "../extension/base"

export class Logger extends Base {
export class Logger {
private static instance: Logger

public static ErrorType = {
Default: 0, // default color
Fetch_Error: 91, // red -- fetch error
Abort: 90, // gray -- abort
Timeout: 33 // yellow -- timeout
}

constructor() {
super()
private static colorCodes: Record<string, number> = {
Default: 0,
FetchError: 91,
Abort: 90,
Timeout: 33
}

public static getInstance(): Logger {
Expand All @@ -22,27 +16,33 @@ export class Logger extends Base {
}

public log = (message: string) => {
if (!this.config.enableLogging) return
console.log(`[twinny] ${message}`)
}

public error = (err: NodeJS.ErrnoException) => {
if (!this.config.enableLogging) return
console.error(err.message)
public error = (error: Error | string) => {
const errorMessage = error instanceof Error ? error.message : error
console.error(`[twinny:ERROR] ${errorMessage}`)
}

public logError(errorType: string, message: string, error: Error | string) {
const colorCode = Logger.colorCodes[errorType] || Logger.colorCodes.Default
const formattedErrorMessage = this.formatErrorMessage(
colorCode,
message,
error
)
console.error(formattedErrorMessage)
}

public logConsoleError(
errorKey: number,
private formatErrorMessage(
colorCode: number,
message: string,
error: Error | string
): void {
const color = errorKey
const coloredMessage = `\x1b[91m [ERROR_twinny] \x1b[32m Message: ${message} \n \x1b[${color}m Error Type: ${
error instanceof Error ? error.name : "Unknown Error"
} \n Error Message: ${
error instanceof Error ? error.message : error
} \n \x1b[31m`
console.error(coloredMessage, error)
) {
const errorName = error instanceof Error ? error.name : "Unknown Error"
const errorMessage = error instanceof Error ? error.message : error
const coloredMessage = `\x1b[${colorCode}m [ERROR_twinny] \x1b[32m Message: ${message} \n \x1b[${colorCode}m Error Type: ${errorName} \n Error Message: ${errorMessage} \n \x1b[31m`
return coloredMessage
}
}

Expand Down
151 changes: 0 additions & 151 deletions src/common/tool-definitions.ts

This file was deleted.

Loading

0 comments on commit b92c286

Please sign in to comment.