monacopilot 0.18.5 → 0.18.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +7 -6
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -39,25 +39,27 @@ const editor = monaco.editor.create(document.getElementById('container'), {
39
39
  });
40
40
 
41
41
  registerCompletion(monaco, editor, {
42
- endpoint: 'https://api.example.com/code-completion', // Your API endpoint for handling completion requests
43
42
  language: 'javascript',
43
+ // Your API endpoint for handling completion requests
44
+ endpoint: 'https://api.example.com/code-completion',
44
45
  });
45
46
  ```
46
47
 
47
48
  3. **Create your completion API handler**
48
49
 
49
50
  ```javascript
50
- // Create an API handler for the endpoint (e.g. /code-completion) you provided in the `registerCompletion` function
51
+ // Create an API handler for the endpoint (e.g. /code-completion) you provided
52
+ // in the `registerCompletion` function
51
53
  // to handle completion requests from the editor
52
54
 
55
+ // Example using Express.js
53
56
  import {Copilot} from 'monacopilot';
54
57
 
55
58
  const copilot = new Copilot(OPENAI_API_KEY, {
56
- provider: 'openai', // or 'anthropic', 'google', etc.,
57
- model: 'gpt-4o', // or 'claude-3-5-haiku', 'gpt-4o-mini', etc.
59
+ provider: 'openai',
60
+ model: 'gpt-4o',
58
61
  });
59
62
 
60
- // Handle completion requests
61
63
  app.post('/code-completion', async (req, res) => {
62
64
  const {completion, error, raw} = await copilot.complete({body: req.body});
63
65
 
@@ -66,7 +68,6 @@ app.post('/code-completion', async (req, res) => {
66
68
  calculateCost(raw.usage.input_tokens);
67
69
  }
68
70
 
69
- // Handle any errors gracefully
70
71
  if (error) {
71
72
  return res.status(500).json({completion: null, error});
72
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monacopilot",
3
- "version": "0.18.5",
3
+ "version": "0.18.7",
4
4
  "description": "AI auto-completion plugin for Monaco Editor",
5
5
  "main": "./build/index.js",
6
6
  "module": "./build/index.mjs",
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "build": "tsup src/index.ts",
13
13
  "dev": "tsup src/index.ts --watch",
14
- "test": "vitest",
14
+ "test": "vitest run",
15
15
  "dev:test-ui": "pnpm -C tests/ui dev",
16
16
  "tsc": "tsc --noEmit",
17
17
  "lint": "eslint . --ext .ts,.tsx --fix",