Plugins
Extend Neovate Code functionality with plugins for enhanced development workflows. Plugins are a way to extend the functionality with plenty of hooks. You can create your own plugins to add your own features, tools, models, providers, system prompt, output style, slash commands and other integrations.
Create a plugin
A plugin is a JavaScript Object that follows the Plugin
interface.
import type { Plugin } from '@neovate/code';
export default const plugin: Plugin = {
name: 'my-plugin',
context: () => {
// Add more context
return {
'Who am I': 'chencheng',
};
},
}
Plugin hooks
You can use this
to access the context instance in the plugin hooks.
Plugin hooks are the main way to extend the functionality of Neovate Code. There are many hooks available.
config
Return a partial config to merge with the config. This hook is called when the config is initialized.
- type:
SeriesMerge
- parameters:
- opts:
- config:
Config
- argvConfig:
Record<string, any>
- config:
- opts:
- return:
Partial<Config>
destroy
This hook is called when the context is destroyed.
- type:
Parallel
- parameters:
- return:
void
slashCommand
Return the slash commands to be registered.
- type:
SeriesMerge
- parameters:
- return:
SlashCommand[]
outputStyle
Return the output styles to be registered.
- type:
SeriesMerge
- parameters:
- return:
OutputStyle[]
provider
Modify the providers map.
- type:
SeriesLast
- parameters:
- providers:
ProvidersMap
- opts:
- models:
ModelMap
- defaultModelCreator:
(name: string, provider: Provider) => LanguageModelV1
- createOpenAI:
(options: any) => OpenAIProvider
- models:
- providers:
- return:
ProvidersMap
modelAlias
Modify the model aliases.
- type:
SeriesLast
- parameters:
- modelAlias:
ModelAlias
- modelAlias:
- return:
ModelAlias
initialized
Initialize the plugin.
- type:
Series
- parameters:
- opts:
- cwd:
string
- quiet:
boolean
- cwd:
- opts:
- return:
void
context
Return the context to be added to the conversation.
- type:
SeriesMerge
- parameters:
- opts:
- userPrompt:
string | null
- sessionId:
string
- userPrompt:
- opts:
- return:
Record<string, string>
env
Return the environment context to be added to the conversation.
- type:
SeriesMerge
- parameters:
- opts:
- userPrompt:
string | null
- sessionId:
string
- userPrompt:
- opts:
- return:
Record<string, string>
userPrompt
Modify the user prompt.
- type:
SeriesLast
- parameters:
- userPrompt:
string
- opts:
- sessionId:
string
- sessionId:
- userPrompt:
- return:
string
systemPrompt
Modify the system prompt.
- type:
SeriesLast
- parameters:
- systemPrompt:
string
- opts:
- isPlan:
boolean
- sessionId:
string
- isPlan:
- systemPrompt:
- return:
string
tool
Return the extra tools to be used. This is useful for adding your own tools to the conversation.
- type:
SeriesMerge
- parameters:
- opts:
- isPlan:
boolean
- sessionId:
string
- isPlan:
- opts:
- return:
Tool[]
toolUse
Modify the tool use.
- type:
SeriesLast
- parameters:
- toolUse:
ToolUse
- opts:
- sessionId:
string
- sessionId:
- toolUse:
- return:
ToolUse
toolResult
Modify the tool result.
- type:
SeriesLast
- parameters:
- toolResult:
ToolResult
- opts:
- toolUse:
ToolUse
- approved:
boolean
- sessionId:
string
- toolUse:
- toolResult:
- return:
ToolResult
query
Notify the plugin that a query has been made.
- type:
Series
- parameters:
- opts:
- usage:
Usage
- startTime:
Date
- endTime:
Date
- sessionId:
string
- usage:
- opts:
- return:
void
conversation
Notify the plugin that a conversation has been made.
- type:
Series
- parameters:
- opts:
- userPrompt:
string | null
- result:
LoopResult
- startTime:
Date
- endTime:
Date
- sessionId:
string
- userPrompt:
- opts:
- return:
void
telemetry
Telemetry hook for collecting usage analytics. This hook is called when telemetry events need to be reported.
- type:
Series
- parameters:
- opts:
- name:
string
- The name of the telemetry event - payload:
Record<string, any>
- The telemetry data payload
- name:
- opts:
- return:
Promise<void> | void
status
Return the extra status to be displayed.
- type:
SeriesMerge
- parameters:
- return:
Status