Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(context-agent): move Deep Cody out of model dropdown #6513

Merged
merged 24 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/shared/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,3 +463,15 @@ export interface FireworksCodeCompletionParams {
languageId: string
user: string | null
}

export interface AgentToolboxSettings {
/**
* Whether the user has enabled the agent.
*/
agent: boolean
/**
* Whether the user has enabled terminal context.
* Defaulted to undefined if shell context is not enabled by site admin via feature flag.
*/
shell?: boolean
abeatrix marked this conversation as resolved.
Show resolved Hide resolved
abeatrix marked this conversation as resolved.
Show resolved Hide resolved
}
124 changes: 0 additions & 124 deletions vscode/src/chat/agentic/CodyChatAgent.ts

This file was deleted.

43 changes: 20 additions & 23 deletions vscode/src/chat/agentic/CodyTool.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import type { Span } from '@opentelemetry/api'
import { type ContextItem, ContextItemSource, ps } from '@sourcegraph/cody-shared'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { URI } from 'vscode-uri'
import { CodyTool, OpenCtxTool, getDefaultCodyTools, registerDefaultTools } from './CodyTool'
import { ToolFactory, ToolRegistry, type ToolStatusCallback } from './CodyToolProvider'
import { mockLocalStorage } from '../../services/LocalStorageProvider'
import { CodyTool, OpenCtxTool } from './CodyTool'
import { CodyToolProvider, ToolFactory, type ToolStatusCallback } from './CodyToolProvider'

const mockCallback: ToolStatusCallback = {
onStart: vi.fn(),
Expand Down Expand Up @@ -35,7 +36,6 @@ describe('CodyTool', () => {
beforeEach(() => {
vi.clearAllMocks()
factory = new ToolFactory()
registerDefaultTools(factory.registry)
mockSpan = {}
factory.registry.register({
name: 'TestTool', // Add this line to match ToolConfiguration interface
Expand All @@ -47,7 +47,7 @@ describe('CodyTool', () => {
prompt: {
instruction: ps`To test the CodyTool class`,
placeholder: ps`TEST_CONTENT`,
example: ps`Test the tool: \`<TOOLTEST><test>sample content</test></TOOLTEST>\``,
examples: [ps`Test the tool: \`<TESTTOOL><test>sample content</test></TESTTOOL>\``],
},
createInstance: config => new TestTool(config),
})
Expand All @@ -63,7 +63,7 @@ describe('CodyTool', () => {
const testTool = factory.createTool('TestTool')
const instruction = testTool?.getInstruction()
expect(instruction).toEqual(
ps`To test the CodyTool class: \`<TOOLTEST><test>TEST_CONTENT</test></TOOLTEST>\``
ps`\`<TOOLTEST><test>TEST_CONTENT</test></TOOLTEST>\`: To test the CodyTool class.\n\t- Test the tool: \`<TESTTOOL><test>sample content</test></TESTTOOL>\``
)
})

Expand Down Expand Up @@ -167,7 +167,7 @@ describe('CodyTool', () => {
prompt: {
instruction: ps`Test OpenCtx provider`,
placeholder: ps`CTX_QUERY`,
example: ps`Test query: \`<TOOLCTX><ctx>query</ctx></TOOLCTX>\``,
examples: [ps`Test query: \`<TOOLCTX><ctx>query</ctx></TOOLCTX>\``],
},
}

Expand All @@ -187,24 +187,21 @@ describe('CodyTool', () => {
},
}))

it('should register all default tools', () => {
const registry = new ToolRegistry()
registerDefaultTools(registry)

expect(registry.get('MemoryTool')).toBeDefined()
expect(registry.get('SearchTool')).toBeDefined()
expect(registry.get('CliTool')).toBeDefined()
expect(registry.get('FileTool')).toBeDefined()
})

it('should create default tools based on shell context', () => {
const contextRetriever = { retrieveContext: vi.fn() }
const provider = CodyToolProvider.instance({ retrieveContext: vi.fn() })

const toolsWithShell = getDefaultCodyTools(true, contextRetriever, factory)
expect(toolsWithShell.length).toBeGreaterThan(0)

const toolsWithoutShell = getDefaultCodyTools(false, contextRetriever, factory)
expect(toolsWithoutShell.length).toBeLessThan(toolsWithShell.length)
it('should register all default tools', () => {
const localStorageData: { [key: string]: unknown } = {}
mockLocalStorage({
get: (key: string) => localStorageData[key],
update: (key: string, value: unknown) => {
localStorageData[key] = value
},
} as any)
const tools = provider.getTools()
expect(tools.some(t => t.config.title.includes('Cody Memory'))).toBeDefined()
expect(tools.some(t => t.config.title.includes('Code Search'))).toBeDefined()
expect(tools.some(t => t.config.title.includes('Terminal'))).toBeDefined()
expect(tools.some(t => t.config.title.includes('Codebase File'))).toBeDefined()
})
})
})
Loading
Loading