pinokiod 8.4.0 → 8.4.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/package.json +1 -1
- package/server/public/agent-bar-compose.js +7 -0
- package/server/public/agent-bar-launch.js +45 -0
- package/server/public/agent-bar-search.css +45 -0
- package/server/public/agent-bar-search.js +265 -0
- package/server/public/agent-bar-shortcut.css +30 -0
- package/server/public/agent-bar-shortcut.js +103 -0
- package/server/public/agent-bar.js +3 -1
- package/server/public/request-strip.js +146 -0
- package/server/views/app.ejs +2 -0
- package/server/views/partials/main_sidebar.ejs +4 -0
- package/server/views/terminal.ejs +5 -0
- package/system/plugin/cursor/pinokio.js +11 -0
- package/system/plugin/vscode/pinokio.js +78 -12
- package/test/agent-bar-launch.test.js +47 -0
- package/test/agent-bar-search.test.js +314 -0
- package/test/agent-bar-shortcut.test.js +215 -0
- package/test/desktop-plugin-requests.test.js +112 -0
- package/test/request-strip.test.js +110 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// The strip a terminal page shows when a plugin's tool was started without the
|
|
2
|
+
// request (server/public/request-strip.js). The real script runs in a page that
|
|
3
|
+
// has only the terminal's place, with a stand-in for the terminal that writes
|
|
4
|
+
// down what it is given.
|
|
5
|
+
const assert = require('node:assert/strict')
|
|
6
|
+
const fs = require('node:fs')
|
|
7
|
+
const path = require('node:path')
|
|
8
|
+
const test = require('node:test')
|
|
9
|
+
const { JSDOM } = require('jsdom')
|
|
10
|
+
|
|
11
|
+
const source = fs.readFileSync(path.resolve(__dirname, '../server/public/request-strip.js'), 'utf8')
|
|
12
|
+
const LINE = 'My message is in sessions/s1/request.md. Read it and respond as if I had typed it here.'
|
|
13
|
+
const ADDRESS = `http://127.0.0.1:42000/run/plugin/tool/pinokio.js?cwd=%2Fw&session=s1&prompt=${encodeURIComponent(LINE)}`
|
|
14
|
+
|
|
15
|
+
function page(t, address = ADDRESS, storage) {
|
|
16
|
+
const dom = new JSDOM('<!doctype html><body><div class="wrap"><div id="terminal"></div></div></body>', {
|
|
17
|
+
url: address,
|
|
18
|
+
runScripts: 'outside-only',
|
|
19
|
+
})
|
|
20
|
+
t.after(() => dom.window.close())
|
|
21
|
+
const { window } = dom
|
|
22
|
+
if (storage) for (const [key, value] of Object.entries(storage)) window.sessionStorage.setItem(key, value)
|
|
23
|
+
const pasted = []
|
|
24
|
+
const keys = []
|
|
25
|
+
const term = { paste: (text) => pasted.push(text), input: (data) => keys.push(data), focus() {} }
|
|
26
|
+
window.eval(source)
|
|
27
|
+
if (!storage || !storage.late) window.PinokioRequestStrip.attach(term)
|
|
28
|
+
const strip = () => window.document.querySelector('.request-strip')
|
|
29
|
+
const start = (method, params) => window.PinokioRequestStrip.step({ type: 'start', data: { method, params } })
|
|
30
|
+
return { window, strip, start, pasted, keys, term }
|
|
31
|
+
}
|
|
32
|
+
const TOOL = { message: 'freebuff', path: '/w', input: true }
|
|
33
|
+
|
|
34
|
+
test('a tool started by a command without the request: the strip, above the terminal', (t) => {
|
|
35
|
+
const p = page(t)
|
|
36
|
+
assert.equal(p.strip(), null)
|
|
37
|
+
p.start('shell.run', TOOL)
|
|
38
|
+
assert.ok(p.strip())
|
|
39
|
+
assert.equal(p.strip().nextElementSibling.id, 'terminal')
|
|
40
|
+
assert.equal(p.strip().querySelector('.request-strip__title').textContent, 'This tool started without your message')
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
test('Send pastes the request line into the terminal, presses Enter a moment later, and the strip goes for good', async (t) => {
|
|
44
|
+
const p = page(t)
|
|
45
|
+
p.start('shell.run', TOOL)
|
|
46
|
+
assert.equal(p.strip().querySelector('.request-strip__send').textContent, 'Send message')
|
|
47
|
+
p.strip().querySelector('.request-strip__send').click()
|
|
48
|
+
assert.deepEqual(p.pasted, [LINE])
|
|
49
|
+
assert.deepEqual(p.keys, [], 'Enter does not come with the paste')
|
|
50
|
+
assert.equal(p.strip(), null)
|
|
51
|
+
for (let i = 0; i < 100 && p.keys.length === 0; i += 1) await new Promise((resolve) => setTimeout(resolve, 10))
|
|
52
|
+
assert.deepEqual(p.keys, ['\r'])
|
|
53
|
+
p.start('shell.run', TOOL)
|
|
54
|
+
assert.equal(p.strip(), null)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
test('dismissed, it stays away', (t) => {
|
|
58
|
+
const p = page(t)
|
|
59
|
+
p.start('shell.run', TOOL)
|
|
60
|
+
p.strip().querySelector('.request-strip__close').click()
|
|
61
|
+
assert.equal(p.strip(), null)
|
|
62
|
+
assert.deepEqual(p.pasted, [])
|
|
63
|
+
p.start('shell.run', TOOL)
|
|
64
|
+
assert.equal(p.strip(), null)
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
test('a command that holds the request shows nothing, however it is written', (t) => {
|
|
68
|
+
for (const message of [`codex '${LINE}'`, { _: ['claude', LINE] }, { _: ['opencode'], prompt: LINE }]) {
|
|
69
|
+
const p = page(t)
|
|
70
|
+
p.start('shell.run', { message, path: '/w', input: true })
|
|
71
|
+
assert.equal(p.strip(), null)
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('the request held by an earlier step counts for the steps after it', (t) => {
|
|
76
|
+
const p = page(t)
|
|
77
|
+
p.start('fs.write', { path: 'ask.txt', text: LINE })
|
|
78
|
+
p.start('shell.run', TOOL)
|
|
79
|
+
assert.equal(p.strip(), null)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('nothing shows for a step that takes no typing, a launch without a request, or other packets', (t) => {
|
|
83
|
+
const p = page(t)
|
|
84
|
+
p.start('shell.run', { message: 'npm install -g freebuff' })
|
|
85
|
+
p.start('exec', { message: 'cursor .' })
|
|
86
|
+
p.window.PinokioRequestStrip.step({ type: 'stream', data: { raw: 'hello' } })
|
|
87
|
+
p.window.PinokioRequestStrip.step({ type: 'start', data: { title: 'Started' } })
|
|
88
|
+
assert.equal(p.strip(), null)
|
|
89
|
+
|
|
90
|
+
const bare = page(t, 'http://127.0.0.1:42000/run/plugin/tool/pinokio.js?cwd=%2Fw&session=s2')
|
|
91
|
+
bare.start('shell.run', TOOL)
|
|
92
|
+
assert.equal(bare.strip(), null)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('the page loaded again: a strip that was showing comes back with the terminal, one that was answered does not', (t) => {
|
|
96
|
+
const showing = page(t, ADDRESS, { 'pinokio:request-strip:s1': 'shown', late: 'yes' })
|
|
97
|
+
assert.equal(showing.strip(), null, 'not before the page has its terminal')
|
|
98
|
+
showing.window.PinokioRequestStrip.attach(showing.term)
|
|
99
|
+
assert.ok(showing.strip())
|
|
100
|
+
const answered = page(t, ADDRESS, { 'pinokio:request-strip:s1': 'done' })
|
|
101
|
+
assert.equal(answered.strip(), null)
|
|
102
|
+
answered.start('shell.run', TOOL)
|
|
103
|
+
assert.equal(answered.strip(), null)
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
test('a packet the strip cannot read does not stop the page', (t) => {
|
|
107
|
+
const p = page(t)
|
|
108
|
+
const odd = { type: 'start', data: { method: 'shell.run', get params() { throw new Error('no') } } }
|
|
109
|
+
assert.doesNotThrow(() => p.window.PinokioRequestStrip.step(odd))
|
|
110
|
+
})
|