feat: ✨ @terminal context provider
This commit is contained in:
parent
36d517e37d
commit
40cfabb8ce
5 changed files with 64 additions and 1 deletions
|
|
@ -19,6 +19,7 @@ from continuedev.src.continuedev.plugins.steps.main import EditHighlightedCodeSt
|
|||
from continuedev.src.continuedev.plugins.context_providers.search import SearchContextProvider
|
||||
from continuedev.src.continuedev.plugins.context_providers.diff import DiffContextProvider
|
||||
from continuedev.src.continuedev.plugins.context_providers.url import URLContextProvider
|
||||
from continuedev.src.continuedev.plugins.context_providers.terminal import TerminalContextProvider
|
||||
|
||||
config = ContinueConfig(
|
||||
allow_anonymous_telemetry=True,
|
||||
|
|
@ -78,7 +79,8 @@ config = ContinueConfig(
|
|||
preset_urls = [
|
||||
# Add any common urls you reference here so they appear in autocomplete
|
||||
]
|
||||
)
|
||||
),
|
||||
TerminalContextProvider(),
|
||||
],
|
||||
)
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
from typing import List
|
||||
|
||||
from ...core.context import ContextProvider
|
||||
from ...core.main import ContextItem, ContextItemDescription, ContextItemId
|
||||
|
||||
|
||||
class TerminalContextProvider(ContextProvider):
|
||||
title = "terminal"
|
||||
|
||||
workspace_dir: str = None
|
||||
|
||||
def _terminal_context_item(self, content: str = ""):
|
||||
return ContextItem(
|
||||
content=content,
|
||||
description=ContextItemDescription(
|
||||
name="Terminal",
|
||||
description="Reference the contents of the VS Code terminal",
|
||||
id=ContextItemId(provider_title=self.title, item_id=self.title),
|
||||
),
|
||||
)
|
||||
|
||||
async def provide_context_items(self, workspace_dir: str) -> List[ContextItem]:
|
||||
self.workspace_dir = workspace_dir
|
||||
return [self._terminal_context_item()]
|
||||
|
||||
async def get_item(self, id: ContextItemId, query: str) -> ContextItem:
|
||||
if not id.item_id == self.title:
|
||||
raise Exception("Invalid item id")
|
||||
|
||||
terminal_contents = await self.sdk.ide.getTerminalContents()
|
||||
|
||||
return self._terminal_context_item(terminal_contents)
|
||||
|
|
@ -155,5 +155,9 @@ class AbstractIdeProtocolServer(ABC):
|
|||
async def fileExists(self, filepath: str) -> str:
|
||||
"""Check if a file exists"""
|
||||
|
||||
@abstractmethod
|
||||
async def getTerminalContents(self) -> str:
|
||||
"""Get the terminal contents"""
|
||||
|
||||
workspace_directory: str
|
||||
unique_id: str
|
||||
|
|
|
|||
|
|
@ -96,6 +96,18 @@ GoogleContextProvider(
|
|||
|
||||
Note: You can get an API key for free at [serper.dev](https://serper.dev).
|
||||
|
||||
### Terminal
|
||||
|
||||
Type '@terminal' to reference the contents of your IDE's terminal.
|
||||
|
||||
```python
|
||||
from continuedev.src.continuedev.plugins.context_providers.terminal import TerminalContextProvider
|
||||
```
|
||||
|
||||
```python
|
||||
TerminalContextProvider()
|
||||
```
|
||||
|
||||
### Requesting Context Providers
|
||||
|
||||
Not seeing what you want? Create an issue [here](https://github.com/continuedev/continue/issues/new?assignees=TyDunn&labels=enhancement&projects=&template=feature-request-%F0%9F%92%AA.md&title=) to request a new ContextProvider.
|
||||
|
|
|
|||
|
|
@ -49,6 +49,19 @@ export async function activateExtension(context: vscode.ExtensionContext) {
|
|||
})
|
||||
.catch((e) => console.log("Error checking for extension updates: ", e));
|
||||
|
||||
// Add to python.analysis.extraPaths global setting
|
||||
// const pythonConfig = vscode.workspace.getConfiguration("python");
|
||||
// const extraPaths = pythonConfig.get<string[]>("analysis.extraPaths");
|
||||
// const pathToAdd = path.join(os.homedir(), ".continue", "server");
|
||||
// if (extraPaths) {
|
||||
// if (!extraPaths.includes(pathToAdd)) {
|
||||
// extraPaths.push(pathToAdd);
|
||||
// pythonConfig.update("analysis.extraPaths", extraPaths);
|
||||
// }
|
||||
// } else {
|
||||
// pythonConfig.update("analysis.extraPaths", [pathToAdd]);
|
||||
// }
|
||||
|
||||
// Register commands and providers
|
||||
registerAllCodeLensProviders(context);
|
||||
registerAllCommands(context);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue