1.11.5 • Published 2 days ago
@yank-note/extension-ai-copilot v1.11.5
AI Copilot
AI Copilot is a Yank Note extension that provides AI-powered text completion suggestions or rewrite suggestions.
Screenshots
Custom AI Adapter
AI Copilot is designed to be extensible. You can use your own AI adapter to provide code completion suggestions or rewrite suggestions.
First, you need learn how to write an Yank Note Plugin, Please refer to Yank Note Plugin
Then, you can write your own AI adapter plugin.
Example:
window.registerPlugin({
name: 'custom-ai-copilot-adapter',
register: ctx => {
ctx.registerHook('EXTENSION_READY', ({ extensions }) => {
const extension = extensions.find(e => e.id === '@yank-note/extension-ai-copilot')
if (!extension) {
throw new Error('Can not find extension @yank-note/extension-ai-copilot')
}
const { registerAdapter, proxyRequest } = ctx.getPluginApi('@yank-note/extension-ai-copilot')
class DemoCompletionAdapter {
type = 'completion'
id = 'demo'
displayname = 'DemoCompletionAdapter'
description = 'Powered by <a target="_blank" href="http://yank-note.com">Yank Note</a>'
state = ctx.lib.vue.reactive({ apiPoint: 'demo' })
panel = {
type: 'form',
items: [
{ type: 'input', key: 'apiPoint', label: 'Api Point', defaultValue: 'demo', props: { placeholder: 'demo' }, hasError: v => !v },
],
}
activate () {
return {
state: this.state,
dispose: () => 0
}
}
async fetchCompletionResults (model, position, context, cancelToken) {
if (context.triggerKind === 0) { // auto trigger
return { items: [] }
}
const range = new (ctx.editor.getMonaco().Range)(
position.lineNumber,
position.column,
position.lineNumber,
position.column,
)
// proxyRequest(url, { headers, body, method })
const text = 'Hello World!' + Math.random()
return {
items: [
{ text: text, insertText: { snippet: text }, range, }
]
}
}
}
class DemoEditAdapter {
type ='edit'
id ='demo'
displayname = 'DemoEditAdapter'
description = 'Powered by <a target="_blank" href="http://yank-note.com">Yank Note</a>'
state = ctx.lib.vue.reactive({
apiPoint: 'demo',
instruction: 'test',
})
panel = {
type: 'form',
items: [
{ type: 'input', key: 'apiPoint', label: 'Api Point', defaultValue: 'demo', props: { placeholder: 'demo' }, hasError: v => !v },
{ type: 'instruction', key: 'instruction', label: 'Instruction', historyValueKey: 'historyInstructions' },
],
}
activate () {
return {
state: this.state,
dispose: () => 0
}
}
async fetchEditResults (selectedText) {
return [...selectedText].reverse().join('')
}
}
registerAdapter(new DemoCompletionAdapter())
registerAdapter(new DemoEditAdapter())
}, true)
}
})
1.11.4
2 days ago
1.11.5
2 days ago
1.11.3
3 days ago
1.11.2
4 days ago
1.11.1
4 days ago
1.11.0
4 days ago
1.10.0
4 days ago
1.9.1
5 days ago
1.9.0
5 days ago
1.8.0
5 days ago
1.9.2
5 days ago
1.7.0
7 days ago
1.6.0
9 days ago
1.5.0
13 days ago
1.4.2
19 days ago
1.4.1
19 days ago
1.4.0
19 days ago
1.3.2
3 months ago
1.3.1
4 months ago
1.3.0
5 months ago
1.2.0
5 months ago
1.2.2
5 months ago
1.2.1
5 months ago
1.1.1
5 months ago
1.1.0
5 months ago
1.1.2
5 months ago
1.0.1
5 months ago
1.0.0
5 months ago
0.0.1
5 months ago