@open-agent-toolkit/cli 0.2.20 → 0.2.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.
Files changed (58) hide show
  1. package/assets/docs/workflows/projects/artifacts.md +1 -1
  2. package/assets/docs/workflows/skills/explainer-kit.md +188 -23
  3. package/assets/docs/workflows/skills/index.md +1 -1
  4. package/assets/public-package-versions.json +4 -4
  5. package/assets/skills/explainer-kit/SKILL.md +87 -25
  6. package/assets/skills/explainer-kit/briefs/deep-dive.md +35 -0
  7. package/assets/skills/explainer-kit/briefs/engineer-tour.md +45 -0
  8. package/assets/skills/explainer-kit/briefs/program-recap.md +41 -0
  9. package/assets/skills/explainer-kit/briefs/project-explainer.md +38 -0
  10. package/assets/skills/explainer-kit/briefs/project-page.md +38 -0
  11. package/assets/skills/explainer-kit/briefs/project-recap.md +47 -0
  12. package/assets/skills/explainer-kit/briefs/supporting-diagram.md +28 -0
  13. package/assets/skills/explainer-kit/briefs/walkthrough-deck.md +35 -0
  14. package/assets/skills/explainer-kit/examples/project-recap/content.md +57 -14
  15. package/assets/skills/explainer-kit/examples/project-recap/fact-base.json +104 -0
  16. package/assets/skills/explainer-kit/examples/project-recap/fact-base.md +26 -4
  17. package/assets/skills/explainer-kit/recipes/engineer-tour.json +27 -10
  18. package/assets/skills/explainer-kit/recipes/program-recap.json +35 -11
  19. package/assets/skills/explainer-kit/recipes/project-explainer.json +27 -10
  20. package/assets/skills/explainer-kit/recipes/project-recap.json +43 -11
  21. package/assets/skills/explainer-kit/references/contracts.md +45 -19
  22. package/assets/skills/explainer-kit/schemas/author-request.v2.schema.json +41 -0
  23. package/assets/skills/explainer-kit/schemas/author-result.v2.schema.json +52 -0
  24. package/assets/skills/explainer-kit/scripts/lib/browser-runtime.mjs +442 -0
  25. package/assets/skills/explainer-kit/scripts/lib/content-approval.mjs +223 -10
  26. package/assets/skills/explainer-kit/scripts/lib/contracts.mjs +28 -43
  27. package/assets/skills/explainer-kit/scripts/lib/diagram.mjs +237 -0
  28. package/assets/skills/explainer-kit/scripts/lib/html-safety.mjs +687 -0
  29. package/assets/skills/explainer-kit/scripts/lib/markdown.mjs +414 -0
  30. package/assets/skills/explainer-kit/scripts/lib/qa.mjs +313 -14
  31. package/assets/skills/explainer-kit/scripts/lib/recipes.mjs +314 -41
  32. package/assets/skills/explainer-kit/scripts/lib/records.mjs +61 -0
  33. package/assets/skills/explainer-kit/scripts/lib/render.mjs +166 -12
  34. package/assets/skills/explainer-kit/scripts/render-qa.mjs +152 -2
  35. package/assets/skills/explainer-kit/scripts/run.mjs +789 -272
  36. package/assets/skills/explainer-kit/templates/deck-shell.html +25 -5
  37. package/assets/skills/explainer-kit/templates/diagram-shell.html +29 -7
  38. package/assets/skills/explainer-kit/templates/engineer-tour.html +133 -9
  39. package/assets/skills/explainer-kit/templates/house-style.html +82 -0
  40. package/assets/skills/oat-brainstorm/SKILL.md +1 -1
  41. package/assets/skills/oat-brainstorm/scripts/helper.js +18 -11
  42. package/assets/skills/oat-brainstorm/scripts/server.cjs +109 -55
  43. package/assets/skills/oat-explainer-kit/SKILL.md +16 -9
  44. package/assets/skills/oat-explainer-kit/references/author-callback.md +51 -0
  45. package/assets/skills/oat-explainer-kit/references/lifecycle-contract.md +10 -8
  46. package/assets/skills/oat-explainer-kit/scripts/resolve-intent.mjs +14 -0
  47. package/assets/skills/oat-explainer-kit/scripts/run.mjs +7 -11
  48. package/assets/skills/oat-project-complete/SKILL.md +18 -2
  49. package/assets/skills/oat-project-implement/SKILL.md +1 -1
  50. package/assets/skills/oat-project-implement/references/completion-and-closeout.md +7 -1
  51. package/assets/skills/oat-wave-execute/SKILL.md +12 -19
  52. package/assets/skills/oat-wave-program/SKILL.md +12 -13
  53. package/dist/commands/init/tools/index.d.ts.map +1 -1
  54. package/dist/commands/init/tools/index.js +4 -4
  55. package/dist/engine/compute-plan.js +3 -3
  56. package/package.json +2 -2
  57. package/assets/skills/explainer-kit/schemas/author-request.schema.json +0 -85
  58. package/assets/skills/explainer-kit/schemas/author-result.schema.json +0 -65
@@ -0,0 +1,414 @@
1
+ const CALLOUT_TYPES = new Set([
2
+ 'NOTE',
3
+ 'TIP',
4
+ 'IMPORTANT',
5
+ 'WARNING',
6
+ 'CAUTION',
7
+ ]);
8
+ const SAFE_NODE_TYPES = new Set([
9
+ 'blockquote',
10
+ 'callout',
11
+ 'code',
12
+ 'delete',
13
+ 'diagram',
14
+ 'document',
15
+ 'emphasis',
16
+ 'figure',
17
+ 'heading',
18
+ 'inlineCode',
19
+ 'link',
20
+ 'list',
21
+ 'listItem',
22
+ 'paragraph',
23
+ 'strong',
24
+ 'table',
25
+ 'text',
26
+ 'timeline',
27
+ ]);
28
+ const RAW_HTML_PATTERN =
29
+ /<\/?[a-z][^>]*>|<!--[\s\S]*?-->|<\?[\s\S]*?\?>|<![A-Z][^>]*>/i;
30
+
31
+ export class MarkdownSafetyError extends Error {
32
+ constructor(message) {
33
+ super(message);
34
+ this.name = 'MarkdownSafetyError';
35
+ }
36
+ }
37
+
38
+ export function parseMarkdown(markdown) {
39
+ if (typeof markdown !== 'string') {
40
+ throw new TypeError('Markdown source must be a string.');
41
+ }
42
+ return {
43
+ type: 'document',
44
+ children: parseBlocks(markdown.replaceAll('\r\n', '\n').split('\n')),
45
+ };
46
+ }
47
+
48
+ export function parseMarkdownDocument(markdown) {
49
+ const ast = parseMarkdown(markdown);
50
+ return { ast, warnings: validateMarkdownAst(ast) };
51
+ }
52
+
53
+ export function validateMarkdownAst(ast) {
54
+ const warnings = [];
55
+ let previousHeadingDepth = 0;
56
+
57
+ visit(ast, (node) => {
58
+ if (!SAFE_NODE_TYPES.has(node.type)) {
59
+ throw new MarkdownSafetyError(
60
+ `Unsafe markdown node type: ${String(node.type)}.`,
61
+ );
62
+ }
63
+ if (node.type === 'html') {
64
+ throw new MarkdownSafetyError('Raw HTML is not allowed in markdown.');
65
+ }
66
+ if (node.type === 'link' || node.type === 'figure') {
67
+ assertSafeDestination(node.url);
68
+ }
69
+ if (node.type === 'heading') {
70
+ if (previousHeadingDepth > 0 && node.depth > previousHeadingDepth + 1) {
71
+ warnings.push({
72
+ code: 'heading-depth-jump',
73
+ message: `Heading depth jumps from ${previousHeadingDepth} to ${node.depth}.`,
74
+ });
75
+ }
76
+ previousHeadingDepth = node.depth;
77
+ }
78
+ if (node.type === 'timeline') {
79
+ for (const entry of node.entries) {
80
+ if (!entry.date || !entry.label) {
81
+ warnings.push({
82
+ code: 'timeline-entry-shape',
83
+ message: 'Timeline entries should use “date — label”.',
84
+ });
85
+ }
86
+ }
87
+ }
88
+ });
89
+
90
+ return warnings;
91
+ }
92
+
93
+ function parseBlocks(lines) {
94
+ const blocks = [];
95
+ let index = 0;
96
+
97
+ while (index < lines.length) {
98
+ if (!lines[index].trim()) {
99
+ index += 1;
100
+ continue;
101
+ }
102
+
103
+ const fence = lines[index].match(/^ {0,3}```\s*([^\s`]*)\s*$/);
104
+ if (fence) {
105
+ const language = fence[1].toLowerCase();
106
+ const source = [];
107
+ index += 1;
108
+ while (index < lines.length && !/^ {0,3}```\s*$/.test(lines[index])) {
109
+ source.push(lines[index]);
110
+ index += 1;
111
+ }
112
+ if (index < lines.length) index += 1;
113
+ blocks.push(fencedNode(language, source.join('\n')));
114
+ continue;
115
+ }
116
+
117
+ const heading = lines[index].match(/^ {0,3}(#{1,6})\s+(.+?)\s*#*\s*$/);
118
+ if (heading) {
119
+ blocks.push({
120
+ type: 'heading',
121
+ depth: heading[1].length,
122
+ children: parseInline(heading[2]),
123
+ });
124
+ index += 1;
125
+ continue;
126
+ }
127
+
128
+ const callout = lines[index].match(
129
+ /^ {0,3}>\s*\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i,
130
+ );
131
+ if (callout) {
132
+ const content = [callout[2]];
133
+ index += 1;
134
+ while (index < lines.length) {
135
+ const continuation = lines[index].match(/^ {0,3}>\s?(.*)$/);
136
+ if (!continuation) break;
137
+ content.push(continuation[1]);
138
+ index += 1;
139
+ }
140
+ const kind = callout[1].toUpperCase();
141
+ blocks.push({
142
+ type: 'callout',
143
+ kind: CALLOUT_TYPES.has(kind) ? kind.toLowerCase() : 'note',
144
+ children: parseBlocks(content),
145
+ });
146
+ continue;
147
+ }
148
+
149
+ if (/^ {0,3}>/.test(lines[index])) {
150
+ const content = [];
151
+ while (index < lines.length) {
152
+ const quote = lines[index].match(/^ {0,3}>\s?(.*)$/);
153
+ if (!quote) break;
154
+ content.push(quote[1]);
155
+ index += 1;
156
+ }
157
+ blocks.push({ type: 'blockquote', children: parseBlocks(content) });
158
+ continue;
159
+ }
160
+
161
+ if (isTableStart(lines, index)) {
162
+ const header = splitTableRow(lines[index]).map(parseInline);
163
+ index += 2;
164
+ const rows = [];
165
+ while (index < lines.length && isTableRow(lines[index])) {
166
+ rows.push(splitTableRow(lines[index]).map(parseInline));
167
+ index += 1;
168
+ }
169
+ blocks.push({ type: 'table', header, rows });
170
+ continue;
171
+ }
172
+
173
+ const listMarker = matchListItem(lines[index]);
174
+ if (listMarker) {
175
+ const ordered = listMarker.ordered;
176
+ const items = [];
177
+ while (index < lines.length) {
178
+ const item = matchListItem(lines[index]);
179
+ if (!item || item.ordered !== ordered) break;
180
+ const content = [item.content];
181
+ index += 1;
182
+ while (index < lines.length && !startsBlock(lines, index)) {
183
+ content.push(lines[index].trim());
184
+ index += 1;
185
+ }
186
+ const text = content.join(' ');
187
+ const task = text.match(/^\[([ xX])\]\s+(.*)$/);
188
+ items.push({
189
+ type: 'listItem',
190
+ checked: task ? task[1].toLowerCase() === 'x' : null,
191
+ children: [
192
+ {
193
+ type: 'paragraph',
194
+ children: parseInline(task?.[2] ?? text),
195
+ },
196
+ ],
197
+ });
198
+ }
199
+ blocks.push({
200
+ type: 'list',
201
+ ordered,
202
+ start: ordered ? listMarker.start : null,
203
+ task: items.some((item) => item.checked !== null),
204
+ children: items,
205
+ });
206
+ continue;
207
+ }
208
+
209
+ if (RAW_HTML_PATTERN.test(lines[index].trim())) {
210
+ blocks.push({ type: 'html', value: lines[index] });
211
+ index += 1;
212
+ continue;
213
+ }
214
+
215
+ const paragraph = [lines[index].trim()];
216
+ index += 1;
217
+ while (index < lines.length && !startsBlock(lines, index)) {
218
+ paragraph.push(lines[index].trim());
219
+ index += 1;
220
+ }
221
+ blocks.push({
222
+ type: 'paragraph',
223
+ children: parseInline(paragraph.join(' ')),
224
+ });
225
+ }
226
+
227
+ return blocks;
228
+ }
229
+
230
+ function fencedNode(language, value) {
231
+ if (language === 'diagram') return { type: 'diagram', source: value };
232
+ if (language === 'timeline') {
233
+ return {
234
+ type: 'timeline',
235
+ entries: value.split('\n').map((line) => {
236
+ const separator = line.indexOf(' — ');
237
+ return separator < 0
238
+ ? { date: '', label: line.trim() }
239
+ : {
240
+ date: line.slice(0, separator).trim(),
241
+ label: line.slice(separator + 3).trim(),
242
+ };
243
+ }),
244
+ };
245
+ }
246
+ return { type: 'code', language: language || null, value };
247
+ }
248
+
249
+ function parseInline(value) {
250
+ const nodes = [];
251
+ let remaining = value;
252
+
253
+ while (remaining) {
254
+ const token = nextInlineToken(remaining);
255
+ if (!token) {
256
+ nodes.push({ type: 'text', value: remaining });
257
+ break;
258
+ }
259
+ if (token.index > 0) {
260
+ nodes.push({ type: 'text', value: remaining.slice(0, token.index) });
261
+ }
262
+ nodes.push(token.node);
263
+ remaining = remaining.slice(token.index + token.length);
264
+ }
265
+
266
+ return nodes;
267
+ }
268
+
269
+ function nextInlineToken(value) {
270
+ const candidates = [
271
+ matchDelimited(value, /`([^`\n]+)`/, (match) => ({
272
+ type: 'inlineCode',
273
+ value: match[1],
274
+ })),
275
+ matchDelimited(value, /~~(.+?)~~/, (match) => ({
276
+ type: 'delete',
277
+ children: parseInline(match[1]),
278
+ })),
279
+ matchDelimited(value, /\*\*(.+?)\*\*/, (match) => ({
280
+ type: 'strong',
281
+ children: parseInline(match[1]),
282
+ })),
283
+ matchDelimited(value, /(?<!\*)\*([^*\n]+)\*/, (match) => ({
284
+ type: 'emphasis',
285
+ children: parseInline(match[1]),
286
+ })),
287
+ matchDelimited(
288
+ value,
289
+ /!\[([^\]]*)\]\((\S+?)(?:\s+["']([^"']*)["'])?\)/,
290
+ (match) => ({
291
+ type: 'figure',
292
+ alt: match[1],
293
+ url: match[2],
294
+ title: match[3] ?? null,
295
+ }),
296
+ ),
297
+ matchDelimited(
298
+ value,
299
+ /\[([^\]]+)\]\((\S+?)(?:\s+["']([^"']*)["'])?\)/,
300
+ (match) => ({
301
+ type: 'link',
302
+ url: match[2],
303
+ title: match[3] ?? null,
304
+ children: parseInline(match[1]),
305
+ }),
306
+ ),
307
+ ].filter(Boolean);
308
+
309
+ if (RAW_HTML_PATTERN.test(value)) {
310
+ const match = value.match(RAW_HTML_PATTERN);
311
+ candidates.push({
312
+ index: match.index,
313
+ length: match[0].length,
314
+ node: { type: 'html', value: match[0] },
315
+ });
316
+ }
317
+
318
+ return candidates.sort((left, right) => left.index - right.index)[0];
319
+ }
320
+
321
+ function matchDelimited(value, pattern, createNode) {
322
+ const match = value.match(pattern);
323
+ return match
324
+ ? {
325
+ index: match.index,
326
+ length: match[0].length,
327
+ node: createNode(match),
328
+ }
329
+ : null;
330
+ }
331
+
332
+ function visit(node, callback) {
333
+ if (!node || typeof node !== 'object' || Array.isArray(node)) {
334
+ throw new MarkdownSafetyError('Markdown AST contains an invalid node.');
335
+ }
336
+ callback(node);
337
+ if (Array.isArray(node.children)) {
338
+ for (const child of node.children) visit(child, callback);
339
+ }
340
+ if (node.type === 'table') {
341
+ for (const cell of [...node.header, ...node.rows.flat()]) {
342
+ for (const child of cell) visit(child, callback);
343
+ }
344
+ }
345
+ }
346
+
347
+ function assertSafeDestination(value) {
348
+ if (typeof value !== 'string' || !value) {
349
+ throw new MarkdownSafetyError('Markdown links require a destination.');
350
+ }
351
+ if (
352
+ value.startsWith('/') ||
353
+ value.startsWith('//') ||
354
+ /^(?:javascript|data|file):/i.test(value)
355
+ ) {
356
+ throw new MarkdownSafetyError(
357
+ `Unsafe markdown link destination: ${value}.`,
358
+ );
359
+ }
360
+ if (/^[a-z][a-z\d+.-]*:/i.test(value) && !/^https:/i.test(value)) {
361
+ throw new MarkdownSafetyError(
362
+ `Absolute markdown links must use HTTPS: ${value}.`,
363
+ );
364
+ }
365
+ }
366
+
367
+ function isTableStart(lines, index) {
368
+ return (
369
+ index + 1 < lines.length &&
370
+ isTableRow(lines[index]) &&
371
+ /^\s*\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$/.test(lines[index + 1])
372
+ );
373
+ }
374
+
375
+ function isTableRow(line) {
376
+ return line.includes('|') && line.trim() !== '';
377
+ }
378
+
379
+ function splitTableRow(line) {
380
+ return line
381
+ .trim()
382
+ .replace(/^\|/, '')
383
+ .replace(/\|$/, '')
384
+ .split('|')
385
+ .map((cell) => cell.trim());
386
+ }
387
+
388
+ function matchListItem(line) {
389
+ const unordered = line.match(/^ {0,3}[-+*]\s+(.+)$/);
390
+ if (unordered) {
391
+ return { ordered: false, start: null, content: unordered[1] };
392
+ }
393
+ const ordered = line.match(/^ {0,3}(\d+)[.)]\s+(.+)$/);
394
+ return ordered
395
+ ? {
396
+ ordered: true,
397
+ start: Number.parseInt(ordered[1], 10),
398
+ content: ordered[2],
399
+ }
400
+ : null;
401
+ }
402
+
403
+ function startsBlock(lines, index) {
404
+ const line = lines[index];
405
+ return (
406
+ !line.trim() ||
407
+ /^ {0,3}```/.test(line) ||
408
+ /^ {0,3}#{1,6}\s/.test(line) ||
409
+ /^ {0,3}>/.test(line) ||
410
+ Boolean(matchListItem(line)) ||
411
+ isTableStart(lines, index) ||
412
+ RAW_HTML_PATTERN.test(line.trim())
413
+ );
414
+ }