SkillAgentSearch skills...

AssistantAI

A Sublime Text plugin to interact with HTTP API endpoints and perform text manipulation with their responses. Bundled with OpenAI to interact with ChatGPT or Codex, Gitea to create Issues from the selected code, and Python prompts to add Docstrings, and more. Users can extend it's features by defining Servers and Prompts in Sublime JSON files.

Install / Use

/learn @kanutron/AssistantAI
About this skill

Quality Score

0/100

Supported Platforms

OpenAI Codex

README

AssistantAI

A Sublime Text plugin to interact with HTTP API endpoints and perform text manipulation with their responses. AssistantAI is bundled with OpenAI to interact with ChatGPT or Codex, Gitea to create Issues directly from the selected code, and Python prompts to automatically add Docstrings and more. The user can extend it's features by defining Server endpoints and custom Prompts in Sublime Settings JSON files.

<p align="center"> <img src="screenshot.gif" alt="AssistantAI in action"></img> </p>

AssistantAI provides general purpose implementation of an HTTP API client that allows perform text manipulation with remote API responses, as a result to requests based on selected text and optional user input. Can be extended by the user or by other packages, providing servers, endpoints, prompt templates and credentials placeholders, defined in Sublime Settings files, in JSON.

A common use case is to consume API of, for instance, Generative AIs like ChatGPT or OpenAI Codex, to complete, edit, comment or explain selected code chunks. Another example is to consume GitHub, Gitea or similar VCS server's API to add Issues from the selected code, without leaving Sublime Text.

Privacy warning

Selected code, file path, name, file size and symbols may be sent to the remote third party API servers for processing (i.e.: OpenAI, see below), so make sure you have the necessary permissions to do so.

Installation

The plugin is available in Package Control.

Installing the plugin via Package Control is the recommended option:

  • Invoke Command Palette (Cmd + Shift + P)
  • Search for "Package Control: Install Package"
  • Search for "AssistantAI" and install it

Once installed, check the settings menu in Settings > Package Settings > AssistantAI, which includes:

  • Settings: General AssistantAI plugin settings. A place to add your custom prompts and servers.
  • Key Bindings: Example Key Bindings for invoking AssistantAI prompt selection panel and more.

Also bundled with the plugin you can configure:

  • OpenAI Server Settings: Definition for ChatGPT completion API endpoints and general prompts.
  • Gitea Server Settings: Definition for Gitea Issue creation endpoint.
  • Python Prompts: Definition of Python-specific prompts (i.e.: to add a Doctring to selected code using OpenAI).

And for when you have at least one configured Server (see below):

  • The AssistantAI command in the command palette.

Settings

AssistantAI is configured, and extended, using Sublime JSON settings files. The plugin provides several files for each service or syntax specific definitions (i.e.: one for OpenAI, another for Gitea, for Python, and more to come), where each file follows the same structure:

  • credentials: Empty by default. You should overwrite this entry with your credentials for that server as described below.
  • prompts: Empty by default. Overwrite it to add (or import and refine) your custom prompts.
  • servers: Empty by default. Overwrite it to add (or import and refine) your custom servers.
  • default_prompts: Prompts provided by the package. You should not overwrite this entry.
  • default_servers: Servers provided by the package. You should not overwrite this entry.

Your custom settings files may include credentials to enable the server, thus making all prompts depending on it available for when you invoke AssistantAI command. If you add custom prompts or servers, then prompts and servers may be present too in your custom files.

What should be never present in your custom files are default_prompts and default_servers. If you want to create a server based on a default one, you can use a import as described in advanced topics or in the examples in the settings files.

The files are named following this convention:

  • assitant_ai.sublime-settings for the general settings.
  • assitant_ai_{NAME}.sublime-settings for the service or syntax specific settings files.

Currently, at the very least, you should configure the API KEY of OpenAI, or API TOKEN of Gitea, to play with the plugin.

Everything can be configured with Sublime JSON settings with a very high degree of flexibility.

Key Bindings and Commands

An example of key bindings file is provided to bind keyboard shortcuts to AssistantAI commands, so you can quickly get the available prompt list based on the current context or directly invoke a prompt.

There are two commands you can invoke with a Key Binding:

  • AssistnatAI Prompt: identified as assistant_ai_prompt. This command is also available in the Command Palette. When invoked without arguments shows a list of prompts that can be used, given the configured servers, selected text, buffer syntax, etc (i.e.: the context). To directly invoke a prompt, you can pass arguments:

    • pid: Prompt ID
    • eid: Endpoint ID
    • ...: Any required input argument required by the prompt.
  • AssistnatAI Dump: identified as assistant_ai_dump. Used for debugging. Dumps all loaded settings and displays in a new buffer, so you can inspect what is being loaded. When you start playing with import for servers and prompts, you may need to know what has been processed by AsistantAI.

If no prompts are available, AssistantAI command does nothing else than show a status bar message warning.

Usage

Once installed and configured, invoke AssistantAI from the command palette, select a prompt from the presented list and follow it's flow.

Prompts are offered based on the context (configured servers, selected text, buffer syntax, available content, etc.), and as per specifications provided by the prompt it self.

Without any configured server, there will be no prompts available.

The general flow is simple. For instance:

  • Select a text region (i.e.: A code function, or Markdown section).
  • Command Palette > AssistantAI (or the keyboard shortcut if you set up one).
  • Select a prompt.
  • If the prompt needs additional inputs, those will be requested using the UI.
  • When several servers with valid endpoints qualifies for the selected prompt, a list of endpoints is presented.

Once AssistantAI have a prompt, with all needed inputs and the target endpoint is selected, it builds an HTTP payload based on that and makes the network request.

The response is parsed based on the endpoint specification and its specified command is executed.

The prompt may specify another action instead of text manipulation (replace, append, prepend, insert), such as show the response in an Output Panel, or a new Buffer.

As an example, consider this flow using the bundled OpenAI server endpoints definition (requires credentials) plugin while editing a Python file:

  • Select a python function
  • Ask AssistantAI for the prompt "Add python docstring"
  • Since only one endpoint qualifies, a request is made to OpenAI without further inputs
  • The python docstring is added to the selected function as returned by ChatGPT

What's included with this plugin?

The plugin implements the parser of the settings files where the servers, prompts and credentials are configured (by this package, another package, or the user). Manages the filtering of the prompts that are available given a context, and takes care of the API requests, building payloads, parsing responses, and performing the text manipulation.

Besides the plugin implementation, AssistantAI includes the following definitions of servers and prompts.

Servers

Servers are definitions of network resources that AssistantAI can consume using HTTP requests. Includes the URL, timeout and a description.

Each server must specify one or more endpoints which includes what are the possible request payloads structures, declarative instructions on how to build it based on the prompt user inputs (i.e.: selected text, or additional inputs the user is prompted for).

AssistantAI reads the configuration seeking for servers definitions, and considers a server to be available when all required credentials are configured by the user (i.e.: API TOKENS).

AssisntantAI includes currently the following server and endpoints definitions.

OpenAI

OpenAI server definition that allows consuming the API with three end points:

  • Edits
  • Completions
  • Chat completions (the one powering ChatGPT)

Please note that OpenAI is a paid service, and you will need to have an API key and sufficient credit to use the plugin.

Once you have your API key, go to Settings > Package Settings > AssistantAI > OpenAI Server Settings and add the credential:

{
  "credentials": {
    // you must specify the Server ID ('openai' in this case) which this credential is for 
    "openai": {
      // OpenAI requires only one credential named 'api_key'
      "api_key": "sk-..."

      // Other servers may require more tokens, identification, etc.

      // For custom TLS: you can specify `verify` for a custom CA and `cert` for a Client Cert
      // "verify": "~/.tls/my_ca.pem"
      // "cert": "~/.tls/my_cert.pem" // must include unencrypted key 
    }
  }
}

Gitea

Gitea is an open source replacement of GitHub, less sophisticated and much lightweight, which you can deploy in your own infrastructure. It provides an API to interact with it, allows among many other workflows, to retrieve repository information, create Issues and PRs.

This Server definition includes two endpoints:

  • Get repositories
  • Create an Issue to a specific repository

Since you may have access to several Gitea instances (i.e.: your personal, and the one in your workplace), you can define your custom servers by importing the default one:

  "servers": [
    {
      "id": "gitea_personal",
      "import": "gitea", // this is provided in 'default_servers'
      "name": "Gitea Kanutron",
      "url": "https://CUSTOM_URL:443", // the default points to https://localhost:3
View on GitHub
GitHub Stars11
CategoryDevelopment
Updated1mo ago
Forks0

Languages

Python

Security Score

95/100

Audited on Feb 22, 2026

No findings