(page)
| 629 | const cardButton = (page, name) => page.locator('.cbm-chat-explanation').getByRole('button', { name, exact: true }); |
| 630 | |
| 631 | async function k12(page) { |
| 632 | const outputs = []; |
| 633 | await openWorkflowFile(page); |
| 634 | await loadModel(page); |
| 635 | await openChat(page); |
| 636 | let mark = await markWorker(page); |
| 637 | await explanationDone(page); |
| 638 | // The automatic card of a configuration file: the facts read from it, and no model text (K12). |
| 639 | const [automatic] = (await sentSince(page, mark)).filter((entry) => entry.profile === 'automatic-explanation'); |
| 640 | const card = await explanationText(page); |
| 641 | const askButton = await cardButton(page, 'Ask the model').count(); |
| 642 | outputs.push({ kind: 'automatic', card, modelCalled: Boolean(automatic) }); |
| 643 | await shot(page, 'K12', 'automatic', 'Explore with the workflow open: the automatic card lists name, trigger, the one job and the action read from the file, says it is not generated by the model, and offers "Ask the model".'); |
| 644 | // Only on request: "Ask the model" lets the model write about the file, marked as generated. |
| 645 | mark = await markWorker(page); |
| 646 | let from = await now(page); |
| 647 | await cardButton(page, 'Ask the model').click(); |
| 648 | await wait(800); |
| 649 | await explanationDone(page); |
| 650 | const [asked] = (await sentSince(page, mark)).filter((entry) => entry.profile === 'automatic-explanation'); |
| 651 | const askedCard = await explanationText(page); |
| 652 | outputs.push({ kind: 'ask-the-model', card: askedCard, model: (await answersSince(page, from))[0]?.output, prompt: promptText(asked) }); |
| 653 | await shot(page, 'K12', 'ask-the-model', 'After "Ask the model": the facts stay above, the model text follows and is marked as generated (or left out when it names what the file does not show).'); |
| 654 | // Other configuration and text files of the project: facts only, no model. |
| 655 | const others = []; |
| 656 | for (const path of ['package.json', 'tox.ini', 'pyproject.toml', 'README.rst', '.editorconfig']) { |
| 657 | mark = await markWorker(page); |
| 658 | if (!(await openTreeFile(page, path))) continue; |
| 659 | await explanationDone(page); |
| 660 | const calls = (await sentSince(page, mark)).filter((entry) => entry.profile === 'automatic-explanation').length; |
| 661 | const text = await explanationText(page); |
| 662 | others.push({ path, card: text.replace(/\s+/g, ' ').slice(0, 300), factsOnly: /Read from the file; not generated by the model\./.test(text), modelCalls: calls }); |
| 663 | if (others.length <= 3) await shot(page, 'K12', `facts-${path.replace(/[^\w]+/g, '-')}`, `${path}: the automatic card shows only what is read from the file; no model call.`); |
| 664 | } |
| 665 | // A YAML list of mappings is a list: django's pre-commit file holds `repos`, a list of 5 items with repo, rev and hooks, |
| 666 | // not "10 keys: rev, hooks, rev, ..." (review of the K12 facts). The Read the Docs file is a mapping with a list below `python.install`. |
| 667 | const yaml = []; |
| 668 | for (const [path, wanted] of [['.pre-commit-config.yaml', /Top-level keys \(1\): repos \(list of 5; item keys: repo, rev, hooks\)\./], |
| 669 | ['.readthedocs.yml', /Top-level keys \(5\): version, build \(2 keys: os, tools\), sphinx \(2 keys: configuration, fail_on_warning\), python \(1 key: install\), formats\./]]) { |
| 670 | mark = await markWorker(page); |
| 671 | const opened = await openTreeFile(page, path); |
| 672 | await explanationDone(page); |
| 673 | const text = await explanationText(page); |
| 674 | const calls = (await sentSince(page, mark)).filter((entry) => entry.profile === 'automatic-explanation').length; |
| 675 | await page.locator('.cbm-chat-explanation').screenshot({ path: join(OUT, 'K12', `yaml-${path.replace(/[^\w]+/g, '-')}-card.png`) }).catch(() => {}); |
| 676 | const file = await shot(page, 'K12', `yaml-${path.replace(/[^\w]+/g, '-')}`, `${path}: the automatic card counts what the YAML holds (a list as a list, its items' keys as item keys); crop: yaml-${path.replace(/[^\w]+/g, '-')}-card.png.`); |
| 677 | yaml.push({ path, opened, file, card: text.replace(/\s+/g, ' ').slice(0, 400), wanted: wanted.test(text.replace(/\s+/g, ' ')), |
| 678 | repeatedKeys: /keys: (\w+), (\w+), \1, \2/.test(text), factsOnly: /Read from the file; not generated by the model\./.test(text), modelCalls: calls }); |
| 679 | } |
| 680 | check('K12', 'YAML facts count a list of mappings as a list with item keys (.pre-commit-config.yaml: repos, list of 5) and a mapping by its keys (.readthedocs.yml)', |
| 681 | yaml.length === 2 && yaml.every((item) => item.opened && item.wanted && !item.repeatedKeys && item.factsOnly && item.modelCalls === 0), { yaml }); |
| 682 | // Explicit questions about the workflow go to the model, as before (back by its tree row: no reload, the model stays loaded). |
| 683 | // Since C7 "what does this file do" questions are answered from the file instead: no request, the counted facts, the read-from-file note. |
| 684 | await openTreeFile(page, '.github/workflows/new_contributor_pr.yml'); |
| 685 | await explanationDone(page); |
| 686 | const questions = ['was kannst du mir über dieses aktuelle File sagen', 'Wie viele Jobs gibt es in dieser Datei?', 'Welche Jobs gibt es in dieser Datei?', 'What does this file do?', 'How many jobs does this workflow have?']; |
| 687 | const runs = Math.max(RUNS, questions.length); |
| 688 | for (let run = 0; run < runs; run++) { |
nothing calls this directly
no test coverage detected