cursor-companion-ai 0.1.0 → 0.2.1
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.
- package/README.md +66 -7
- package/dist/companion.js +34 -85
- package/dist/index.cjs +195 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.mjs +195 -0
- package/package.json +26 -4
package/README.md
CHANGED
|
@@ -9,25 +9,84 @@ An AI cursor that reads any web page and guides users by pointing at the exact e
|
|
|
9
9
|
|
|
10
10
|
## Quick start
|
|
11
11
|
|
|
12
|
+
Three ways in, depending on your stack. They all do the same thing.
|
|
13
|
+
|
|
14
|
+
### React / Next.js / Vite (npm)
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install cursor-companion-ai
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
// Next.js: app/layout.tsx
|
|
22
|
+
import { Companion } from "cursor-companion-ai";
|
|
23
|
+
|
|
24
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
25
|
+
return (
|
|
26
|
+
<html>
|
|
27
|
+
<body>
|
|
28
|
+
{children}
|
|
29
|
+
<Companion
|
|
30
|
+
anthropicKey={process.env.NEXT_PUBLIC_ANTHROPIC_KEY!}
|
|
31
|
+
context="This is My App. The Reports tab is at the top. When users say 'export' they mean the toolbar Download button."
|
|
32
|
+
/>
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
// Vite / CRA: src/App.tsx
|
|
41
|
+
import { Companion } from "cursor-companion-ai";
|
|
42
|
+
|
|
43
|
+
export default function App() {
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
{/* your app */}
|
|
47
|
+
<Companion
|
|
48
|
+
anthropicKey={import.meta.env.VITE_ANTHROPIC_KEY}
|
|
49
|
+
context="..."
|
|
50
|
+
/>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Drop the component once at the app root. It renders nothing — just mounts the companion globally on first render.
|
|
57
|
+
|
|
58
|
+
### Vanilla JS / non-React
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { mountCompanion } from "cursor-companion-ai";
|
|
62
|
+
|
|
63
|
+
mountCompanion({
|
|
64
|
+
anthropicKey: "sk-ant-...",
|
|
65
|
+
context: "App description...",
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Plain HTML — one script tag, no install
|
|
70
|
+
|
|
12
71
|
```html
|
|
13
72
|
<script
|
|
14
73
|
src="https://cdn.jsdelivr.net/npm/cursor-companion-ai@latest/dist/companion.js"
|
|
15
74
|
data-anthropic-key="sk-ant-..."
|
|
16
|
-
data-context="
|
|
75
|
+
data-context="App description..."
|
|
17
76
|
></script>
|
|
18
77
|
```
|
|
19
78
|
|
|
20
|
-
That's it. Reload
|
|
79
|
+
That's it. Reload → right-click anywhere → companion panel appears at the cursor → type a goal.
|
|
21
80
|
|
|
22
81
|
## Configuration
|
|
23
82
|
|
|
24
|
-
|
|
83
|
+
Same options regardless of how you mount it — `<Companion>` props, `mountCompanion()` options, or `data-*` attributes on the script tag.
|
|
25
84
|
|
|
26
|
-
|
|
|
85
|
+
| Option | Required | What it does |
|
|
27
86
|
|---|---|---|
|
|
28
|
-
| `data-anthropic-key` | Yes (for direct mode) | Your Anthropic API key (`sk-ant-...`). The library calls Anthropic from the browser with this key. **Visible in page source** — see the security note below. |
|
|
29
|
-
| `data-context` | Recommended | Plain-English description of your app: page names, terminology, conventions, edge cases. Prepended to every model call so the AI sounds like it knows your product. |
|
|
30
|
-
| `data-endpoint` | Optional | If set, requests go to your own backend at this URL instead of direct Anthropic. Use this in production where the key shouldn't be in the browser.
|
|
87
|
+
| `anthropicKey` / `data-anthropic-key` | Yes (for direct mode) | Your Anthropic API key (`sk-ant-...`). The library calls Anthropic from the browser with this key. **Visible in page source** — see the security note below. |
|
|
88
|
+
| `context` / `data-context` | Recommended | Plain-English description of your app: page names, terminology, conventions, edge cases. Prepended to every model call so the AI sounds like it knows your product. |
|
|
89
|
+
| `endpoint` / `data-endpoint` | Optional | If set, requests go to your own backend at this URL instead of direct Anthropic. Use this in production where the key shouldn't be in the browser. |
|
|
31
90
|
|
|
32
91
|
## Security note
|
|
33
92
|
|