refactor: VSCode Extension Settings cleanup. (#248)
* refactor: VSCode Extension Settings cleanup. * fix: vscode extension update settings naming.improve-workflow
parent
7f607f2f30
commit
7597ec6097
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "vscode-tabby",
|
"name": "vscode-tabby",
|
||||||
"publisher": "TabbyML",
|
"publisher": "TabbyML",
|
||||||
"displayName": "Tabby",
|
"displayName": "Tabby",
|
||||||
"description": "Get completions from Tabby server",
|
"description": "Tabby is a self-hosted AI coding assistant that can suggest multi-line code or full functions in real-time.",
|
||||||
"repository": "https://github.com/TabbyML/tabby",
|
"repository": "https://github.com/TabbyML/tabby",
|
||||||
"version": "0.0.6",
|
"version": "0.0.6",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
@ -30,12 +30,8 @@
|
||||||
"title": "Tabby: Toggle Code Suggestion On/Off"
|
"title": "Tabby: Toggle Code Suggestion On/Off"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "tabby.setServerUrl",
|
"command": "tabby.setApiEndpoint",
|
||||||
"title": "Tabby: Set URL of Tabby Server"
|
"title": "Tabby: Specify API Endpoint of Tabby"
|
||||||
},
|
|
||||||
{
|
|
||||||
"command": "tabby.setSuggestionDelay",
|
|
||||||
"title": "Tabby: Set suggestion delay"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "tabby.openSettings",
|
"command": "tabby.openSettings",
|
||||||
|
|
@ -45,38 +41,50 @@
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"title": "Tabby",
|
"title": "Tabby",
|
||||||
"properties": {
|
"properties": {
|
||||||
"tabby.enabled": {
|
"tabby.api.endpoint": {
|
||||||
"type": "boolean",
|
|
||||||
"default": true,
|
|
||||||
"description": "Enable Tabby code suggestion or not."
|
|
||||||
},
|
|
||||||
"tabby.serverUrl": {
|
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "http://127.0.0.1:8080",
|
"default": "http://localhost:8080",
|
||||||
|
"format": "uri",
|
||||||
"pattern": "^https?:\\/\\/[^\\s]+$",
|
"pattern": "^https?:\\/\\/[^\\s]+$",
|
||||||
"patternErrorMessage": "Please enter a validate http or https URL.",
|
"patternErrorMessage": "Please enter a validate http or https URL.",
|
||||||
"markdownDescription": "Specifies the url of [Tabby Server](https://github.com/TabbyML/tabby)."
|
"description": "Specify API Endpoint of Tabby."
|
||||||
},
|
},
|
||||||
"tabby.disableAnonymousUsageTracking": {
|
"tabby.codeCompletion": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Enable Tabby code completion or not."
|
||||||
|
},
|
||||||
|
"tabby.developerOptions": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "Developer options for Tabby.",
|
||||||
|
"properties": {
|
||||||
|
"suggestionDelay": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 150,
|
||||||
|
"minimum": 0,
|
||||||
|
"description": "Specifies the delay in milliseconds after which the request is sent to the tabby."
|
||||||
|
},
|
||||||
|
"agent": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"logs": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"debug",
|
||||||
|
"error",
|
||||||
|
"silent"
|
||||||
|
],
|
||||||
|
"default": "error",
|
||||||
|
"markdownDescription": "Specifies the log level for tabby-agent."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"tabby.usage.anonymousUsageTracking": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false,
|
"default": false,
|
||||||
"description": "Disable anonymous usage tracking."
|
"description": "Disable anonymous usage tracking."
|
||||||
},
|
|
||||||
"tabby.suggestionDelay": {
|
|
||||||
"type": "number",
|
|
||||||
"default": 150,
|
|
||||||
"minimum": 0,
|
|
||||||
"description": "Specifies the delay in milliseconds after which the request is sent to the tabby."
|
|
||||||
},
|
|
||||||
"tabby.agentLogs": {
|
|
||||||
"type": "string",
|
|
||||||
"enum": [
|
|
||||||
"debug",
|
|
||||||
"error",
|
|
||||||
"silent"
|
|
||||||
],
|
|
||||||
"default": "error",
|
|
||||||
"markdownDescription": "Specifies the log level of tabby-agent for debugging purpose. \n * If VSCode is running as desktop application, you can find log files in `$HOME/.tabby/agent-logs/`. It's recommend using `tail -f ~/.tabby/agent-logs/tabby-agent.log | npx pino-pretty` to monitor logs. \n * If VSCode is running in browser, you can find logs in debug console. "
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,8 +74,8 @@ export class TabbyCompletionProvider implements InlineCompletionItemProvider {
|
||||||
|
|
||||||
private updateConfiguration() {
|
private updateConfiguration() {
|
||||||
const configuration = workspace.getConfiguration("tabby");
|
const configuration = workspace.getConfiguration("tabby");
|
||||||
this.enabled = configuration.get("enabled", true);
|
this.enabled = configuration.get("codeCompletion", true);
|
||||||
this.suggestionDelay = configuration.get("suggestionDelay", 150);
|
this.suggestionDelay = configuration.get("developerOptions.suggestionDelay", 150);
|
||||||
}
|
}
|
||||||
|
|
||||||
private toInlineCompletions(tabbyCompletion: CompletionResponse | null, range: Range): InlineCompletionItem[] {
|
private toInlineCompletions(tabbyCompletion: CompletionResponse | null, range: Range): InlineCompletionItem[] {
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,21 @@ import { TabbyAgent, AgentConfig, DataStore } from "tabby-agent";
|
||||||
function getWorkspaceConfiguration(): Partial<AgentConfig> {
|
function getWorkspaceConfiguration(): Partial<AgentConfig> {
|
||||||
const configuration = workspace.getConfiguration("tabby");
|
const configuration = workspace.getConfiguration("tabby");
|
||||||
const config: Partial<AgentConfig> = {};
|
const config: Partial<AgentConfig> = {};
|
||||||
const serverUrl = configuration.get<string>("serverUrl");
|
const endpoint = configuration.get<string>("api.endpoint");
|
||||||
if (serverUrl) {
|
if (endpoint) {
|
||||||
config.server = {
|
config.server = {
|
||||||
endpoint: serverUrl,
|
endpoint,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const agentLogs = configuration.get<"debug" | "error" | "silent">("agentLogs");
|
const agentLogs = configuration.get<"debug" | "error" | "silent">("developerOptions.agent.logs");
|
||||||
if (agentLogs) {
|
if (agentLogs) {
|
||||||
config.logs = {
|
config.logs = {
|
||||||
level: agentLogs,
|
level: agentLogs,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const disableAnonymousUsageTracking = configuration.get<boolean>("disableAnonymousUsageTracking", false);
|
const anonymousUsageTrackingDisabled = configuration.get<boolean>("usage.anonymousUsageTracking", false);
|
||||||
config.anonymousUsageTracking = {
|
config.anonymousUsageTracking = {
|
||||||
disable: disableAnonymousUsageTracking,
|
disable: anonymousUsageTrackingDisabled,
|
||||||
};
|
};
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ const toggleEnabled: Command = {
|
||||||
command: "tabby.toggleEnabled",
|
command: "tabby.toggleEnabled",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
const configuration = workspace.getConfiguration("tabby");
|
const configuration = workspace.getConfiguration("tabby");
|
||||||
const enabled = configuration.get("enabled", true);
|
const enabled = configuration.get("codeCompletion", true);
|
||||||
console.debug(`Toggle Enabled: ${enabled} -> ${!enabled}.`);
|
console.debug(`Toggle Enabled: ${enabled} -> ${!enabled}.`);
|
||||||
configuration.update("enabled", !enabled, configTarget, false);
|
configuration.update("codeCompletion", !enabled, configTarget, false);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -36,7 +36,7 @@ const setSuggestionDelay: Command = {
|
||||||
command: "tabby.setSuggestionDelay",
|
command: "tabby.setSuggestionDelay",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
const configuration = workspace.getConfiguration("tabby");
|
const configuration = workspace.getConfiguration("tabby");
|
||||||
const current = configuration.get("suggestionDelay", 150);
|
const current = configuration.get("developerOptions.suggestionDelay", 150);
|
||||||
const items = {
|
const items = {
|
||||||
Immediately: 0, // ms
|
Immediately: 0, // ms
|
||||||
Default: 150,
|
Default: 150,
|
||||||
|
|
@ -87,20 +87,20 @@ const setSuggestionDelay: Command = {
|
||||||
quickPick.hide();
|
quickPick.hide();
|
||||||
const delay = new Duration(quickPick.selectedItems[0].label).offset;
|
const delay = new Duration(quickPick.selectedItems[0].label).offset;
|
||||||
console.debug("Set suggestion delay: ", delay);
|
console.debug("Set suggestion delay: ", delay);
|
||||||
configuration.update("suggestionDelay", delay, configTarget, false);
|
configuration.update("developerOptions.suggestionDelay", delay, configTarget, false);
|
||||||
});
|
});
|
||||||
quickPick.show();
|
quickPick.show();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const setServerUrl: Command = {
|
const setApiEndpoint: Command = {
|
||||||
command: "tabby.setServerUrl",
|
command: "tabby.setApiEndpoint",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
const configuration = workspace.getConfiguration("tabby");
|
const configuration = workspace.getConfiguration("tabby");
|
||||||
window
|
window
|
||||||
.showInputBox({
|
.showInputBox({
|
||||||
prompt: "Enter the URL of your Tabby Server",
|
prompt: "Enter the URL of your Tabby Server",
|
||||||
value: configuration.get("serverUrl", ""),
|
value: configuration.get("api.endpoint", ""),
|
||||||
validateInput: (input: string) => {
|
validateInput: (input: string) => {
|
||||||
try {
|
try {
|
||||||
let url = new URL(input);
|
let url = new URL(input);
|
||||||
|
|
@ -117,7 +117,7 @@ const setServerUrl: Command = {
|
||||||
.then((url) => {
|
.then((url) => {
|
||||||
if (url) {
|
if (url) {
|
||||||
console.debug("Set Tabby Server URL: ", url);
|
console.debug("Set Tabby Server URL: ", url);
|
||||||
configuration.update("serverUrl", url, configTarget, false);
|
configuration.update("api.endpoint", url, configTarget, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -126,7 +126,7 @@ const setServerUrl: Command = {
|
||||||
const openSettings: Command = {
|
const openSettings: Command = {
|
||||||
command: "tabby.openSettings",
|
command: "tabby.openSettings",
|
||||||
callback: () => {
|
callback: () => {
|
||||||
commands.executeCommand("workbench.action.openSettings", "tabby");
|
commands.executeCommand("workbench.action.openSettings", "@ext:TabbyML.vscode-tabby");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -178,6 +178,6 @@ const statusBarItemClicked: Command = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const tabbyCommands = () =>
|
export const tabbyCommands = () =>
|
||||||
[toggleEnabled, setServerUrl, setSuggestionDelay, openSettings, emitEvent, openAuthPage, statusBarItemClicked].map(
|
[toggleEnabled, setApiEndpoint, setSuggestionDelay, openSettings, emitEvent, openAuthPage, statusBarItemClicked].map(
|
||||||
(command) => commands.registerCommand(command.command, command.callback, command.thisArg)
|
(command) => commands.registerCommand(command.command, command.callback, command.thisArg)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ function toDisabled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateStatusBarItem() {
|
function updateStatusBarItem() {
|
||||||
const enabled = workspace.getConfiguration("tabby").get("enabled", true);
|
const enabled = workspace.getConfiguration("tabby").get("codeCompletion", true);
|
||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
fsmService.send("disabled");
|
fsmService.send("disabled");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue