Merge branch 'main' into reranker-scores-error

This commit is contained in:
uinstinct 2025-08-11 08:23:03 +05:30
commit e3b923668d
15 changed files with 801 additions and 184 deletions

342
.github/workflows/similar-issues.yml vendored Normal file
View file

@ -0,0 +1,342 @@
name: Similar Issue Search & Discussion Suggestion
on:
issues:
types: [opened]
pull_request:
types: [opened]
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Checkout deja-view
uses: actions/checkout@v4
with:
repository: 'bdougie/deja-view'
# Option 1: Pin to specific commit (most secure)
ref: '45e7696' # Pin to specific commit for stability
# Option 2: Use a tag (recommended after creating releases)
# ref: 'v1.0.0'
# Option 3: Use main branch (least secure, gets latest changes)
# ref: 'main'
path: deja-view
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
cd deja-view
pip install -r requirements.txt
- name: Index repository if needed
env:
CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }}
CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }}
CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd deja-view
# Index the repository (this will update existing index)
python cli.py index "${{ github.repository }}" --max-issues 200 || true
- name: Search for similar issues
id: search
env:
CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }}
CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }}
CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd deja-view
# Determine if this is an issue or PR
if [ "${{ github.event_name }}" = "pull_request" ]; then
ISSUE_URL="https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
THRESHOLD="0.85"
TOP_K="5"
else
ISSUE_URL="https://github.com/${{ github.repository }}/issues/${{ github.event.issue.number }}"
THRESHOLD="0.7"
TOP_K="5"
fi
# Create a Python script to search and format as JSON
cat << 'PYTHON_SCRIPT' > search_similar.py
import sys
import json
import os
from github_similarity_service import SimilarityService
issue_url = sys.argv[1]
threshold = float(sys.argv[2])
top_k = int(sys.argv[3])
# Parse issue number from URL
issue_number = int(issue_url.split('/')[-1])
repo_parts = issue_url.split('/')
owner = repo_parts[3]
repo = repo_parts[4]
service = SimilarityService()
# Find similar issues
similar = service.find_similar_issues(
owner=owner,
repo=repo,
issue_number=issue_number,
top_k=top_k,
min_similarity=threshold
)
# Format as JSON
print(json.dumps(similar))
PYTHON_SCRIPT
# Search for similar issues
SIMILAR_ISSUES=$(python search_similar.py "$ISSUE_URL" "$THRESHOLD" "$TOP_K")
# Save to output
echo "similar_issues<<EOF" >> $GITHUB_OUTPUT
echo "$SIMILAR_ISSUES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Check if any similar issues found
if [ "$(echo "$SIMILAR_ISSUES" | jq '. | length')" -gt 0 ]; then
echo "has_similar=true" >> $GITHUB_OUTPUT
else
echo "has_similar=false" >> $GITHUB_OUTPUT
fi
- name: Check if issue should be a discussion
id: discussion_check
if: github.event_name == 'issues'
env:
CHROMA_API_KEY: ${{ secrets.CHROMA_CLOUD_API_KEY }}
CHROMA_TENANT: ${{ secrets.CHROMA_TENANT }}
CHROMA_DATABASE: ${{ secrets.CHROMA_DATABASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd deja-view
# Create a Python script to analyze the issue
cat << 'PYTHON_SCRIPT' > check_discussion.py
import os
import json
import re
from github_similarity_service import SimilarityService
# Get issue details from environment
issue_title = os.environ.get('ISSUE_TITLE', '')
issue_body = os.environ.get('ISSUE_BODY', '')
issue_labels = json.loads(os.environ.get('ISSUE_LABELS', '[]'))
# Mock Issue object for analysis
class MockIssue:
def __init__(self):
self.title = issue_title
self.body = issue_body
self.labels = issue_labels
self.state = 'open'
self.number = int(os.environ.get('ISSUE_NUMBER', 0))
self.created_at = ''
self.updated_at = ''
self.url = ''
service = SimilarityService()
issue = MockIssue()
score, reasons = service._calculate_discussion_score(issue)
result = {
'score': score,
'reasons': reasons,
'should_be_discussion': score >= 0.5,
'confidence': 'high' if score >= 0.7 else 'medium' if score >= 0.5 else 'low'
}
print(json.dumps(result))
PYTHON_SCRIPT
# Run the analysis
DISCUSSION_ANALYSIS=$(ISSUE_TITLE="${{ github.event.issue.title }}" \
ISSUE_BODY='${{ github.event.issue.body }}' \
ISSUE_LABELS='${{ toJson(github.event.issue.labels.*.name) }}' \
ISSUE_NUMBER="${{ github.event.issue.number }}" \
python check_discussion.py)
echo "analysis<<EOF" >> $GITHUB_OUTPUT
echo "$DISCUSSION_ANALYSIS" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Extract whether it should be a discussion
SHOULD_BE_DISCUSSION=$(echo "$DISCUSSION_ANALYSIS" | jq -r '.should_be_discussion')
echo "should_be_discussion=$SHOULD_BE_DISCUSSION" >> $GITHUB_OUTPUT
# Extract confidence level
CONFIDENCE=$(echo "$DISCUSSION_ANALYSIS" | jq -r '.confidence')
echo "confidence=$CONFIDENCE" >> $GITHUB_OUTPUT
- name: Comment with analysis
uses: actions/github-script@v7
with:
script: |
let comment = '';
const hasSimilar = '${{ steps.search.outputs.has_similar }}' === 'true';
const isPR = '${{ github.event_name }}' === 'pull_request';
const shouldBeDiscussion = !isPR && '${{ steps.discussion_check.outputs.should_be_discussion }}' === 'true';
// Add similar issues section if found
if (hasSimilar) {
const similarIssues = JSON.parse(`${{ steps.search.outputs.similar_issues }}`);
if (isPR) {
// Filter only open issues for PRs
const openIssues = similarIssues.filter(issue => issue.state === 'open');
if (openIssues.length > 0) {
// Simple table format for PRs
comment += '## 📋 Related Open Issues\n\n';
comment += 'These open issues appear to be related to this PR (≥85% similarity):\n\n';
comment += '| # | Title | Similarity |\n';
comment += '|---|-------|------------|\n';
openIssues.forEach(issue => {
const similarity = (issue.similarity * 100).toFixed(0);
const title = issue.title.length > 50 ? issue.title.substring(0, 47) + '...' : issue.title;
comment += `| [#${issue.number}](${issue.url}) | ${title} | ${similarity}% |\n`;
});
comment += '\n';
comment += '_Consider closing related issues if this PR addresses them._\n';
} else {
// Don't add any comment if no open issues found
return;
}
} else {
// Original format for issues
comment += '## 🔍 Similar Issues Found\n\n';
comment += 'I found some existing issues that might be related:\n\n';
similarIssues.forEach((issue, index) => {
const similarity = (issue.similarity * 100).toFixed(1);
const state = issue.state === 'open' ? '🟢' : '🔴';
comment += `${index + 1}. ${state} [#${issue.number}: ${issue.title}](${issue.url}) (${similarity}% similar)\n`;
if (issue.summary) {
comment += ` > ${issue.summary.substring(0, 150)}${issue.summary.length > 150 ? '...' : ''}\n`;
}
comment += '\n';
});
comment += '\n';
}
}
// Add discussion suggestion if applicable
if (shouldBeDiscussion) {
const analysis = JSON.parse(`${{ steps.discussion_check.outputs.analysis }}`);
const confidence = '${{ steps.discussion_check.outputs.confidence }}';
if (hasSimilar) {
comment += '---\n\n';
}
comment += '## 💬 Discussion Suggestion\n\n';
const confidenceEmoji = {
'high': '🟢',
'medium': '🟡',
'low': '🔴'
};
comment += `This issue might be better suited as a **GitHub Discussion** ${confidenceEmoji[confidence] || ''}\n\n`;
comment += `**Confidence**: ${confidence.charAt(0).toUpperCase() + confidence.slice(1)} (${(analysis.score * 100).toFixed(0)}%)\n\n`;
if (analysis.reasons && analysis.reasons.length > 0) {
comment += '**Reasons**:\n';
analysis.reasons.forEach(reason => {
comment += `- ${reason}\n`;
});
comment += '\n';
}
comment += 'GitHub Discussions are great for:\n';
comment += '- Questions and help requests\n';
comment += '- Feature requests and ideas\n';
comment += '- General feedback and brainstorming\n';
comment += '- Community conversations\n\n';
comment += '_Consider converting this to a discussion if it\'s not a bug report or actionable task._\n';
}
// Only comment if we have something to say
if (comment) {
comment += '\n---\n';
comment += '_This analysis was automatically generated by [deja-view](https://github.com/bdougie/deja-view)._';
if ('${{ github.event_name }}' === 'pull_request') {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: comment
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: comment
});
}
}
- name: Add labels
if: github.event_name == 'issues'
uses: actions/github-script@v7
with:
script: |
const labels = [];
// Check for duplicate
if ('${{ steps.search.outputs.has_similar }}' === 'true') {
const similarIssues = JSON.parse(`${{ steps.search.outputs.similar_issues }}`);
const hasDuplicate = similarIssues.some(issue => issue.similarity > 0.9);
if (hasDuplicate) {
labels.push('potential-duplicate');
}
}
// Check for discussion suggestion
if ('${{ steps.discussion_check.outputs.should_be_discussion }}' === 'true') {
const confidence = '${{ steps.discussion_check.outputs.confidence }}';
if (confidence === 'high') {
labels.push('should-be-discussion');
} else if (confidence === 'medium') {
labels.push('discussion');
}
}
// Add labels if any
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: labels
});
}

View file

@ -63,13 +63,22 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
) {
return true;
}
// LGAI EXAONE models expose an OpenAI-compatible API with tool
// calling support when served via frameworks like vLLM
if (lower.includes("exaone")) {
return true;
}
if (lower.includes("gpt-oss")) {
return true;
}
// https://ai.google.dev/gemma/docs/capabilities/function-calling
if (lower.startsWith("gemma")) {
return true;
}
// firworks-ai https://docs.fireworks.ai/guides/function-calling
if (model.startsWith("accounts/fireworks/models/")) {
switch (model.substring(26)) {
@ -179,6 +188,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
"firefunction-v2",
"mistral",
"devstral",
"exaone",
"gpt-oss",
].some((part) => modelName.toLowerCase().includes(part))
) {
@ -269,6 +279,7 @@ export const PROVIDER_TOOL_SUPPORT: Record<string, (model: string) => boolean> =
"deepseek/deepseek-chat",
"meta-llama/llama-4",
"all-hands/openhands-lm-32b",
"lgai-exaone/exaone",
];
for (const prefix of supportedPrefixes) {
if (model.toLowerCase().startsWith(prefix)) {
@ -339,6 +350,7 @@ export function modelSupportsNativeTools(modelDescription: ModelDescription) {
if (modelDescription.capabilities?.tools !== undefined) {
return modelDescription.capabilities.tools;
}
const providerSupport = PROVIDER_TOOL_SUPPORT[modelDescription.provider];
if (!providerSupport) {
return false;

View file

@ -352,4 +352,123 @@ describe("runTerminalCommandImpl", () => {
expect(result[0].content).toBe("Command is running in the background...");
expect(result[0].status).toBe("Command is running in the background...");
});
it("should handle missing workspace directory gracefully", async () => {
// Mock IDE to return empty workspace directories
const mockEmptyWorkspace = jest.fn().mockReturnValue(Promise.resolve([]));
// Create IDE mock with empty workspace
const mockIde = {
getIdeInfo: jest
.fn()
.mockReturnValue(Promise.resolve({ remoteName: "local" })),
getWorkspaceDirs: mockEmptyWorkspace,
runCommand: jest.fn(),
getIdeSettings: jest.fn(),
getDiff: jest.fn(),
getClipboardContent: jest.fn(),
isTelemetryEnabled: jest.fn(),
readFile: jest.fn(),
writeFile: jest.fn(),
renameFile: jest.fn(),
deleteFile: jest.fn(),
globFiles: jest.fn(),
ls: jest.fn(),
};
const extras = {
ide: mockIde as unknown as IDE,
llm: {} as any,
fetch: {} as any,
tool: {} as any,
toolCallId: "test-tool-call",
} as ToolExtras;
const command = `node -e "console.log('no workspace test')"`;
const args = { command, waitForCompletion: true };
const result = await runTerminalCommandImpl(args, extras);
// Should still work - falling back to HOME or cwd
expect(result).toHaveLength(1);
expect(result[0].name).toBe("Terminal");
expect(result[0].description).toBe("Terminal command output");
expect(result[0].content).toContain("no workspace test");
expect(result[0].status).toBe("Command completed");
// Verify workspace dirs was called but returned empty
expect(mockEmptyWorkspace).toHaveBeenCalled();
});
it("should handle case where cwd fallbacks all fail", async () => {
// Mock IDE to return empty workspace directories
const mockEmptyWorkspace = jest.fn().mockReturnValue(Promise.resolve([]));
// Save original environment variables and process.cwd
const originalHome = process.env.HOME;
const originalUserProfile = process.env.USERPROFILE;
const originalCwd = process.cwd;
try {
// Mock all fallbacks to fail
delete process.env.HOME;
delete process.env.USERPROFILE;
process.cwd = jest.fn().mockImplementation(() => {
throw new Error("Current directory unavailable");
}) as jest.MockedFunction<() => string>;
// Create IDE mock with empty workspace
const mockIde = {
getIdeInfo: jest
.fn()
.mockReturnValue(Promise.resolve({ remoteName: "local" })),
getWorkspaceDirs: mockEmptyWorkspace,
runCommand: jest.fn(),
getIdeSettings: jest.fn(),
getDiff: jest.fn(),
getClipboardContent: jest.fn(),
isTelemetryEnabled: jest.fn(),
readFile: jest.fn(),
writeFile: jest.fn(),
renameFile: jest.fn(),
deleteFile: jest.fn(),
globFiles: jest.fn(),
ls: jest.fn(),
};
const extras = {
ide: mockIde as unknown as IDE,
llm: {} as any,
fetch: {} as any,
tool: {} as any,
toolCallId: "test-tool-call",
} as ToolExtras;
const command = `node -e "console.log('fallback test')"`;
const args = { command, waitForCompletion: true };
// This should now handle the case gracefully by falling back to temp directory
const result = await runTerminalCommandImpl(args, extras);
// Should work using the temp directory as fallback
expect(result).toHaveLength(1);
expect(result[0].name).toBe("Terminal");
expect(result[0].content).toContain("fallback test");
expect(result[0].status).toBe("Command completed");
console.log(
"Successfully handled cwd fallback to temp directory:",
result[0].status,
);
} finally {
// Always restore original values
if (originalHome !== undefined) {
process.env.HOME = originalHome;
}
if (originalUserProfile !== undefined) {
process.env.USERPROFILE = originalUserProfile;
}
process.cwd = originalCwd;
}
});
});

View file

@ -1,5 +1,6 @@
import iconv from "iconv-lite";
import childProcess from "node:child_process";
import os from "node:os";
import util from "node:util";
// Automatically decode the buffer according to the platform to avoid garbled Chinese
function getDecodedOutput(data: Buffer): string {
@ -75,89 +76,132 @@ export const runTerminalCommandImpl: ToolImpl = async (args, extras) => {
if (ENABLED_FOR_REMOTES.includes(ideInfo.remoteName)) {
// For streaming output
if (extras.onPartialOutput) {
return new Promise((resolve, reject) => {
try {
const getWorkspaceDirsPromise = extras.ide.getWorkspaceDirs();
getWorkspaceDirsPromise
.then((workspaceDirs) => {
const cwd = fileURLToPath(workspaceDirs[0]);
let terminalOutput = "";
try {
const workspaceDirs = await extras.ide.getWorkspaceDirs();
if (!waitForCompletion) {
const status = "Command is running in the background...";
if (extras.onPartialOutput) {
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: "",
status: status,
},
],
});
}
}
// Handle case where no workspace is available
let cwd: string;
if (workspaceDirs.length > 0) {
cwd = fileURLToPath(workspaceDirs[0]);
} else {
// Default to user's home directory with fallbacks
try {
cwd = process.env.HOME || process.env.USERPROFILE || process.cwd();
} catch (error) {
// Final fallback if even process.cwd() fails - use system temp directory
cwd = os.tmpdir();
}
}
// Use spawn with color environment
const { shell, args } = getShellCommand(command);
const childProc = childProcess.spawn(shell, args, {
cwd,
env: getColorEnv(), // Add enhanced environment for colors
return new Promise((resolve, reject) => {
let terminalOutput = "";
if (!waitForCompletion) {
const status = "Command is running in the background...";
if (extras.onPartialOutput) {
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: "",
status: status,
},
],
});
}
}
childProc.stdout?.on("data", (data) => {
// Skip if this process has been backgrounded
if (isProcessBackgrounded(toolCallId)) return;
// Use spawn with color environment
const { shell, args } = getShellCommand(command);
const childProc = childProcess.spawn(shell, args, {
cwd,
env: getColorEnv(), // Add enhanced environment for colors
});
const newOutput = getDecodedOutput(data);
terminalOutput += newOutput;
childProc.stdout?.on("data", (data) => {
// Skip if this process has been backgrounded
if (isProcessBackgrounded(toolCallId)) return;
// Send partial output to UI
if (extras.onPartialOutput) {
const status = waitForCompletion
? ""
: "Command is running in the background...";
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
],
});
}
const newOutput = getDecodedOutput(data);
terminalOutput += newOutput;
// Send partial output to UI
if (extras.onPartialOutput) {
const status = waitForCompletion
? ""
: "Command is running in the background...";
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
],
});
}
});
childProc.stderr?.on("data", (data) => {
// Skip if this process has been backgrounded
if (isProcessBackgrounded(toolCallId)) return;
childProc.stderr?.on("data", (data) => {
// Skip if this process has been backgrounded
if (isProcessBackgrounded(toolCallId)) return;
const newOutput = getDecodedOutput(data);
terminalOutput += newOutput;
const newOutput = getDecodedOutput(data);
terminalOutput += newOutput;
// Send partial output to UI, status is not required
if (extras.onPartialOutput) {
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
},
],
});
}
// Send partial output to UI, status is not required
if (extras.onPartialOutput) {
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
},
],
});
}
});
// If we don't need to wait for completion, resolve immediately
if (!waitForCompletion) {
const status = "Command is running in the background...";
// If we don't need to wait for completion, resolve immediately
if (!waitForCompletion) {
const status = "Command is running in the background...";
resolve([
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
]);
}
childProc.on("close", (code) => {
// If this process has been backgrounded, clean it up from the map and return
if (isProcessBackgrounded(toolCallId)) {
removeBackgroundedProcess(toolCallId);
return;
}
if (waitForCompletion) {
// Normal completion, resolve now
if (code === 0) {
const status = "Command completed";
resolve([
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
]);
} else {
const status = `Command failed with exit code ${code}`;
resolve([
{
name: "Terminal",
@ -167,80 +211,58 @@ export const runTerminalCommandImpl: ToolImpl = async (args, extras) => {
},
]);
}
} else {
// Already resolved, just update the UI with final output
if (extras.onPartialOutput) {
const status =
code === 0 || !code
? "\nBackground command completed"
: `\nBackground command failed with exit code ${code}`;
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
],
});
}
}
});
childProc.on("close", (code) => {
// If this process has been backgrounded, clean it up from the map and return
if (isProcessBackgrounded(toolCallId)) {
removeBackgroundedProcess(toolCallId);
return;
}
childProc.on("error", (error) => {
// If this process has been backgrounded, clean it up from the map and return
if (isProcessBackgrounded(toolCallId)) {
removeBackgroundedProcess(toolCallId);
return;
}
if (waitForCompletion) {
// Normal completion, resolve now
if (code === 0) {
const status = "Command completed";
resolve([
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
]);
} else {
const status = `Command failed with exit code ${code}`;
resolve([
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
]);
}
} else {
// Already resolved, just update the UI with final output
if (extras.onPartialOutput) {
const status =
code === 0 || !code
? "\nBackground command completed"
: `\nBackground command failed with exit code ${code}`;
extras.onPartialOutput({
toolCallId,
contextItems: [
{
name: "Terminal",
description: "Terminal command output",
content: terminalOutput,
status: status,
},
],
});
}
}
});
childProc.on("error", (error) => {
// If this process has been backgrounded, clean it up from the map and return
if (isProcessBackgrounded(toolCallId)) {
removeBackgroundedProcess(toolCallId);
return;
}
reject(error);
});
})
.catch((error) => {
reject(error);
});
} catch (error: any) {
reject(error);
}
});
reject(error);
});
});
} catch (error: any) {
throw error;
}
} else {
// Fallback to non-streaming for older clients
const workspaceDirs = await extras.ide.getWorkspaceDirs();
const cwd = fileURLToPath(workspaceDirs[0]);
// Handle case where no workspace is available
let cwd: string;
if (workspaceDirs.length > 0) {
cwd = fileURLToPath(workspaceDirs[0]);
} else {
// Default to user's home directory with fallbacks
try {
cwd = process.env.HOME || process.env.USERPROFILE || process.cwd();
} catch (error) {
// Final fallback if even process.cwd() fails - use system temp directory
cwd = os.tmpdir();
}
}
if (waitForCompletion) {
// Standard execution, waiting for completion

View file

@ -20,6 +20,7 @@ export const DEFAULT_AUTOCOMPLETE_OPTS: TabAutocompleteOptions = {
useImports: true,
transform: true,
showWhateverWeHaveAtXMs: 300,
// Experimental options: true = enabled, false = disabled, number = enabled w priority
experimental_includeClipboard: true,
experimental_includeRecentlyVisitedRanges: true,
experimental_includeRecentlyEditedRanges: true,

View file

@ -84,7 +84,7 @@ Then, add the model to your configuration:
Once the model has been downloaded, you should begin to see completions in VS Code.
NOTE: Typically, thinking-type models are not recommended as they generate more slowly and are not suitable for scenarios that require speed.
NOTE: Typically, thinking-type models are not recommended as they generate more slowly and are not suitable for scenarios that require speed.
However, if you use any thinking-switchable models, you can configure these models for autocomplete functions by turning off the thinking mode.
@ -92,7 +92,7 @@ For example:
<Tabs>
<Tab title="YAML">
```yaml title="config.yaml"
```yaml title="config.yaml"
models:
- name: Qwen3 without Thinking for Autocomplete
provider: ollama
@ -122,9 +122,32 @@ The following settings can be configured for autocompletion in the IDE extension
- `Multiline Autocompletions`: Controls multiline completions for autocomplete. Can be set to `always`, `never`, or `auto`. Defaults to `auto`
- `Disable autocomplete in files`: List of comma-separated glob pattern to disable autocomplete in matching files. E.g., "\_/.md, \*/.txt"
### `config.json` Configuration
### Autocomplete Configuration
The `config.json` configuration format (deprecated) offers further configuration options through `tabAutocompleteOptions`. See the [JSON Reference](/reference) for more details.
#### YAML Configuration
The `config.yaml` format offers model-level configuration using the `autocompleteOptions` field. See the [YAML Reference](/reference#models) for more details.
```yaml
models:
- name: Codestral
provider: mistral
model: codestral-latest
roles:
- autocomplete
autocompleteOptions:
disable: false
maxPromptTokens: 1024
debounceDelay: 250
modelTimeout: 150
maxSuffixPercentage: 0.2
prefixPercentage: 0.3
onlyMyCode: true
```
#### JSON Configuration (Deprecated)
The `config.json` configuration format offers configuration options through `tabAutocompleteOptions`. See the [JSON Reference](/reference/json-reference#tabautocomplete-options) for more details.
## FAQs

View file

@ -175,6 +175,7 @@ The `models` section defines the language models used in your configuration. Mod
- `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used.
- `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. See the [Model Capabilities guide](/customize/deep-dives/model-capabilities) for detailed information. Supported capabilities include:
- `tool_use`: Enables function/tool calling support (required for Agent mode)
- `image_input`: Enables image upload and processing support
@ -228,6 +229,21 @@ The `models` section defines the language models used in your configuration. Mod
- `key`: Path to the client certificate key file.
- `passphrase`: Optional passphrase for the client certificate key file.
- `autocompleteOptions`: If the model includes role `autocomplete`, these settings apply for tab autocompletion:
- `disable`: If `true`, disables autocomplete for this model.
- `maxPromptTokens`: Maximum number of tokens for the autocomplete prompt.
- `debounceDelay`: Delay before triggering autocomplete in milliseconds.
- `modelTimeout`: Model timeout for autocomplete requests in milliseconds.
- `maxSuffixPercentage`: Maximum percentage of prompt allocated for suffix.
- `prefixPercentage`: Percentage of input allocated for prefix.
- `template`: Custom template for autocomplete using Mustache syntax. You can use the `{{{ prefix }}}`, `{{{ suffix }}}`, `{{{ filename }}}`, `{{{ reponame }}}`, and `{{{ language }}}` variables.
- `onlyMyCode`: Only includes code within the repository for context.
- `useCache`: If `true`, enables caching for completions.
- `useImports`: If `true`, includes imports in context.
- `useRecentlyEdited`: If `true`, includes recently edited files in context.
- `useRecentlyOpened`: If `true`, includes recently opened files in context.
**Example:**
```yaml title="config.yaml"
@ -247,6 +263,10 @@ models:
model: codestral-latest
roles:
- autocomplete
autocompleteOptions:
debounceDelay: 250
maxPromptTokens: 1024
onlyMyCode: true
- name: My Model - OpenAI-Compatible
provider: openai
apiBase: http://my-endpoint/v1
@ -456,6 +476,10 @@ models:
model: starcoder
roles:
- autocomplete
autocompleteOptions:
debounceDelay: 350
maxPromptTokens: 1024
onlyMyCode: true
defaultCompletionOptions:
temperature: 0.3
stop:
@ -531,4 +555,8 @@ models:
useLegacyCompletionsEndpoint: false
roles:
- autocomplete
autocompleteOptions:
debounceDelay: 350
maxPromptTokens: 1024
onlyMyCode: true
```

View file

@ -107,6 +107,12 @@ config.json
Specifies options for tab autocompletion behavior.
<Info>
**Note**: Many of these parameters can also be configured per-model using the
`autocompleteOptions` field in `config.yaml`. See the [YAML
Reference](/reference#models) for more details.
</Info>
**Properties:**
- `disable`: If `true`, disables tab autocomplete (default: `false`).

View file

@ -1,6 +1,6 @@
pluginGroup=com.github.continuedev.continueintellijextension
pluginRepositoryUrl=https://github.com/continuedev/continue
pluginVersion=1.0.34
pluginVersion=1.0.35
pluginSinceBuild=223
platformType=IC
platformVersion=2022.3.3

View file

@ -1,29 +1,27 @@
package com.github.continuedev.continueintellijextension.listeners
import ToolTipComponent
import com.github.continuedev.continueintellijextension.editor.EditorUtils
import com.github.continuedev.continueintellijextension.services.ContinueExtensionSettings
import com.github.continuedev.continueintellijextension.utils.Debouncer
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.service
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.LogicalPosition
import com.intellij.openapi.editor.SelectionModel
import com.intellij.openapi.editor.event.SelectionEvent
import com.intellij.openapi.editor.event.SelectionListener
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.TextRange
import kotlinx.coroutines.CoroutineScope
import com.intellij.openapi.editor.Document
import com.intellij.openapi.editor.ex.util.EditorUtil
import com.intellij.openapi.fileEditor.FileDocumentManager
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.fileEditor.TextEditor
import com.intellij.openapi.project.DumbAware
import com.intellij.openapi.util.TextRange
import kotlinx.coroutines.CoroutineScope
class ContinuePluginSelectionListener(
coroutineScope: CoroutineScope,
) : SelectionListener, DumbAware {
private val debouncer = Debouncer(100, coroutineScope)
private val debouncer = Debouncer(200, coroutineScope)
private var toolTipComponents: ArrayList<ToolTipComponent> = ArrayList()
private var lastActiveEditor: Editor? = null
@ -228,5 +226,3 @@ class ContinuePluginSelectionListener(
editor.contentComponent.repaint()
}
}

View file

@ -32,6 +32,7 @@ import FileIcon from "../../FileIcon";
import SafeImg from "../../SafeImg";
import AddDocsDialog from "../../dialogs/AddDocsDialog";
import HeaderButtonWithToolTip from "../../gui/HeaderButtonWithToolTip";
import { Button } from "../../ui";
import { NAMED_ICONS } from "../icons";
import type { ComboBoxItem, ComboBoxItemType } from "../types";
@ -117,6 +118,7 @@ const QueryInput = styled.textarea`
background-color: #fff1;
border: 1px solid ${lightGray};
border-radius: ${defaultBorderRadius};
overflow: hidden;
padding: 0.2rem 0.4rem;
width: 240px;
@ -243,7 +245,7 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => {
.run();
// Trigger warning message
ideMessenger.ide.showToast(
void ideMessenger.ide.showToast(
"warning",
fileSize > 0
? "File exceeds model's context length"
@ -368,8 +370,9 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => {
if (item) {
if (item.type === "file" && item.query) {
isItemTooBig(item.type, item.query).then(([fileExceeds, fileSize]) =>
handleItemTooBig(fileExceeds, fileSize, item),
void isItemTooBig(item.type, item.query).then(
([fileExceeds, fileSize]) =>
handleItemTooBig(fileExceeds, fileSize, item),
);
} else {
props.command({ ...item, itemType: item.type });
@ -456,34 +459,53 @@ const AtMentionDropdown = forwardRef((props: AtMentionDropdownProps, ref) => {
return (
<ItemsDiv>
{querySubmenuItem ? (
<QueryInput
onClick={(e) => {
e.stopPropagation();
}}
rows={1}
ref={queryInputRef}
placeholder={querySubmenuItem.description}
onKeyDown={(e) => {
if (!queryInputRef.current) {
return;
}
if (e.key === "Enter") {
if (e.shiftKey) {
queryInputRef.current.innerText += "\n";
} else {
props.command({
...querySubmenuItem,
itemType: querySubmenuItem.type,
query: queryInputRef.current.value,
label: `${querySubmenuItem.label}: ${queryInputRef.current.value}`,
});
<span className="flex items-center gap-x-1">
<QueryInput
wrap="off"
onClick={(e) => {
e.stopPropagation();
}}
rows={1}
ref={queryInputRef}
placeholder={querySubmenuItem.description}
onKeyDown={(e) => {
if (!queryInputRef.current) {
return;
}
} else if (e.key === "Escape") {
setQuerySubmenuItem(undefined);
setSubMenuTitle(undefined);
if (e.key === "Enter") {
if (e.shiftKey) {
queryInputRef.current.innerText += "\n";
} else {
props.command({
...querySubmenuItem,
itemType: querySubmenuItem.type,
query: queryInputRef.current.value,
label: `${querySubmenuItem.label}: ${queryInputRef.current.value}`,
});
}
} else if (e.key === "Escape") {
setQuerySubmenuItem(undefined);
setSubMenuTitle(undefined);
}
}}
/>
<Button
variant="secondary"
size="sm"
className="m-0"
disabled={!queryInputRef.current}
onClick={() =>
props.command({
...querySubmenuItem,
itemType: querySubmenuItem.type,
query: queryInputRef.current!.value,
label: `${querySubmenuItem.label}: ${queryInputRef.current!.value}`,
})
}
}}
/>
>
⏎
</Button>
</span>
) : (
<>
{subMenuTitle && <ItemDiv className="mb-2">{subMenuTitle}</ItemDiv>}

View file

@ -330,6 +330,32 @@ export const models: { [key: string]: ModelPackage } = {
providerOptions: ["nebius"],
isOpenSource: true,
},
exaone32B: {
title: "EXAONE 4.0.1-32B",
description:
"LG AI Research's 32B model with integrated reasoning and agentic tool use capabilities.",
refUrl: "https://huggingface.co/LGAI-EXAONE/EXAONE-4.0.1-32B",
params: {
title: "EXAONE-4.0.1-32B",
model: "LGAI-EXAONE/EXAONE-4.0.1-32B",
contextLength: 131072,
},
providerOptions: ["openai"],
isOpenSource: true,
},
exaone12B: {
title: "EXAONE 4.0-1.2B",
description:
"Compact EXAONE 4.0 model suitable for on-device use while retaining tool calling support.",
refUrl: "https://huggingface.co/LGAI-EXAONE/EXAONE-4.0-1.2B",
params: {
title: "EXAONE-4.0-1.2B",
model: "LGAI-EXAONE/EXAONE-4.0-1.2B",
contextLength: 65536,
},
providerOptions: ["openai"],
isOpenSource: true,
},
moonshotChat: {
title: "Moonshot Chat",
description: "Moonshot AI provides high-performance large language models",

View file

@ -15,7 +15,7 @@ export function IndexingSettingsSection() {
<div className="pb-2 pt-5">
<p className="py-1 text-center font-semibold">Indexing is disabled</p>
<p className="text-lightgray cursor-pointer text-center text-xs">
Open settings and toggle <code>Disable Indexing</code> to re-enable
Open settings and toggle <code>Enable Indexing</code> to re-enable
</p>
</div>
) : (

View file

@ -151,6 +151,16 @@ export const tabAutocompleteOptionsSchema = z.object({
useRecentlyEdited: z.boolean(),
disableInFiles: z.array(z.string()).optional(),
useImports: z.boolean().optional(),
// Experimental options: true = enabled, false = disabled, number = enabled w priority
experimental_includeClipboard: z.union([z.boolean(), z.number()]).optional(),
experimental_includeRecentlyVisitedRanges: z
.union([z.boolean(), z.number()])
.optional(),
experimental_includeRecentlyEditedRanges: z
.union([z.boolean(), z.number()])
.optional(),
experimental_includeDiff: z.union([z.boolean(), z.number()]).optional(),
experimental_enableStaticContextualization: z.boolean().optional(),
});
export type TabAutocompleteOptions = z.infer<
typeof tabAutocompleteOptionsSchema

View file

@ -120,6 +120,16 @@ export const autocompleteOptionsSchema = z.object({
prefixPercentage: z.number().optional(),
template: z.string().optional(),
onlyMyCode: z.boolean().optional(),
useCache: z.boolean().optional(),
useImports: z.boolean().optional(),
useRecentlyEdited: z.boolean().optional(),
useRecentlyOpened: z.boolean().optional(),
// Experimental options: true = enabled, false = disabled, number = enabled w priority
experimental_includeClipboard: z.boolean().optional(),
experimental_includeRecentlyVisitedRanges: z.boolean().optional(),
experimental_includeRecentlyEditedRanges: z.boolean().optional(),
experimental_includeDiff: z.boolean().optional(),
experimental_enableStaticContextualization: z.boolean().optional(),
});
/** Prompt templates use Handlebars syntax */