monacopilot 0.18.6 → 0.18.8

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 +9 -9
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -29,8 +29,9 @@ npm install monacopilot
29
29
 
30
30
  2. **Register the AI completion to your editor**
31
31
 
32
+ In your frontend code:
33
+
32
34
  ```javascript
33
- // In your frontend code
34
35
  import * as monaco from 'monaco-editor';
35
36
  import {registerCompletion} from 'monacopilot';
36
37
 
@@ -47,11 +48,11 @@ registerCompletion(monaco, editor, {
47
48
 
48
49
  3. **Create your completion API handler**
49
50
 
50
- ```javascript
51
- // Create an API handler for the endpoint (e.g. /code-completion) you provided
52
- // in the `registerCompletion` function
53
- // to handle completion requests from the editor
51
+ Create an API handler for the endpoint (e.g. /code-completion) you provided in the `registerCompletion` function to handle completion requests from the editor.
52
+
53
+ Example using Express.js:
54
54
 
55
+ ```javascript
55
56
  import {Copilot} from 'monacopilot';
56
57
 
57
58
  const copilot = new Copilot(OPENAI_API_KEY, {
@@ -59,7 +60,6 @@ const copilot = new Copilot(OPENAI_API_KEY, {
59
60
  model: 'gpt-4o',
60
61
  });
61
62
 
62
- // Handle completion requests
63
63
  app.post('/code-completion', async (req, res) => {
64
64
  const {completion, error, raw} = await copilot.complete({body: req.body});
65
65
 
@@ -68,7 +68,6 @@ app.post('/code-completion', async (req, res) => {
68
68
  calculateCost(raw.usage.input_tokens);
69
69
  }
70
70
 
71
- // Handle any errors gracefully
72
71
  if (error) {
73
72
  return res.status(500).json({completion: null, error});
74
73
  }
@@ -77,9 +76,10 @@ app.post('/code-completion', async (req, res) => {
77
76
  });
78
77
  ```
79
78
 
80
- You can use any backend framework or programming language for your API handler, as long as the endpoint is accessible from the browser. For non-JavaScript implementations, see [Cross-Language API Handler Implementation](#cross-language-api-handler-implementation).
79
+ **That's it! Your Monaco Editor now has AI-powered completions! 🎉**
81
80
 
82
- That's it! Your Monaco Editor now has AI-powered completions! 🎉
81
+ > [!NOTE]
82
+ > You can use any backend framework or programming language for your API handler, as long as the endpoint is accessible from the browser. For non-JavaScript implementations, see [Cross-Language API Handler Implementation](#cross-language-api-handler-implementation).
83
83
 
84
84
  ### Examples
85
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monacopilot",
3
- "version": "0.18.6",
3
+ "version": "0.18.8",
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",