@playdrop/playdrop-cli 0.13.6 → 0.13.8

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.
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertPrimaryVerbTeachingParity = assertPrimaryVerbTeachingParity;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
6
- const types_1 = require("@playdrop/types");
7
- function extractPotentialPlayerText(source, extension) {
8
- const candidates = new Set();
9
- if (extension === '.html') {
10
- const visibleText = source
11
- .replace(/<!--[\s\S]*?-->/g, ' ')
12
- .replace(/<(?:script|style)\b[^>]*>[\s\S]*?<\/(?:script|style)>/gi, ' ')
13
- .replace(/<[^>]+>/g, ' ')
14
- .replace(/\s+/g, ' ')
15
- .trim();
16
- if (visibleText)
17
- candidates.add(visibleText.slice(0, 300));
18
- }
19
- const stringLiteral = /"((?:\\.|[^"\\]){1,300})"|'((?:\\.|[^'\\]){1,300})'|`((?:\\.|[^`\\]){1,300})`/g;
20
- for (const match of source.matchAll(stringLiteral)) {
21
- const text = (match[1] ?? match[2] ?? match[3] ?? '')
22
- .replace(/\\[nrt]/g, ' ')
23
- .replace(/\s+/g, ' ')
24
- .trim();
25
- if (text)
26
- candidates.add(text);
27
- }
28
- return Array.from(candidates);
29
- }
30
- function readPrimaryVerbTeachingText(task) {
31
- const runtimeRoot = (0, node_path_1.dirname)(task.filePath);
32
- const matches = new Set();
33
- const walk = (dir) => {
34
- for (const entry of (0, node_fs_1.readdirSync)(dir, { withFileTypes: true })) {
35
- const absolute = (0, node_path_1.join)(dir, entry.name);
36
- if (entry.isDirectory()) {
37
- if (!['node_modules', '.git', 'assets'].includes(entry.name))
38
- walk(absolute);
39
- continue;
40
- }
41
- if (!entry.isFile() || !['.html', '.js', '.mjs', '.cjs'].includes((0, node_path_1.extname)(entry.name).toLowerCase()))
42
- continue;
43
- const extension = (0, node_path_1.extname)(entry.name).toLowerCase();
44
- const source = (0, node_fs_1.readFileSync)(absolute, 'utf8');
45
- for (const text of extractPotentialPlayerText(source, extension)) {
46
- if (types_1.APP_PLAYTEST_PRIMARY_VERB_VALUES.some((verb) => (0, types_1.appPlaytestTeachingTextMatchesVerb)(text, verb))) {
47
- matches.add(text);
48
- }
49
- }
50
- }
51
- };
52
- walk(runtimeRoot);
53
- return Array.from(matches);
54
- }
55
- function assertPrimaryVerbTeachingParity(task) {
56
- const primarySurface = task.primarySurface;
57
- const tape = primarySurface ? task.playtestTapes?.[primarySurface] : null;
58
- if (!primarySurface || !tape) {
59
- throw new Error('agent_task_primary_verb_tape_required');
60
- }
61
- const teachingTexts = readPrimaryVerbTeachingText(task);
62
- const matchingText = teachingTexts.find((text) => (0, types_1.appPlaytestTeachingTextMatchesVerb)(text, tape.primaryVerb));
63
- if (!matchingText) {
64
- throw new Error(`agent_task_primary_verb_not_taught:${tape.primaryVerb}: show the player a concise instruction using the declared primary verb.`);
65
- }
66
- const competingVerbs = types_1.APP_PLAYTEST_PRIMARY_VERB_VALUES
67
- .filter((verb) => verb !== tape.primaryVerb)
68
- .filter((verb) => teachingTexts.some((text) => {
69
- if (!(0, types_1.appPlaytestTeachingTextMatchesVerb)(text, verb))
70
- return false;
71
- return verb !== 'tap' || !/\btap\b[^\n]{0,30}\b(?:start|play|begin|continue|retry)\b/i.test(text);
72
- }));
73
- if (competingVerbs.length > 0) {
74
- throw new Error(`agent_task_primary_verb_teaching_mismatch:${tape.primaryVerb}:${competingVerbs.join(',')}`);
75
- }
76
- return matchingText;
77
- }