Skip to content

Commit

Permalink
chore: update pnpm lockfile for modelcontextprotocoltools dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
arafatkatze committed Jan 12, 2025
1 parent 9312e2d commit 218cde8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
11 changes: 7 additions & 4 deletions vscode/src/chat/agentic/CodyTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,14 @@ export class ModelContextProviderTool extends CodyTool {
}

public parse(): string[] {
const parsed = JSON.parse(this.unprocessedText)
console.log(' the parsed for me is ', parsed)
const beforeCleaup = this.unprocessedText
try {
JSON.parse(this.unprocessedText)
} catch {
return []
}
const unparsedText = this.unprocessedText
this.reset()
return [beforeCleaup]
return [unparsedText]
}

public async execute(span: Span, queries: string[]): Promise<ContextItem[]> {
Expand Down
17 changes: 3 additions & 14 deletions vscode/src/chat/agentic/CodyToolProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PromptString, authStatus, firstValueFrom, isDefined, ps } from '@sourcegraph/cody-shared'
import * as vscode from 'vscode'
import { getOpenCtxProviders } from '../../context/openctx'
import { createModelContextProvider } from '../../context/openctx/modelContextProvider'
import type { OpenCtxProvider } from '../../context/openctx/types'
Expand All @@ -11,7 +12,6 @@ import {
getDefaultCodyTools,
registerDefaultTools,
} from './CodyTool'
import * as vscode from 'vscode'
interface CodyShellConfig {
user?: boolean
instance?: boolean
Expand Down Expand Up @@ -86,12 +86,10 @@ export class CodyToolProvider {

private async initializeModelContextProviderTools(): Promise<void> {
// read vscode settings for modelcontextprovidertools
const modelcontextprotocoltoolsEnabled =
vscode.workspace
const modelcontextprotocoltoolsEnabled = vscode.workspace
.getConfiguration()
.get<boolean>('openctx.mcp.enable')
const modelcontextprotocoltoolsURI =
vscode.workspace
const modelcontextprotocoltoolsURI = vscode.workspace
.getConfiguration()
.get<string>('openctx.mcp.uri')
if (!modelcontextprotocoltoolsEnabled || !modelcontextprotocoltoolsURI) {
Expand Down Expand Up @@ -145,8 +143,6 @@ export class CodyToolProvider {
),
},
}
const instructstring = this.getInstruction(config)
console.log(' the instructstring for me is ', instructstring)

// Register the tool
this.toolFactory.registry.register({
Expand All @@ -169,13 +165,6 @@ export class CodyToolProvider {
.filter(isDefined)
}

private getInstruction(config: CodyToolConfig): PromptString {
const { tag } = config.tags
const { instruction, placeholder } = config.prompt
const instructionString = ps`${instruction}: \`<${tag}>${placeholder}</${tag}>\``
return ps`${instructionString}`
}

private async buildOpenCtxCodyTools(): Promise<CodyTool[]> {
const OPENCTX_CONFIG = {
'internal-web-provider': {
Expand Down
8 changes: 4 additions & 4 deletions vscode/src/context/openctx/modelContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import proxy from '@openctx/provider-modelcontextprotocoltools'
import { MODEL_CONTEXT_PROVIDER_URI } from '@sourcegraph/cody-shared'
import type { OpenCtxProvider } from './types'

export async function createModelContextProvider(modelContextProviderToolsURI: string): Promise<OpenCtxProvider> {
export async function createModelContextProvider(
modelContextProviderToolsURI: string
): Promise<OpenCtxProvider> {
return {
providerUri: MODEL_CONTEXT_PROVIDER_URI,

Expand All @@ -12,7 +14,7 @@ export async function createModelContextProvider(modelContextProviderToolsURI: s
{},
{
'mcp.provider.uri': modelContextProviderToolsURI,
// 'file:///Users/arafatkhan/Desktop/servers/src/everything/dist/index.js',
// 'file:///Users/arafatkhan/Desktop/servers/src/everything/dist/index.js',
'mcp.provider.args': [],
}
)
Expand All @@ -23,14 +25,12 @@ export async function createModelContextProvider(modelContextProviderToolsURI: s
async mentions({ query }) {
// returns a list of available tools in MCP
const items = await proxy.mentions!({ query: 'noti' }, {})
console.log(' the items for me are ', items)
return items
},

async items({ mention }) {
// returns the result of a speciic tool of MCP
const items = await proxy.items!({ mention }, {})
console.log(' the items for me are ', items)
return items
},
}
Expand Down

0 comments on commit 218cde8

Please sign in to comment.