ai-debug-pins 0.5.0 → 0.6.0
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 +6 -2
- package/bin.js +2 -1
- package/client.js +3 -1
- package/package.json +1 -1
- package/server.js +14 -2
- package/vite.js +2 -1
package/README.md
CHANGED
|
@@ -70,9 +70,11 @@ claude plugin install ai-debug-pins@ai-debug-pins
|
|
|
70
70
|
**2a. A Vite project** (Vite, React with Vite, Vue, SvelteKit, Nuxt, Astro, React Router...):
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
|
-
npm
|
|
73
|
+
npm install --save-dev ai-debug-pins
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
+
(or `pnpm add -D ai-debug-pins`, `yarn add -D ai-debug-pins`, `bun add -d ai-debug-pins`)
|
|
77
|
+
|
|
76
78
|
```js
|
|
77
79
|
// vite.config.js
|
|
78
80
|
import debugPins from 'ai-debug-pins'
|
|
@@ -89,6 +91,8 @@ folder, beside your dev server,
|
|
|
89
91
|
npx ai-debug-pins
|
|
90
92
|
```
|
|
91
93
|
|
|
94
|
+
(or `pnpm dlx ai-debug-pins`, `yarn dlx ai-debug-pins`, `bunx ai-debug-pins`)
|
|
95
|
+
|
|
92
96
|
and add one line to your page, in development only:
|
|
93
97
|
|
|
94
98
|
```html
|
|
@@ -144,7 +148,7 @@ What only Claude Code gets: notes going along with your messages by themselves,
|
|
|
144
148
|
Take `debugPins()` out of your Vite config (or the script tag out of your page), then:
|
|
145
149
|
|
|
146
150
|
```bash
|
|
147
|
-
npm
|
|
151
|
+
npm uninstall ai-debug-pins
|
|
148
152
|
```
|
|
149
153
|
|
|
150
154
|
```bash
|
package/bin.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
// <script type="module" src="http://localhost:7777/client.js"></script>
|
|
5
5
|
import { createServer } from 'node:http'
|
|
6
6
|
import { resolve } from 'node:path'
|
|
7
|
-
import { handler } from './server.js'
|
|
7
|
+
import { handler, claudePlugin, HINT } from './server.js'
|
|
8
8
|
|
|
9
9
|
const port = Number(process.argv[2] || process.env.PORT || 7777)
|
|
10
10
|
createServer(handler()).listen(port, '127.0.0.1', () => {
|
|
11
11
|
console.log(`ai-debug-pins: notes go to ${resolve('.notes')}`)
|
|
12
12
|
console.log(`Add to your page, in development only:`)
|
|
13
13
|
console.log(` <script type="module" src="http://localhost:${port}/client.js"></script>`)
|
|
14
|
+
claudePlugin().then((ok) => ok || console.log(HINT))
|
|
14
15
|
})
|
package/client.js
CHANGED
|
@@ -186,7 +186,9 @@ card.onsubmit = async (e) => {
|
|
|
186
186
|
const saved = await POST('note', note).catch(() => null)
|
|
187
187
|
if (!saved || saved.status === 404) return copy(note)
|
|
188
188
|
if (!saved.ok) return say('Not pinned: ' + (await saved.json().catch(() => ({}))).error, true)
|
|
189
|
-
|
|
189
|
+
const { claude } = await saved.json().catch(() => ({}))
|
|
190
|
+
if (!note.png) return say('Pinned, without a picture: ' + note.noPicture, true)
|
|
191
|
+
say(claude ? '📍 Pinned. It goes with your next message to Claude.' : '📍 Pinned in .notes/notes.md.')
|
|
190
192
|
}
|
|
191
193
|
|
|
192
194
|
// The page draws its own picture: no permission, no extension. Taken inside a frame, right after the page has drawn,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-debug-pins",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Click a spot on your dev page and type a note: Claude Code gets a picture with a ring where you clicked, your words and the code they point at.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// The notes endpoint and the client's files, as one request handler: used by the Vite plugin (under /@ai-debug-pins/)
|
|
2
2
|
// and by the standalone server (bin.js, at the root) for pages that are not built by Vite.
|
|
3
3
|
import { readFile } from 'node:fs/promises'
|
|
4
|
-
import {
|
|
4
|
+
import { homedir } from 'node:os'
|
|
5
|
+
import { join, resolve } from 'node:path'
|
|
5
6
|
import { saveNote } from './notes.js'
|
|
6
7
|
|
|
7
8
|
const FILES = {
|
|
@@ -24,6 +25,17 @@ const loopback = (ip = '') => ip === '::1' || /^(::ffff:)?127\./.test(ip)
|
|
|
24
25
|
const PNG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a])
|
|
25
26
|
const MAX = 32 * 1024 * 1024 // a picture of a 4K screen at 2x is about 10 MB as base64
|
|
26
27
|
|
|
28
|
+
// Whether the Claude Code plugin is installed, which is what carries notes into the chat. Without it notes are only
|
|
29
|
+
// saved, so the button and the server say so instead of promising Claude will see them.
|
|
30
|
+
export async function claudePlugin() {
|
|
31
|
+
const file = join(process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude'), 'plugins', 'installed_plugins.json')
|
|
32
|
+
const list = await readFile(file, 'utf8').then(JSON.parse, () => null)
|
|
33
|
+
return Object.keys(list?.plugins ?? {}).some((k) => k.startsWith('ai-debug-pins@'))
|
|
34
|
+
}
|
|
35
|
+
export const HINT =
|
|
36
|
+
'ai-debug-pins: notes are saved in .notes/. To have them go to Claude Code by themselves: ' +
|
|
37
|
+
'claude plugin marketplace add TiagoJeronimo/ai-debug-pins && claude plugin install ai-debug-pins@ai-debug-pins'
|
|
38
|
+
|
|
27
39
|
export function handler({ dir = '.notes', prefix = '/', log = console.log } = {}) {
|
|
28
40
|
const out = resolve(process.cwd(), dir)
|
|
29
41
|
return async (req, res, next = () => send(res, 404, { error: 'not found' })) => {
|
|
@@ -53,7 +65,7 @@ export function handler({ dir = '.notes', prefix = '/', log = console.log } = {}
|
|
|
53
65
|
if (png && !png.subarray(0, 8).equals(PNG)) return send(res, 400, { error: 'the picture is not a PNG' })
|
|
54
66
|
const id = await saveNote(out, { ...body, time: undefined }, png)
|
|
55
67
|
log(`ai-debug-pins: ${dir}/notes.md ← ${id}`)
|
|
56
|
-
send(res, 200, { id, dir })
|
|
68
|
+
send(res, 200, { id, dir, claude: await claudePlugin() })
|
|
57
69
|
} catch (e) {
|
|
58
70
|
send(res, e.status ?? 500, { error: e.message })
|
|
59
71
|
}
|
package/vite.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The Vite plugin: puts the note button on every page of the dev server and saves what it sends.
|
|
2
2
|
// apply: 'serve', so nothing of it reaches a production build.
|
|
3
|
-
import { handler } from './server.js'
|
|
3
|
+
import { handler, claudePlugin, HINT } from './server.js'
|
|
4
4
|
|
|
5
5
|
export default function debugPins({ dir = '.notes' } = {}) {
|
|
6
6
|
return {
|
|
@@ -11,6 +11,7 @@ export default function debugPins({ dir = '.notes' } = {}) {
|
|
|
11
11
|
],
|
|
12
12
|
configureServer(server) {
|
|
13
13
|
server.middlewares.use(handler({ dir, prefix: '/@ai-debug-pins/', log: (m) => server.config.logger.info(m) }))
|
|
14
|
+
claudePlugin().then((ok) => ok || server.config.logger.info(HINT))
|
|
14
15
|
},
|
|
15
16
|
}
|
|
16
17
|
}
|