@qvac/harness 1.0.0-rc.21 → 1.0.0-rc.22
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 +44 -0
- package/README.md +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +2 -4
- package/dist-lib/lib/capabilities/tool-turns/answered.d.ts +15 -0
- package/dist-lib/lib/capabilities/tool-turns/answered.js +16 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +2 -0
- package/dist-lib/lib/capabilities/tool-turns.js +1 -0
- package/dist-lib/lib/contract/completion.d.ts +2 -1
- package/dist-lib/lib/machine/completion/actions/tools.js +7 -1
- package/dist-lib/lib/tools/files/glob.js +48 -9
- package/dist-lib/lib/tools/files/grep.js +27 -13
- package/dist-lib/lib/tools/files/read-file.js +120 -76
- package/dist-lib/lib/tools/fs/suggest.d.ts +8 -0
- package/dist-lib/lib/tools/fs/suggest.js +110 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +3 -0
- package/dist-lib/lib/tools/fs/tool-path.js +13 -0
- package/dist-lib/lib/tools/toolsets.d.ts +1 -1
- package/dist-lib/lib/tools/toolsets.js +1 -0
- package/dist-lib/plugins/diagrams/draw.d.ts +10 -0
- package/dist-lib/plugins/diagrams/draw.js +90 -0
- package/dist-lib/plugins/diagrams/index.d.ts +13 -0
- package/dist-lib/plugins/diagrams/index.js +15 -0
- package/dist-lib/plugins/diagrams/render.d.ts +16 -0
- package/dist-lib/plugins/diagrams/render.js +285 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/package.json +5 -1
- package/worker/harness-sidecar.mjs +2 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
export const DIAGRAM_TYPES = [
|
|
2
|
+
'flowchart',
|
|
3
|
+
'sequence',
|
|
4
|
+
'state',
|
|
5
|
+
'mindmap',
|
|
6
|
+
'er',
|
|
7
|
+
'class',
|
|
8
|
+
'timeline',
|
|
9
|
+
'gantt',
|
|
10
|
+
'pie'
|
|
11
|
+
];
|
|
12
|
+
const LABEL_LIMIT = 80;
|
|
13
|
+
function text(raw) {
|
|
14
|
+
const flat = (raw ?? '').replace(/\s+/g, ' ').trim();
|
|
15
|
+
const bounded = flat.length > LABEL_LIMIT ? `${flat.slice(0, LABEL_LIMIT - 1)}…` : flat;
|
|
16
|
+
return bounded.replace(/"/g, "'").replace(/#/g, '#');
|
|
17
|
+
}
|
|
18
|
+
function key(name) {
|
|
19
|
+
return name.replace(/\s+/g, ' ').trim().toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
class Ids {
|
|
22
|
+
_ids = new Map();
|
|
23
|
+
_prefix;
|
|
24
|
+
names = [];
|
|
25
|
+
constructor(prefix) {
|
|
26
|
+
this._prefix = prefix;
|
|
27
|
+
}
|
|
28
|
+
has(name) {
|
|
29
|
+
return this._ids.has(key(name));
|
|
30
|
+
}
|
|
31
|
+
of(name) {
|
|
32
|
+
const k = key(name);
|
|
33
|
+
let id = this._ids.get(k);
|
|
34
|
+
if (id === undefined) {
|
|
35
|
+
id = `${this._prefix}${this._ids.size + 1}`;
|
|
36
|
+
this._ids.set(k, id);
|
|
37
|
+
this.names.push(name);
|
|
38
|
+
}
|
|
39
|
+
return id;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function present(name) {
|
|
43
|
+
return name !== undefined && key(name).length > 0;
|
|
44
|
+
}
|
|
45
|
+
function flowchart(links, direction, { numbered = false } = {}) {
|
|
46
|
+
const ids = new Ids('n');
|
|
47
|
+
const lines = [`flowchart ${direction === 'horizontal' ? 'LR' : 'TD'}`];
|
|
48
|
+
const node = (name) => {
|
|
49
|
+
const seen = ids.has(name);
|
|
50
|
+
const id = ids.of(name);
|
|
51
|
+
if (seen) {
|
|
52
|
+
return id;
|
|
53
|
+
}
|
|
54
|
+
const label = text(name);
|
|
55
|
+
return name.trim().endsWith('?') ? `${id}{"${label}"}` : `${id}["${label}"]`;
|
|
56
|
+
};
|
|
57
|
+
links.forEach((link, at) => {
|
|
58
|
+
const from = node(link.from);
|
|
59
|
+
const target = present(link.to) || !numbered ? link.to : link.from;
|
|
60
|
+
if (!present(target)) {
|
|
61
|
+
lines.push(` ${from}`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const to = node(target);
|
|
65
|
+
const label = numbered ? `${at + 1}. ${link.label ?? ''}`.trim() : (link.label ?? '');
|
|
66
|
+
lines.push(present(label) ? ` ${from} -->|"${text(label)}"| ${to}` : ` ${from} --> ${to}`);
|
|
67
|
+
});
|
|
68
|
+
return lines;
|
|
69
|
+
}
|
|
70
|
+
function sequence(links) {
|
|
71
|
+
const ids = new Ids('p');
|
|
72
|
+
for (const link of links) {
|
|
73
|
+
ids.of(link.from);
|
|
74
|
+
if (present(link.to)) {
|
|
75
|
+
ids.of(link.to);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const lines = [
|
|
79
|
+
'sequenceDiagram',
|
|
80
|
+
...ids.names.map((name) => ` participant ${ids.of(name)} as ${text(name).replace(/;/g, ',')}`)
|
|
81
|
+
];
|
|
82
|
+
const calls = new Set();
|
|
83
|
+
for (const link of links) {
|
|
84
|
+
const from = ids.of(link.from);
|
|
85
|
+
const to = present(link.to) ? ids.of(link.to) : from;
|
|
86
|
+
const arrow = calls.has(`${to}>${from}`) ? '-->>' : '->>';
|
|
87
|
+
calls.add(`${from}>${to}`);
|
|
88
|
+
lines.push(` ${from}${arrow}${to}: ${text(link.label).replace(/;/g, ',') || ' '}`);
|
|
89
|
+
}
|
|
90
|
+
return lines;
|
|
91
|
+
}
|
|
92
|
+
const TERMINAL = new Set(['[*]', 'start', 'end']);
|
|
93
|
+
function state(links, direction) {
|
|
94
|
+
const ids = new Ids('s');
|
|
95
|
+
const lines = ['stateDiagram-v2'];
|
|
96
|
+
if (direction === 'horizontal') {
|
|
97
|
+
lines.push(' direction LR');
|
|
98
|
+
}
|
|
99
|
+
const ref = (name) => {
|
|
100
|
+
if (TERMINAL.has(key(name))) {
|
|
101
|
+
return '[*]';
|
|
102
|
+
}
|
|
103
|
+
const seen = ids.has(name);
|
|
104
|
+
const id = ids.of(name);
|
|
105
|
+
if (!seen) {
|
|
106
|
+
lines.push(` state "${text(name)}" as ${id}`);
|
|
107
|
+
}
|
|
108
|
+
return id;
|
|
109
|
+
};
|
|
110
|
+
for (const link of links) {
|
|
111
|
+
const from = ref(link.from);
|
|
112
|
+
if (!present(link.to)) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const to = ref(link.to);
|
|
116
|
+
const label = item(link.label);
|
|
117
|
+
lines.push(label ? ` ${from} --> ${to} : ${label}` : ` ${from} --> ${to}`);
|
|
118
|
+
}
|
|
119
|
+
return lines;
|
|
120
|
+
}
|
|
121
|
+
function mindmap(links) {
|
|
122
|
+
const children = new Map();
|
|
123
|
+
const names = new Map();
|
|
124
|
+
const targets = new Set();
|
|
125
|
+
for (const link of links) {
|
|
126
|
+
names.set(key(link.from), names.get(key(link.from)) ?? link.from);
|
|
127
|
+
if (!present(link.to)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
names.set(key(link.to), names.get(key(link.to)) ?? link.to);
|
|
131
|
+
targets.add(key(link.to));
|
|
132
|
+
const list = children.get(key(link.from)) ?? [];
|
|
133
|
+
if (!list.includes(key(link.to))) {
|
|
134
|
+
list.push(key(link.to));
|
|
135
|
+
}
|
|
136
|
+
children.set(key(link.from), list);
|
|
137
|
+
}
|
|
138
|
+
const order = [...names.keys()];
|
|
139
|
+
const root = order.find((k) => !targets.has(k)) ?? order[0];
|
|
140
|
+
const lines = ['mindmap'];
|
|
141
|
+
const placed = new Set();
|
|
142
|
+
let count = 0;
|
|
143
|
+
const place = (k, depth) => {
|
|
144
|
+
if (placed.has(k)) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
placed.add(k);
|
|
148
|
+
count++;
|
|
149
|
+
lines.push(`${' '.repeat(depth + 1)}m${count}["${text(names.get(k))}"]`);
|
|
150
|
+
for (const child of children.get(k) ?? []) {
|
|
151
|
+
place(child, depth + 1);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
if (root !== undefined) {
|
|
155
|
+
place(root, 0);
|
|
156
|
+
}
|
|
157
|
+
for (const k of order) {
|
|
158
|
+
place(k, 1);
|
|
159
|
+
}
|
|
160
|
+
return lines;
|
|
161
|
+
}
|
|
162
|
+
function er(links) {
|
|
163
|
+
const ids = new Ids('e');
|
|
164
|
+
const declared = [];
|
|
165
|
+
const relations = [];
|
|
166
|
+
const ref = (name) => {
|
|
167
|
+
const seen = ids.has(name);
|
|
168
|
+
const id = ids.of(name);
|
|
169
|
+
if (!seen) {
|
|
170
|
+
declared.push(` ${id}["${text(name).replace(/\\/g, '/').replace(/%/g, '%')}"]`);
|
|
171
|
+
}
|
|
172
|
+
return id;
|
|
173
|
+
};
|
|
174
|
+
for (const link of links) {
|
|
175
|
+
const from = ref(link.from);
|
|
176
|
+
if (present(link.to)) {
|
|
177
|
+
relations.push(` ${from} ||--o{ ${ref(link.to)} : "${text(link.label) || 'has'}"`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return ['erDiagram', ...declared, ...relations];
|
|
181
|
+
}
|
|
182
|
+
function classes(links) {
|
|
183
|
+
const ids = new Ids('c');
|
|
184
|
+
const declared = [];
|
|
185
|
+
const relations = [];
|
|
186
|
+
const ref = (name) => {
|
|
187
|
+
const seen = ids.has(name);
|
|
188
|
+
const id = ids.of(name);
|
|
189
|
+
if (!seen) {
|
|
190
|
+
declared.push(` class ${id}["${text(name)}"]`);
|
|
191
|
+
}
|
|
192
|
+
return id;
|
|
193
|
+
};
|
|
194
|
+
for (const link of links) {
|
|
195
|
+
const parent = ref(link.from);
|
|
196
|
+
if (present(link.to)) {
|
|
197
|
+
const label = item(link.label).replace(/\{/g, '(').replace(/\}/g, ')').replace(/\\/g, '/');
|
|
198
|
+
relations.push(` ${parent} <|-- ${ref(link.to)}${label ? ` : ${label}` : ''}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return ['classDiagram', ...declared, ...relations];
|
|
202
|
+
}
|
|
203
|
+
function item(raw) {
|
|
204
|
+
return text(raw).replace(/:/g, '꞉').replace(/;/g, ',');
|
|
205
|
+
}
|
|
206
|
+
const GANTT_KEYWORD = /^(click|section|title|dateformat|axisformat|tickinterval|excludes|includes|todaymarker|weekday|weekend|inclusiveenddates|topaxis|displaymode|acctitle|accdescr)\b/i;
|
|
207
|
+
function task(raw) {
|
|
208
|
+
const name = item(raw);
|
|
209
|
+
return GANTT_KEYWORD.test(name) ? `‣ ${name}` : name;
|
|
210
|
+
}
|
|
211
|
+
function timeline(links) {
|
|
212
|
+
const periods = new Map();
|
|
213
|
+
for (const link of links) {
|
|
214
|
+
const period = periods.get(key(link.from)) ?? { name: link.from, events: [] };
|
|
215
|
+
const event = present(link.to) ? link.to : link.label;
|
|
216
|
+
if (present(event)) {
|
|
217
|
+
period.events.push(item(event));
|
|
218
|
+
}
|
|
219
|
+
periods.set(key(link.from), period);
|
|
220
|
+
}
|
|
221
|
+
return [
|
|
222
|
+
'timeline',
|
|
223
|
+
...[...periods.values()].map(({ name, events }) => [` ${item(name)}`, ...events].join(' : '))
|
|
224
|
+
];
|
|
225
|
+
}
|
|
226
|
+
function days(raw) {
|
|
227
|
+
const match = /(\d+(?:\.\d+)?)\s*(d|days?|w|weeks?)?(?![a-z])/i.exec((raw ?? '').slice(0, LABEL_LIMIT));
|
|
228
|
+
if (!match) {
|
|
229
|
+
return 1;
|
|
230
|
+
}
|
|
231
|
+
const perUnit = match[2]?.toLowerCase().startsWith('w') ? 7 : 1;
|
|
232
|
+
return Math.max(1, Math.round(Number(match[1]) * perUnit));
|
|
233
|
+
}
|
|
234
|
+
function gantt(links, today) {
|
|
235
|
+
const start = today.toISOString().slice(0, 10);
|
|
236
|
+
const lines = ['gantt', ' dateFormat YYYY-MM-DD'];
|
|
237
|
+
let section;
|
|
238
|
+
links.forEach((link, at) => {
|
|
239
|
+
if (present(link.label) && link.label !== section) {
|
|
240
|
+
section = link.label;
|
|
241
|
+
lines.push(` section ${task(section)}`);
|
|
242
|
+
}
|
|
243
|
+
const when = at === 0 ? start : `after t${at}`;
|
|
244
|
+
lines.push(` ${task(link.from)} :t${at + 1}, ${when}, ${days(link.to)}d`);
|
|
245
|
+
});
|
|
246
|
+
return lines;
|
|
247
|
+
}
|
|
248
|
+
export function sliceValue(link) {
|
|
249
|
+
const match = /-?\d+(?:\.\d+)?/.exec(`${link.to ?? ''} ${link.label ?? ''}`);
|
|
250
|
+
const value = match ? Number(match[0]) : Number.NaN;
|
|
251
|
+
return value > 0 ? value : undefined;
|
|
252
|
+
}
|
|
253
|
+
function pie(links) {
|
|
254
|
+
return [
|
|
255
|
+
'pie',
|
|
256
|
+
...links.flatMap((link) => {
|
|
257
|
+
const value = sliceValue(link);
|
|
258
|
+
return value === undefined ? [] : [` "${text(link.from)}" : ${value}`];
|
|
259
|
+
})
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
export function renderMermaid({ type, direction, links, today }) {
|
|
263
|
+
switch (type) {
|
|
264
|
+
case 'flowchart':
|
|
265
|
+
return flowchart(links, direction).join('\n');
|
|
266
|
+
case 'sequence':
|
|
267
|
+
return (direction === 'horizontal'
|
|
268
|
+
? flowchart(links, direction, { numbered: true })
|
|
269
|
+
: sequence(links)).join('\n');
|
|
270
|
+
case 'state':
|
|
271
|
+
return state(links, direction).join('\n');
|
|
272
|
+
case 'mindmap':
|
|
273
|
+
return mindmap(links).join('\n');
|
|
274
|
+
case 'er':
|
|
275
|
+
return er(links).join('\n');
|
|
276
|
+
case 'class':
|
|
277
|
+
return classes(links).join('\n');
|
|
278
|
+
case 'timeline':
|
|
279
|
+
return timeline(links).join('\n');
|
|
280
|
+
case 'gantt':
|
|
281
|
+
return gantt(links, today ?? new Date()).join('\n');
|
|
282
|
+
case 'pie':
|
|
283
|
+
return pie(links).join('\n');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qvac/harness",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"bare": ">=1.33.4",
|
|
@@ -404,6 +404,10 @@
|
|
|
404
404
|
"types": "./dist-lib/plugins/translation/index.d.ts",
|
|
405
405
|
"default": "./dist-lib/plugins/translation/index.js"
|
|
406
406
|
},
|
|
407
|
+
"./plugins/diagrams": {
|
|
408
|
+
"types": "./dist-lib/plugins/diagrams/index.d.ts",
|
|
409
|
+
"default": "./dist-lib/plugins/diagrams/index.js"
|
|
410
|
+
},
|
|
407
411
|
"./plugins/weather": {
|
|
408
412
|
"types": "./dist-lib/plugins/weather/index.d.ts",
|
|
409
413
|
"default": "./dist-lib/plugins/weather/index.js"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// bare-stow entry: the first-party plugins on the shared boot; a host entry composes the same two
|
|
2
2
|
import '../dist-lib/lib/hardware/gpu-probe-entry.js'
|
|
3
3
|
import { HarnessSidecar } from '../dist-lib/lib/sidecar/index.js'
|
|
4
|
+
import { Diagrams } from '../dist-lib/plugins/diagrams/index.js'
|
|
4
5
|
import { Image } from '../dist-lib/plugins/image/index.js'
|
|
5
6
|
import { Knowledge } from '../dist-lib/plugins/knowledge/index.js'
|
|
6
7
|
import { McpPlugin } from '../dist-lib/plugins/mcp/index.js'
|
|
@@ -29,6 +30,7 @@ export function firstPartyPlugins({
|
|
|
29
30
|
new Speech(pluginOptions.speech),
|
|
30
31
|
new TranslationPlugin(),
|
|
31
32
|
new Weather({ read: ['weather_lookup'] }),
|
|
33
|
+
new Diagrams({ read: ['draw_diagram'] }),
|
|
32
34
|
new WebSearchPlugin({ read: ['web_search'] }),
|
|
33
35
|
// granted read so a skill's declared read methods on its server do not ask
|
|
34
36
|
new McpPlugin({
|