ceulen 0.8.0 → 0.9.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/CHANGELOG.md +35 -0
- package/extensions/lib/registry.ts +8 -1
- package/extensions/modules/a2a/configPanel.ts +435 -0
- package/extensions/modules/a2a/index.ts +1117 -0
- package/extensions/modules/a2a/lib/activity.ts +173 -0
- package/extensions/modules/a2a/lib/client.ts +1061 -0
- package/extensions/modules/a2a/lib/config.ts +920 -0
- package/extensions/modules/a2a/lib/discovery.ts +158 -0
- package/extensions/modules/a2a/lib/gateway.ts +889 -0
- package/extensions/modules/a2a/lib/mdns.ts +233 -0
- package/extensions/modules/a2a/lib/outcome.ts +48 -0
- package/extensions/modules/a2a/lib/persistence.ts +123 -0
- package/extensions/modules/a2a/lib/protocol.ts +506 -0
- package/extensions/modules/a2a/lib/registry.ts +146 -0
- package/extensions/modules/a2a/lib/retry.ts +86 -0
- package/extensions/modules/a2a/lib/security.ts +394 -0
- package/extensions/modules/a2a/lib/server.ts +1436 -0
- package/extensions/modules/a2a/test/activity.test.ts +138 -0
- package/extensions/modules/a2a/test/bridge.test.ts +101 -0
- package/extensions/modules/a2a/test/broadcast-parse.test.ts +31 -0
- package/extensions/modules/a2a/test/chai.ts +101 -0
- package/extensions/modules/a2a/test/client.test.ts +856 -0
- package/extensions/modules/a2a/test/completion-guard.test.ts +73 -0
- package/extensions/modules/a2a/test/config.test.ts +1396 -0
- package/extensions/modules/a2a/test/configPanel.test.ts +393 -0
- package/extensions/modules/a2a/test/discovery.test.ts +144 -0
- package/extensions/modules/a2a/test/extension.test.ts +135 -0
- package/extensions/modules/a2a/test/gateway.test.ts +1449 -0
- package/extensions/modules/a2a/test/helpers.ts +39 -0
- package/extensions/modules/a2a/test/mdns.test.ts +131 -0
- package/extensions/modules/a2a/test/outcome.test.ts +61 -0
- package/extensions/modules/a2a/test/persistence.test.ts +92 -0
- package/extensions/modules/a2a/test/protocol.test.ts +217 -0
- package/extensions/modules/a2a/test/registry.test.ts +114 -0
- package/extensions/modules/a2a/test/retry.test.ts +136 -0
- package/extensions/modules/a2a/test/security.test.ts +281 -0
- package/extensions/modules/a2a/test/server.test.ts +1966 -0
- package/extensions/modules/a2a/test/tmp.ts +59 -0
- package/extensions/modules/a2a/test/vendor.test.ts +57 -0
- package/extensions/modules/a2a/types/bonjour-service.d.ts +22 -0
- package/extensions/modules/a2a/vendor/VENDORED.md +18 -0
- package/extensions/modules/a2a/vendor/package.json +1 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/LICENSE +23 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/index.d.ts +14 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/index.js +57 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/KeyValue.d.ts +4 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/KeyValue.js +3 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/bonjour.d.ts +13 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/bonjour.js +50 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/browser.d.ts +41 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/browser.js +209 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/dns-txt.d.ts +9 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/dns-txt.js +42 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/mdns-server.d.ts +14 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/mdns-server.js +119 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/registry.d.ts +14 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/registry.js +142 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service-types.d.ts +7 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service-types.js +53 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service.d.ts +58 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/service.js +130 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/dns-equal.d.ts +1 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/dns-equal.js +13 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/equal-txt.d.ts +1 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/equal-txt.js +17 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-service.d.ts +4 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-service.js +22 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-txt.d.ts +3 -0
- package/extensions/modules/a2a/vendor/vendored_deps/bonjour-service/dist/lib/utils/filter-txt.js +6 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/classes.js +23 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/index.js +1761 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/opcodes.js +50 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/optioncodes.js +59 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/rcodes.js +50 -0
- package/extensions/modules/a2a/vendor/vendored_deps/dns-packet/types.js +103 -0
- package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/es6.js +73 -0
- package/extensions/modules/a2a/vendor/vendored_deps/fast-deep-equal/index.js +46 -0
- package/extensions/modules/a2a/vendor/vendored_deps/ip-codec/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/ip-codec/index.cjs +250 -0
- package/extensions/modules/a2a/vendor/vendored_deps/multicast-dns/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/multicast-dns/index.js +205 -0
- package/extensions/modules/a2a/vendor/vendored_deps/thunky/LICENSE +21 -0
- package/extensions/modules/a2a/vendor/vendored_deps/thunky/index.js +55 -0
- package/extensions/modules/composer/test/module.test.ts +2 -2
- package/extensions/modules/config/index.ts +2 -0
- package/extensions/modules/config/test/renderTools.test.ts +1 -1
- package/extensions/modules/todo/configPanel.ts +55 -0
- package/extensions/modules/todo/index.ts +46 -13
- package/extensions/modules/todo/lib/render.ts +271 -0
- package/extensions/modules/todo/lib/settings.ts +73 -0
- package/extensions/modules/todo/test/todo.test.ts +276 -0
- package/package.json +2 -2
- package/skills/a2a/SKILL.md +63 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
var packet = require('../dns-packet/index.js') // ponytail: vendored from multicast-dns 7.2.5 — path localized
|
|
2
|
+
var dgram = require('dgram')
|
|
3
|
+
var thunky = require('../thunky/index.js') // ponytail: vendored from multicast-dns 7.2.5 — path localized
|
|
4
|
+
var events = require('events')
|
|
5
|
+
var os = require('os')
|
|
6
|
+
|
|
7
|
+
var noop = function () {}
|
|
8
|
+
|
|
9
|
+
module.exports = function (opts) {
|
|
10
|
+
if (!opts) opts = {}
|
|
11
|
+
|
|
12
|
+
var that = new events.EventEmitter()
|
|
13
|
+
var port = typeof opts.port === 'number' ? opts.port : 5353
|
|
14
|
+
var type = opts.type || 'udp4'
|
|
15
|
+
var ip = opts.ip || opts.host || (type === 'udp4' ? '224.0.0.251' : null)
|
|
16
|
+
var me = {address: ip, port: port}
|
|
17
|
+
var memberships = {}
|
|
18
|
+
var destroyed = false
|
|
19
|
+
var interval = null
|
|
20
|
+
|
|
21
|
+
if (type === 'udp6' && (!ip || !opts.interface)) {
|
|
22
|
+
throw new Error('For IPv6 multicast you must specify `ip` and `interface`')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var socket = opts.socket || dgram.createSocket({
|
|
26
|
+
type: type,
|
|
27
|
+
reuseAddr: opts.reuseAddr !== false,
|
|
28
|
+
toString: function () {
|
|
29
|
+
return type
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
socket.on('error', function (err) {
|
|
34
|
+
if (err.code === 'EACCES' || err.code === 'EADDRINUSE') that.emit('error', err)
|
|
35
|
+
else that.emit('warning', err)
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
socket.on('message', function (message, rinfo) {
|
|
39
|
+
try {
|
|
40
|
+
message = packet.decode(message)
|
|
41
|
+
} catch (err) {
|
|
42
|
+
that.emit('warning', err)
|
|
43
|
+
return
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
that.emit('packet', message, rinfo)
|
|
47
|
+
|
|
48
|
+
if (message.type === 'query') that.emit('query', message, rinfo)
|
|
49
|
+
if (message.type === 'response') that.emit('response', message, rinfo)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
socket.on('listening', function () {
|
|
53
|
+
if (!port) port = me.port = socket.address().port
|
|
54
|
+
if (opts.multicast !== false) {
|
|
55
|
+
that.update()
|
|
56
|
+
interval = setInterval(that.update, 5000)
|
|
57
|
+
socket.setMulticastTTL(opts.ttl || 255)
|
|
58
|
+
socket.setMulticastLoopback(opts.loopback !== false)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
var bind = thunky(function (cb) {
|
|
63
|
+
if (!port || opts.bind === false) return cb(null)
|
|
64
|
+
socket.once('error', cb)
|
|
65
|
+
socket.bind(port, opts.bind || opts.interface, function () {
|
|
66
|
+
socket.removeListener('error', cb)
|
|
67
|
+
cb(null)
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
bind(function (err) {
|
|
72
|
+
if (err) return that.emit('error', err)
|
|
73
|
+
that.emit('ready')
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
that.send = function (value, rinfo, cb) {
|
|
77
|
+
if (typeof rinfo === 'function') return that.send(value, null, rinfo)
|
|
78
|
+
if (!cb) cb = noop
|
|
79
|
+
if (!rinfo) rinfo = me
|
|
80
|
+
else if (!rinfo.host && !rinfo.address) rinfo.address = me.address
|
|
81
|
+
|
|
82
|
+
bind(onbind)
|
|
83
|
+
|
|
84
|
+
function onbind (err) {
|
|
85
|
+
if (destroyed) return cb()
|
|
86
|
+
if (err) return cb(err)
|
|
87
|
+
var message = packet.encode(value)
|
|
88
|
+
socket.send(message, 0, message.length, rinfo.port, rinfo.address || rinfo.host, cb)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
that.response =
|
|
93
|
+
that.respond = function (res, rinfo, cb) {
|
|
94
|
+
if (Array.isArray(res)) res = {answers: res}
|
|
95
|
+
|
|
96
|
+
res.type = 'response'
|
|
97
|
+
res.flags = (res.flags || 0) | packet.AUTHORITATIVE_ANSWER
|
|
98
|
+
that.send(res, rinfo, cb)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
that.query = function (q, type, rinfo, cb) {
|
|
102
|
+
if (typeof type === 'function') return that.query(q, null, null, type)
|
|
103
|
+
if (typeof type === 'object' && type && type.port) return that.query(q, null, type, rinfo)
|
|
104
|
+
if (typeof rinfo === 'function') return that.query(q, type, null, rinfo)
|
|
105
|
+
if (!cb) cb = noop
|
|
106
|
+
|
|
107
|
+
if (typeof q === 'string') q = [{name: q, type: type || 'ANY'}]
|
|
108
|
+
if (Array.isArray(q)) q = {type: 'query', questions: q}
|
|
109
|
+
|
|
110
|
+
q.type = 'query'
|
|
111
|
+
that.send(q, rinfo, cb)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
that.destroy = function (cb) {
|
|
115
|
+
if (!cb) cb = noop
|
|
116
|
+
if (destroyed) return process.nextTick(cb)
|
|
117
|
+
destroyed = true
|
|
118
|
+
clearInterval(interval)
|
|
119
|
+
|
|
120
|
+
// Need to drop memberships by hand and ignore errors.
|
|
121
|
+
// socket.close() does not cope with errors.
|
|
122
|
+
for (var iface in memberships) {
|
|
123
|
+
try {
|
|
124
|
+
socket.dropMembership(ip, iface)
|
|
125
|
+
} catch (e) {
|
|
126
|
+
// eat it
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
memberships = {}
|
|
130
|
+
socket.close(cb)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
that.update = function () {
|
|
134
|
+
var ifaces = opts.interface ? [].concat(opts.interface) : allInterfaces()
|
|
135
|
+
var updated = false
|
|
136
|
+
|
|
137
|
+
for (var i = 0; i < ifaces.length; i++) {
|
|
138
|
+
var addr = ifaces[i]
|
|
139
|
+
if (memberships[addr]) continue
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
socket.addMembership(ip, addr)
|
|
143
|
+
memberships[addr] = true
|
|
144
|
+
updated = true
|
|
145
|
+
} catch (err) {
|
|
146
|
+
that.emit('warning', err)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (updated) {
|
|
151
|
+
if (socket.setMulticastInterface) {
|
|
152
|
+
try {
|
|
153
|
+
socket.setMulticastInterface(opts.interface || defaultInterface())
|
|
154
|
+
} catch (err) {
|
|
155
|
+
that.emit('warning', err)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
that.emit('networkInterface')
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return that
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function defaultInterface () {
|
|
166
|
+
var networks = os.networkInterfaces()
|
|
167
|
+
var names = Object.keys(networks)
|
|
168
|
+
|
|
169
|
+
for (var i = 0; i < names.length; i++) {
|
|
170
|
+
var net = networks[names[i]]
|
|
171
|
+
for (var j = 0; j < net.length; j++) {
|
|
172
|
+
var iface = net[j]
|
|
173
|
+
if (isIPv4(iface.family) && !iface.internal) {
|
|
174
|
+
if (os.platform() === 'darwin' && names[i] === 'en0') return iface.address
|
|
175
|
+
return '0.0.0.0'
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return '127.0.0.1'
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function allInterfaces () {
|
|
184
|
+
var networks = os.networkInterfaces()
|
|
185
|
+
var names = Object.keys(networks)
|
|
186
|
+
var res = []
|
|
187
|
+
|
|
188
|
+
for (var i = 0; i < names.length; i++) {
|
|
189
|
+
var net = networks[names[i]]
|
|
190
|
+
for (var j = 0; j < net.length; j++) {
|
|
191
|
+
var iface = net[j]
|
|
192
|
+
if (isIPv4(iface.family)) {
|
|
193
|
+
res.push(iface.address)
|
|
194
|
+
// could only addMembership once per interface (https://nodejs.org/api/dgram.html#dgram_socket_addmembership_multicastaddress_multicastinterface)
|
|
195
|
+
break
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return res
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function isIPv4 (family) { // for backwards compat
|
|
204
|
+
return family === 4 || family === 'IPv4'
|
|
205
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Mathias Buus
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
var nextTick = nextTickArgs
|
|
4
|
+
process.nextTick(upgrade, 42) // pass 42 and see if upgrade is called with it
|
|
5
|
+
|
|
6
|
+
module.exports = thunky
|
|
7
|
+
|
|
8
|
+
function thunky (fn) {
|
|
9
|
+
var state = run
|
|
10
|
+
return thunk
|
|
11
|
+
|
|
12
|
+
function thunk (callback) {
|
|
13
|
+
state(callback || noop)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function run (callback) {
|
|
17
|
+
var stack = [callback]
|
|
18
|
+
state = wait
|
|
19
|
+
fn(done)
|
|
20
|
+
|
|
21
|
+
function wait (callback) {
|
|
22
|
+
stack.push(callback)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function done (err) {
|
|
26
|
+
var args = arguments
|
|
27
|
+
state = isError(err) ? run : finished
|
|
28
|
+
while (stack.length) finished(stack.shift())
|
|
29
|
+
|
|
30
|
+
function finished (callback) {
|
|
31
|
+
nextTick(apply, callback, args)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function isError (err) { // inlined from util so this works in the browser
|
|
38
|
+
return Object.prototype.toString.call(err) === '[object Error]'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function noop () {}
|
|
42
|
+
|
|
43
|
+
function apply (callback, args) {
|
|
44
|
+
callback.apply(null, args)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function upgrade (val) {
|
|
48
|
+
if (val === 42) nextTick = process.nextTick
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function nextTickArgs (fn, a, b) {
|
|
52
|
+
process.nextTick(function () {
|
|
53
|
+
fn(a, b)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
@@ -305,8 +305,8 @@ describe("core module contract", () => {
|
|
|
305
305
|
it("nextDisabled excludes core modules; withEnableRow adds no row for them", async () => {
|
|
306
306
|
const { nextDisabled, withEnableRow } = await import("../../config/index.js");
|
|
307
307
|
// working = enabled set; nextDisabled lists the NOT-enabled non-core modules.
|
|
308
|
-
assert.deepEqual(nextDisabled(new Set(["munin"])), ["zai", "ponytail", "subagent", "plan", "todo", "repair", "serena", "fff", "web", "rules", "steering", "rtk"]);
|
|
309
|
-
assert.deepEqual(nextDisabled(new Set(["router", "classifier", "ux", "munin", "usage", "ponytail", "subagent", "plan", "todo", "repair", "serena", "fff", "web", "rules", "steering", "zai", "rtk", "config"])), [], "all-on → nothing disabled");
|
|
308
|
+
assert.deepEqual(nextDisabled(new Set(["munin"])), ["zai", "ponytail", "subagent", "plan", "a2a", "todo", "repair", "serena", "fff", "web", "rules", "steering", "rtk"]);
|
|
309
|
+
assert.deepEqual(nextDisabled(new Set(["router", "classifier", "ux", "munin", "usage", "ponytail", "subagent", "plan", "a2a", "todo", "repair", "serena", "fff", "web", "rules", "steering", "zai", "rtk", "config"])), [], "all-on → nothing disabled");
|
|
310
310
|
for (const core of ["composer", "advisor", "router", "classifier", "usage", "ux", "config"]) {
|
|
311
311
|
assert.ok(!nextDisabled(new Set()).includes(core), `core (${core}) is never disableable`);
|
|
312
312
|
}
|
|
@@ -253,10 +253,12 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
253
253
|
ux: { section: "UX discipline", icon: "📐" },
|
|
254
254
|
ponytail: { section: "Ponytail", icon: "🦥" },
|
|
255
255
|
plan: { section: "Plan mode", icon: "🗺️" },
|
|
256
|
+
todo: { section: "Todo", icon: "☑" },
|
|
256
257
|
serena: { section: "Serena" },
|
|
257
258
|
repair: { section: "Repair", icon: "🔧" },
|
|
258
259
|
fff: { section: "FFF search" },
|
|
259
260
|
web: { section: "Web", icon: "🌍" },
|
|
261
|
+
a2a: { section: "A2A", icon: "📡" },
|
|
260
262
|
rtk: { section: "RTK" },
|
|
261
263
|
config: { section: "Ceulen config", icon: "🧩" },
|
|
262
264
|
};
|
|
@@ -34,7 +34,7 @@ function toolGroups(): PanelGroup[] {
|
|
|
34
34
|
describe("render smoke — ported modules' /config sections", () => {
|
|
35
35
|
it("renders Enable + per-tool rows inside the boxed frame with zero overflow", () => {
|
|
36
36
|
const groups = toolGroups();
|
|
37
|
-
assert.equal(groups.length,
|
|
37
|
+
assert.equal(groups.length, 13, "serena + fff + ux + munin + classifier + advisor + subagent + repair + plan + todo + web + rules + a2a (rtk has no tools)");
|
|
38
38
|
const m = new ConfigPanelModel(groups, theme, "Settings");
|
|
39
39
|
m.getHeight = () => 40;
|
|
40
40
|
for (const w of [110, 100, 80, 60]) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* todo's /config contribution — Tasks tab, Todo section.
|
|
3
|
+
*
|
|
4
|
+
* One row: `todo.lingerSecs` — how long the all-done HUD stays above the
|
|
5
|
+
* editor before auto-clearing (OMP's tasks.todoClearDelay parity). Writes the
|
|
6
|
+
* GLOBAL agent-dir settings.json `todo` section (lib/settings.ts); read per
|
|
7
|
+
* commit, so a save applies live with no /reload.
|
|
8
|
+
*/
|
|
9
|
+
import { row, type PanelGroup } from "../../lib/panel.js";
|
|
10
|
+
import type { ModuleConfig } from "../../lib/registry.js";
|
|
11
|
+
import { LINGER_DESCRIPTIONS, LINGER_VALUES, readLingerSecs, writeTodoSection } from "./lib/settings.ts";
|
|
12
|
+
|
|
13
|
+
/** Working-copy panel groups. Exported for tests. */
|
|
14
|
+
export function buildTodoGroups(lingerSecs: { value: string }): PanelGroup[] {
|
|
15
|
+
return [
|
|
16
|
+
{
|
|
17
|
+
key: "todo",
|
|
18
|
+
label: "Todo",
|
|
19
|
+
tab: "Tasks",
|
|
20
|
+
icon: "☑",
|
|
21
|
+
rows: [
|
|
22
|
+
row("todo.lingerSecs", "Completed board lingers", "number", lingerSecs.value, (v) => {
|
|
23
|
+
lingerSecs.value = String(v ?? "");
|
|
24
|
+
}, {
|
|
25
|
+
menu: () => LINGER_VALUES.map((v) => ({ value: v, label: v === "-1" ? "Never" : `${Number(v) / 60} minute${Number(v) === 60 ? "" : "s"}`, description: LINGER_DESCRIPTIONS[v] })),
|
|
26
|
+
description: "How long the all-done TODO HUD stays above the editor before auto-clearing. Applies live.",
|
|
27
|
+
defaultValue: "60",
|
|
28
|
+
}),
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const OWNED_PREFIX = "todo.";
|
|
35
|
+
|
|
36
|
+
/** todo's ModuleConfig for the central /config panel. */
|
|
37
|
+
export function todoConfig(): ModuleConfig {
|
|
38
|
+
const before = String(readLingerSecs());
|
|
39
|
+
const working = { value: before };
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
groups: () => buildTodoGroups(working),
|
|
43
|
+
save: async (edited, ctx) => {
|
|
44
|
+
if (![...edited].some((k) => k.startsWith(OWNED_PREFIX))) return;
|
|
45
|
+
const n = parseInt(working.value, 10);
|
|
46
|
+
if (!Number.isFinite(n)) return;
|
|
47
|
+
try {
|
|
48
|
+
const file = writeTodoSection(n);
|
|
49
|
+
ctx.ui.notify(`Todo config saved to ${file} — applies live (read per commit).`, "info");
|
|
50
|
+
} catch (e) {
|
|
51
|
+
ctx.ui.notify(`Todo save failed: ${e instanceof Error ? e.message : e}`, "error");
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -39,12 +39,20 @@ import type {
|
|
|
39
39
|
ExtensionContext,
|
|
40
40
|
ToolDefinition,
|
|
41
41
|
} from "@earendil-works/pi-coding-agent";
|
|
42
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
42
43
|
import { Type, type Static } from "typebox";
|
|
44
|
+
import {
|
|
45
|
+
createTodoWidgetController,
|
|
46
|
+
renderTodoBoard,
|
|
47
|
+
type WidgetTheme,
|
|
48
|
+
} from "./lib/render.ts";
|
|
49
|
+
import { readLingerSecs } from "./lib/settings.ts";
|
|
43
50
|
import { readDisabledTools } from "../../lib/tools.js";
|
|
44
51
|
|
|
45
52
|
export const TODO_TOOL = "todo";
|
|
46
53
|
export const TODO_ENTRY_TYPE = "ceulen-todo";
|
|
47
54
|
export const TODO_STATUS_KEY = "ceulen-todo";
|
|
55
|
+
export const TODO_WIDGET_KEY = "ceulen-todo";
|
|
48
56
|
|
|
49
57
|
export type TodoStatus = "pending" | "in_progress" | "done" | "blocked";
|
|
50
58
|
|
|
@@ -118,23 +126,24 @@ function clonePhases(phases: readonly TodoPhase[]): TodoPhase[] {
|
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
/** A phase is BLOCKED when it has unmet blockers — derived, never stored. */
|
|
121
|
-
function isBlocked(phase: TodoPhase,
|
|
129
|
+
export function isBlocked(phase: TodoPhase, phases: readonly TodoPhase[]): boolean {
|
|
130
|
+
const byId = new Map(phases.map((p) => [p.id, p]));
|
|
122
131
|
return phase.blockedBy.some((dep) => {
|
|
123
132
|
const depPhase = byId.get(dep);
|
|
124
133
|
return depPhase !== undefined && depPhase.status !== "done";
|
|
125
134
|
});
|
|
126
135
|
}
|
|
127
136
|
|
|
128
|
-
function effectiveStatus(phase: TodoPhase,
|
|
129
|
-
return isBlocked(phase,
|
|
137
|
+
export function effectiveStatus(phase: TodoPhase, phases: readonly TodoPhase[]): TodoStatus {
|
|
138
|
+
return isBlocked(phase, phases) ? "blocked" : phase.status;
|
|
130
139
|
}
|
|
131
140
|
|
|
132
141
|
/** Next actionable phase: first running one, else the first pending unblocked phase. */
|
|
133
142
|
function nextActionable(phases: readonly TodoPhase[]): TodoPhase | undefined {
|
|
134
143
|
const byId = new Map(phases.map((p) => [p.id, p]));
|
|
135
144
|
return (
|
|
136
|
-
phases.find((p) => p.status === "in_progress" && !isBlocked(p,
|
|
137
|
-
phases.find((p) => p.status === "pending" && !isBlocked(p,
|
|
145
|
+
phases.find((p) => p.status === "in_progress" && !isBlocked(p, phases)) ??
|
|
146
|
+
phases.find((p) => p.status === "pending" && !isBlocked(p, phases))
|
|
138
147
|
);
|
|
139
148
|
}
|
|
140
149
|
|
|
@@ -146,9 +155,8 @@ function counts(phases: readonly TodoPhase[]): { done: number; total: number } {
|
|
|
146
155
|
export function statusLine(phases: readonly TodoPhase[]): string | undefined {
|
|
147
156
|
const { done, total } = counts(phases);
|
|
148
157
|
if (total === 0 || done === total) return undefined;
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
const blocked = phases.filter((p) => p.status !== "done" && isBlocked(p, byId)).length;
|
|
158
|
+
const active = phases.find((p) => p.status === "in_progress" && !isBlocked(p, phases));
|
|
159
|
+
const blocked = phases.filter((p) => p.status !== "done" && isBlocked(p, phases)).length;
|
|
152
160
|
return [
|
|
153
161
|
`▸ ${done}/${total} done`,
|
|
154
162
|
active ? `in_progress: ${active.title}` : "next: " + (nextActionable(phases)?.title ?? "—"),
|
|
@@ -165,7 +173,7 @@ function renderBoard(phases: readonly TodoPhase[], note?: string): string {
|
|
|
165
173
|
const byId = new Map(phases.map((p) => [p.id, p]));
|
|
166
174
|
const { done, total } = counts(phases);
|
|
167
175
|
const lines = phases.map((p, i) => {
|
|
168
|
-
const st = effectiveStatus(p,
|
|
176
|
+
const st = effectiveStatus(p, phases);
|
|
169
177
|
const waiters = p.blockedBy.filter((dep) => byId.get(dep)?.status !== "done");
|
|
170
178
|
const tail = [
|
|
171
179
|
st === "blocked" && waiters.length > 0 ? `blocked by ${waiters.join(", ")}` : undefined,
|
|
@@ -346,6 +354,14 @@ export default function todoModule(pi: ExtensionAPI): void {
|
|
|
346
354
|
let phases: TodoPhase[] = [];
|
|
347
355
|
/** Last live ctx — the status item is set through it on every mutation. */
|
|
348
356
|
let liveUi: ExtensionContext["ui"] | undefined;
|
|
357
|
+
/** Above-editor HUD (colored board + all-done linger). */
|
|
358
|
+
const widget = createTodoWidgetController();
|
|
359
|
+
|
|
360
|
+
const syncWidget = (ctx?: { mode?: string; ui: ExtensionContext["ui"] }): void => {
|
|
361
|
+
// getPhases: the render closure reads LIVE state — a captured array would
|
|
362
|
+
// freeze the HUD at the install-time snapshot (caught live in a herdr pane).
|
|
363
|
+
widget.sync(ctx, phases, readLingerSecs(), () => phases);
|
|
364
|
+
};
|
|
349
365
|
|
|
350
366
|
const syncStatus = (ui: ExtensionContext["ui"] | undefined = liveUi): void => {
|
|
351
367
|
if (!ui) return;
|
|
@@ -356,10 +372,11 @@ export default function todoModule(pi: ExtensionAPI): void {
|
|
|
356
372
|
}
|
|
357
373
|
};
|
|
358
374
|
|
|
359
|
-
const commit = (next: TodoPhase[],
|
|
375
|
+
const commit = (next: TodoPhase[], ctx?: { mode?: string; ui: ExtensionContext["ui"] }): void => {
|
|
360
376
|
phases = next;
|
|
361
377
|
pi.appendEntry(TODO_ENTRY_TYPE, { phases });
|
|
362
|
-
syncStatus(ui);
|
|
378
|
+
syncStatus(ctx?.ui);
|
|
379
|
+
syncWidget(ctx);
|
|
363
380
|
};
|
|
364
381
|
|
|
365
382
|
const tool: ToolDefinition<typeof todoSchema, { phases: TodoPhase[] }> = {
|
|
@@ -379,12 +396,24 @@ export default function todoModule(pi: ExtensionAPI): void {
|
|
|
379
396
|
],
|
|
380
397
|
defaultActive: !readDisabledTools().has(TODO_TOOL),
|
|
381
398
|
parameters: todoSchema,
|
|
399
|
+
// TUI-only: the colored board (status colors, strikethrough on done).
|
|
400
|
+
// The LLM-facing text content stays the plain board — this only swaps
|
|
401
|
+
// what the transcript draws. No phases in details → the plain text blob.
|
|
402
|
+
renderResult(result, _options, theme) {
|
|
403
|
+
const detail = result.details as { phases?: TodoPhase[] } | undefined;
|
|
404
|
+
const boardPhases = Array.isArray(detail?.phases) && detail!.phases!.every(isTodoPhase) ? detail!.phases! : [];
|
|
405
|
+
if (boardPhases.length === 0) {
|
|
406
|
+
const text = result.content[0];
|
|
407
|
+
return new Text(text?.type === "text" ? text.text : "", 0, 0);
|
|
408
|
+
}
|
|
409
|
+
return new Text(renderTodoBoard(boardPhases, theme as unknown as WidgetTheme).join("\n"), 0, 0);
|
|
410
|
+
},
|
|
382
411
|
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
383
412
|
const ui = ctx.ui;
|
|
384
413
|
liveUi = ui;
|
|
385
414
|
const result = applyTodo(phases, params);
|
|
386
415
|
const failed = result.errors.length > 0;
|
|
387
|
-
if (!failed && result.changed) commit(result.phases,
|
|
416
|
+
if (!failed && result.changed) commit(result.phases, ctx);
|
|
388
417
|
const effective = failed ? phases : result.phases;
|
|
389
418
|
// Mutations restate the batch contract; a pure view stays quiet.
|
|
390
419
|
const tail = failed
|
|
@@ -415,7 +444,7 @@ export default function todoModule(pi: ExtensionAPI): void {
|
|
|
415
444
|
ctx.ui.notify("Todo list is already empty.", "info");
|
|
416
445
|
return;
|
|
417
446
|
}
|
|
418
|
-
commit([], ctx
|
|
447
|
+
commit([], ctx);
|
|
419
448
|
ctx.ui.notify("Todo list cleared.", "info");
|
|
420
449
|
return;
|
|
421
450
|
}
|
|
@@ -436,11 +465,15 @@ export default function todoModule(pi: ExtensionAPI): void {
|
|
|
436
465
|
[];
|
|
437
466
|
phases = resolveTodoPhases(entries);
|
|
438
467
|
syncStatus(ctx.ui);
|
|
468
|
+
// A resumed session with open work shows the HUD again; an all-done
|
|
469
|
+
// snapshot from a previous session stays hidden (no re-linger).
|
|
470
|
+
syncWidget(ctx);
|
|
439
471
|
});
|
|
440
472
|
|
|
441
473
|
// The indicator must not leak past this runtime (subagent-precedent: the
|
|
442
474
|
// widget controller owns set + clear on session change).
|
|
443
475
|
pi.on("session_shutdown", () => {
|
|
476
|
+
widget.dispose();
|
|
444
477
|
try {
|
|
445
478
|
liveUi?.setStatus(TODO_STATUS_KEY, undefined);
|
|
446
479
|
} catch {
|