Download automation/scripts/check-glossary.js from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.42 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/automation/scripts/check-glossary.js
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/automation/scripts/check-glossary.js
-
curl -L -o check-glossary.js https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/automation/scripts/check-glossary.js
2.42 kB
| // Checks each module label mapping (src/modules/<module>/labels.ts) against tests/ui-glossary.yaml <module>: tasks/labels. | |
| // Every UI name in TASK/FIELD/BUTTON/TAB/MENU/PARAM must appear in the glossary section of that module (tasks, labels incl. param:, | |
| // known_variants). Since 9 Oct 2026 there is no local exception list (CASE_STEP_ONLY was dropped; the glossary is the single source). | |
| // A module without a glossary section is reported as 'no glossary section' (exit 1 only with --strict). Exit 1 on unmapped names. | |
| const fs = require('fs'); const path = require('path'); const YAML = require('yaml'); | |
| const root = path.resolve(__dirname, '..'); const g = YAML.parse(fs.readFileSync(path.resolve(root, '../tests/ui-glossary.yaml'), 'utf8')); | |
| const flat = (v) => (Array.isArray(v) ? v.flatMap(flat) : v && typeof v === 'object' ? Object.values(v).flatMap(flat) : typeof v === 'string' ? [v] : []); | |
| let bad = 0; | |
| const modsDir = path.join(root, 'src/modules'); | |
| for (const m of fs.readdirSync(modsDir)) { | |
| const f = path.join(modsDir, m, 'labels.ts'); if (!fs.existsSync(f)) continue; | |
| const src = fs.readFileSync(f, 'utf8'); | |
| const sec = g[m] || {}; | |
| const names = new Set([...flat(sec.tasks), ...flat(sec.labels).map((x) => x.replace(/^[a-z]+:/, '')), ...Object.keys(sec.known_variants || {}), ...flat(sec.known_variants)]); | |
| const block = (name) => { const r = new RegExp(`export const ${name}\\b[^=]*=\\s*\\{([\\s\\S]*?)\\}\\s*as const`).exec(src); return r ? [...r[1].matchAll(/:\s*'([^']+)'/g)].map((x) => x[1]) : []; }; | |
| const used = [...new Set(['TASK', 'FIELD', 'BUTTON', 'TAB', 'MENU', 'PARAM'].flatMap(block))]; | |
| const missing = used.filter((n) => !names.has(n)); | |
| const inGlossary = used.filter((n) => names.has(n)).length; | |
| if (!g[m]) { console.log(`${m}: ${used.length} UI names, NO ui-glossary.yaml ${m}: section (labels from case steps; UNVERIFIED)`); if (process.argv.includes('--strict')) bad += used.length; continue; } | |
| console.log(`${m}: ${used.length} UI names, ${inGlossary} in ui-glossary.yaml ${m}:, ${missing.length} unmapped${missing.length ? `: ${missing.join(', ')}` : ''}`); | |
| bad += missing.length; | |
| const gaps = block('GLOSSARY_GAP'); if (gaps.length) console.log(`${m}: ${gaps.length} case-step UI names reported as glossary gaps (not in ui-glossary.yaml; Test Designer to add): ${gaps.join(', ')}`); | |
| } | |
| process.exit(bad ? 1 : 0); | |