vibedgames 0.6.2 → 0.7.0

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 (140) hide show
  1. package/README.md +14 -9
  2. package/dist/THIRD_PARTY_NOTICES.txt +383 -0
  3. package/dist/chunk-2GL2WJZX.js +172 -0
  4. package/dist/chunk-2QBYTIMH.js +511 -0
  5. package/dist/chunk-34AHIMX7.js +466 -0
  6. package/dist/chunk-6FZPPUQH.js +107 -0
  7. package/dist/chunk-BVVYDSFJ.js +99 -0
  8. package/dist/chunk-CAKBGDCY.js +47 -0
  9. package/dist/chunk-CBKOPVU6.js +1780 -0
  10. package/dist/chunk-CU7UY5YJ.js +1108 -0
  11. package/dist/chunk-CZPKN32Z.js +257 -0
  12. package/dist/chunk-DHEXGWJY.js +111 -0
  13. package/dist/chunk-FL6IFBUF.js +22 -0
  14. package/dist/chunk-FLUXEHMU.js +1360 -0
  15. package/dist/chunk-FNYBZNW2.js +165 -0
  16. package/dist/chunk-G5FRIFA3.js +22 -0
  17. package/dist/chunk-HCMTSR7E.js +69 -0
  18. package/dist/chunk-HKA5LBYW.js +159 -0
  19. package/dist/chunk-I6O4HIDY.js +1063 -0
  20. package/dist/chunk-J6PKNPI2.js +26 -0
  21. package/dist/chunk-JT2AU24K.js +759 -0
  22. package/dist/chunk-MBXCVCC4.js +478 -0
  23. package/dist/chunk-MJQSHP3Y.js +415 -0
  24. package/dist/chunk-MYFLYNPO.js +68 -0
  25. package/dist/chunk-PEUP4MZR.js +59 -0
  26. package/dist/chunk-PHEDW6C7.js +32 -0
  27. package/dist/chunk-PQDBCZRT.js +2017 -0
  28. package/dist/chunk-QGEITHUP.js +395 -0
  29. package/dist/chunk-QIVCBUYD.js +273 -0
  30. package/dist/chunk-RYFO3ZPO.js +71 -0
  31. package/dist/chunk-RZ4DIJQW.js +68 -0
  32. package/dist/chunk-SAANBZ25.js +118 -0
  33. package/dist/chunk-VFFOT7KD.js +2980 -0
  34. package/dist/chunk-Y552BNFZ.js +41 -0
  35. package/dist/chunk-Z4Z24FWO.js +39 -0
  36. package/dist/chunk-ZI6PKVXG.js +64 -0
  37. package/dist/chunk-ZYCSYJWX.js +87 -0
  38. package/dist/index.js +67 -60
  39. package/package.json +13 -16
  40. package/templates/none/_gitignore +3 -0
  41. package/templates/none/index.html +29 -0
  42. package/templates/none/package.json +16 -0
  43. package/templates/none/src/main.ts +16 -0
  44. package/templates/none/tsconfig.json +18 -0
  45. package/templates/none/vite.config.ts +8 -0
  46. package/templates/phaser/_gitignore +3 -0
  47. package/templates/phaser/index.html +24 -0
  48. package/templates/phaser/package.json +19 -0
  49. package/templates/phaser/src/main.ts +16 -0
  50. package/templates/phaser/src/scenes/game-scene.ts +65 -0
  51. package/templates/phaser/tsconfig.json +18 -0
  52. package/templates/phaser/vite.config.ts +8 -0
  53. package/templates/react-r3f/_gitignore +3 -0
  54. package/templates/react-r3f/index.html +24 -0
  55. package/templates/react-r3f/package.json +27 -0
  56. package/templates/react-r3f/src/app.tsx +33 -0
  57. package/templates/react-r3f/src/main.tsx +15 -0
  58. package/templates/react-r3f/tsconfig.json +19 -0
  59. package/templates/react-r3f/vite.config.ts +10 -0
  60. package/templates/threejs/_gitignore +3 -0
  61. package/templates/threejs/index.html +36 -0
  62. package/templates/threejs/package.json +20 -0
  63. package/templates/threejs/src/main.ts +44 -0
  64. package/templates/threejs/tsconfig.json +18 -0
  65. package/templates/threejs/vite.config.ts +8 -0
  66. package/dist/commands/completions.d.ts +0 -7
  67. package/dist/commands/completions.js +0 -145
  68. package/dist/commands/credits.d.ts +0 -10
  69. package/dist/commands/credits.js +0 -136
  70. package/dist/commands/deploy.d.ts +0 -26
  71. package/dist/commands/deploy.js +0 -257
  72. package/dist/commands/factory.d.ts +0 -3
  73. package/dist/commands/factory.js +0 -73
  74. package/dist/commands/fork.d.ts +0 -29
  75. package/dist/commands/fork.js +0 -124
  76. package/dist/commands/generate.d.ts +0 -1
  77. package/dist/commands/generate.js +0 -565
  78. package/dist/commands/init.d.ts +0 -20
  79. package/dist/commands/init.js +0 -105
  80. package/dist/commands/login.d.ts +0 -1
  81. package/dist/commands/login.js +0 -45
  82. package/dist/commands/logout.d.ts +0 -1
  83. package/dist/commands/logout.js +0 -13
  84. package/dist/commands/new.d.ts +0 -26
  85. package/dist/commands/new.js +0 -318
  86. package/dist/commands/playtest-run.d.ts +0 -66
  87. package/dist/commands/playtest-run.js +0 -268
  88. package/dist/commands/playtest.d.ts +0 -76
  89. package/dist/commands/playtest.js +0 -372
  90. package/dist/commands/update.d.ts +0 -13
  91. package/dist/commands/update.js +0 -82
  92. package/dist/commands/whoami.d.ts +0 -10
  93. package/dist/commands/whoami.js +0 -44
  94. package/dist/index.d.ts +0 -2
  95. package/dist/lib/api.d.ts +0 -18
  96. package/dist/lib/api.js +0 -27
  97. package/dist/lib/archive.d.ts +0 -17
  98. package/dist/lib/archive.js +0 -228
  99. package/dist/lib/codex.d.ts +0 -117
  100. package/dist/lib/codex.js +0 -426
  101. package/dist/lib/config-file.d.ts +0 -16
  102. package/dist/lib/config-file.js +0 -54
  103. package/dist/lib/config.d.ts +0 -11
  104. package/dist/lib/config.js +0 -54
  105. package/dist/lib/manifest.d.ts +0 -10
  106. package/dist/lib/manifest.js +0 -91
  107. package/dist/lib/media-args.d.ts +0 -30
  108. package/dist/lib/media-args.js +0 -219
  109. package/dist/lib/media-download.d.ts +0 -37
  110. package/dist/lib/media-download.js +0 -268
  111. package/dist/lib/media-poll.d.ts +0 -18
  112. package/dist/lib/media-poll.js +0 -86
  113. package/dist/lib/media-upload.d.ts +0 -12
  114. package/dist/lib/media-upload.js +0 -52
  115. package/dist/lib/output.d.ts +0 -68
  116. package/dist/lib/output.js +0 -102
  117. package/dist/lib/package-manager.d.ts +0 -25
  118. package/dist/lib/package-manager.js +0 -77
  119. package/dist/lib/playtest/agent.d.ts +0 -192
  120. package/dist/lib/playtest/agent.js +0 -652
  121. package/dist/lib/playtest/browser.d.ts +0 -109
  122. package/dist/lib/playtest/browser.js +0 -219
  123. package/dist/lib/playtest/controls.d.ts +0 -47
  124. package/dist/lib/playtest/controls.js +0 -218
  125. package/dist/lib/playtest/errors.d.ts +0 -9
  126. package/dist/lib/playtest/errors.js +0 -12
  127. package/dist/lib/playtest/keys.d.ts +0 -41
  128. package/dist/lib/playtest/keys.js +0 -157
  129. package/dist/lib/playtest/run.d.ts +0 -195
  130. package/dist/lib/playtest/run.js +0 -409
  131. package/dist/lib/run.d.ts +0 -19
  132. package/dist/lib/run.js +0 -23
  133. package/dist/lib/strict-args.d.ts +0 -27
  134. package/dist/lib/strict-args.js +0 -78
  135. package/dist/lib/types.d.ts +0 -16
  136. package/dist/lib/types.js +0 -10
  137. package/dist/lib/update.d.ts +0 -10
  138. package/dist/lib/update.js +0 -110
  139. package/dist/lib/upload.d.ts +0 -16
  140. package/dist/lib/upload.js +0 -41
@@ -1,409 +0,0 @@
1
- /**
2
- * Orchestrates one model playtest: build the in-page agent's config from the
3
- * control scheme, inject it, wait for it to finish, and turn its records into
4
- * the report. The loop itself — decide, apply, measure, repeat, plus the
5
- * per-frame reflex — runs inside the page (agent.ts); nothing here touches
6
- * the game per tick.
7
- */
8
- import { setTimeout as delay } from "node:timers/promises";
9
- import { isJsonObject, isJsonString } from "../types.js";
10
- import { browserEnv, inPageAgent } from "./agent.js";
11
- import { HarnessError } from "./errors.js";
12
- import { keyInitsFor, keyTable } from "./keys.js";
13
- export const THRESHOLDS = {
14
- /** Mean `move` confidence below which the state is probably too thin to decide from. */
15
- confidence: 0.3,
16
- displacement: 5,
17
- /**
18
- * Frames a run must advance to count as alive — the bot's gate — capped by
19
- * `minFps` × the run's wall time, because a model run can legitimately be
20
- * a couple of seconds long where the scripted sweep is twelve.
21
- */
22
- framesAdvanced: 100,
23
- /** Decisions a rested no-input option stays out of the question. */
24
- idleRestTicks: 8,
25
- /** Idle decisions in a row (holding nothing, going nowhere) before the no-input option is rested. */
26
- idleRun: 3,
27
- minFps: 10,
28
- /**
29
- * A window counts as "didn't move" below this fraction of the displacement
30
- * gate, so both scale together when a game measures in world units.
31
- */
32
- motionEpsilonRatio: 0.04,
33
- /** Stuck ticks in a row after which the agent withdraws the move. */
34
- stuckRun: 2,
35
- /**
36
- * Stuck ticks in a row that fail the run. The decision after a withdrawal
37
- * was already in flight when it landed, so `stuckRun + 1` is what hitting
38
- * one wall costs; past that the alternatives went nowhere too.
39
- */
40
- wedgedRun: 5,
41
- };
42
- /** The input-alive gate for this scheme, in the game's own `player` units. */
43
- export const displacementGate = (controls) => controls.minDisplacement ?? THRESHOLDS.displacement;
44
- const motionEpsilon = (controls) => displacementGate(controls) * THRESHOLDS.motionEpsilonRatio;
45
- /** A yes/no answer at or above this probability is acted on. */
46
- export const ACTION_THRESHOLD = 0.5;
47
- /** Positions kept in the state's `trail`, newest last. */
48
- const TRAIL_LENGTH = 6;
49
- /** How long the last decision is held before its window is read. */
50
- const FINAL_HOLD_MS = 250;
51
- const DECISION_RETRIES = 2;
52
- const DECISION_TIMEOUT_MS = 10_000;
53
- /** How often the CLI asks the page whether the agent is done. */
54
- const POLL_MS = 250;
55
- const round = (value) => Number(value.toFixed(2));
56
- /** The agent's config for this scheme: every key pre-resolved to a proper event init. */
57
- export const agentConfig = (opts, session) => {
58
- const move = {};
59
- for (const [label, option] of Object.entries(opts.controls.move)) {
60
- move[label] = {
61
- description: option.description,
62
- inits: keyInitsFor(option.keys),
63
- pointer: option.pointer
64
- ? { down: option.pointer.down === true, x: option.pointer.x, y: option.pointer.y }
65
- : null,
66
- };
67
- }
68
- const actions = {};
69
- for (const [label, action] of Object.entries(opts.controls.actions)) {
70
- actions[label] = { description: action.description, inits: keyInitsFor(action.keys) };
71
- }
72
- return {
73
- actionThreshold: ACTION_THRESHOLD,
74
- actions,
75
- decideUrl: session.decideUrl,
76
- decisionRetries: DECISION_RETRIES,
77
- decisionTimeoutMs: DECISION_TIMEOUT_MS,
78
- finalHoldMs: FINAL_HOLD_MS,
79
- goal: opts.controls.goal,
80
- idleRestTicks: THRESHOLDS.idleRestTicks,
81
- idleRun: THRESHOLDS.idleRun,
82
- keyTable: keyTable(),
83
- model: opts.model,
84
- motionEpsilon: motionEpsilon(opts.controls),
85
- move,
86
- pinMove: opts.pinMove,
87
- stuckRun: THRESHOLDS.stuckRun,
88
- tickMs: opts.tickMs,
89
- ticks: opts.ticks,
90
- token: session.token,
91
- trailLength: TRAIL_LENGTH,
92
- };
93
- };
94
- /**
95
- * The agent as page source: its own function text applied to the config and
96
- * to the real-browser env. Both functions are self-contained by contract, so
97
- * their `toString()` is all the page needs.
98
- */
99
- export const agentSource = (config) => `(${inPageAgent.toString()})(${JSON.stringify(config)}, (${browserEnv.toString()})())`;
100
- /** Upper bound on a run, after which the agent is stopped and the run is a harness failure. */
101
- const budgetMs = (opts) => opts.ticks * (Math.max(opts.tickMs, 150) + DECISION_TIMEOUT_MS + 3500) + FINAL_HOLD_MS + 15_000;
102
- /** Fold one measured window into the running metrics. */
103
- const measure = (metrics, window, askedToMove, index, epsilon) => {
104
- metrics.distance += window.path;
105
- metrics.maxTickDisplacement = Math.max(metrics.maxTickDisplacement, window.peak);
106
- const progressed = window.score > window.scoreBefore;
107
- if (progressed && metrics.tickOfFirstScore === null) {
108
- metrics.tickOfFirstScore = index;
109
- }
110
- // Stuck signature: frames advanced, the model asked the player to move, and
111
- // nothing came of it. Counted as a RUN: one dead tick is a wall, several in
112
- // a row is a player wedged in geometry — or a model that keeps choosing the
113
- // wall, which the agent's reflex exists to break.
114
- let stuck = false;
115
- if (askedToMove) {
116
- stuck = window.frame > window.frameBefore && window.peak < epsilon && !progressed;
117
- if (stuck) {
118
- metrics.stuckTicks += 1;
119
- metrics.stuckRun += 1;
120
- metrics.longestStuckRun = Math.max(metrics.longestStuckRun, metrics.stuckRun);
121
- }
122
- else {
123
- metrics.stuckRun = 0;
124
- }
125
- }
126
- return { progressed, stuck };
127
- };
128
- const timelineEntry = (record, progressed, stuck) => ({
129
- actionProbabilities: record.actionProbabilities,
130
- actions: record.actions,
131
- confidence: record.confidence,
132
- decisionMs: record.decisionMs,
133
- frames: record.window.frame - record.window.frameBefore,
134
- move: record.move,
135
- path: record.window.path,
136
- peak: record.window.peak,
137
- progress: record.progress,
138
- progressed,
139
- reflexFrames: record.reflexFrames,
140
- scoreDelta: record.window.score - record.window.scoreBefore,
141
- stuck,
142
- tick: record.tick,
143
- });
144
- const num = (value) => (Number.isFinite(value) ? Number(value) : 0);
145
- const readWindow = (value) => {
146
- if (!isJsonObject(value)) {
147
- return null;
148
- }
149
- return {
150
- complete: value.complete === true,
151
- frame: num(value.frame),
152
- frameBefore: num(value.frameBefore),
153
- path: num(value.path),
154
- peak: num(value.peak),
155
- score: num(value.score),
156
- scoreBefore: num(value.scoreBefore),
157
- x: num(value.x),
158
- y: num(value.y),
159
- z: num(value.z),
160
- };
161
- };
162
- const readRecord = (value) => {
163
- const window = isJsonObject(value) ? readWindow(value.window) : null;
164
- if (!isJsonObject(value) || !window || !isJsonString(value.move)) {
165
- throw new HarnessError(`the agent published a malformed record: ${JSON.stringify(value).slice(0, 200)}`);
166
- }
167
- const probabilities = {};
168
- if (isJsonObject(value.actionProbabilities)) {
169
- for (const [label, probability] of Object.entries(value.actionProbabilities)) {
170
- probabilities[label] = num(probability);
171
- }
172
- }
173
- return {
174
- actionProbabilities: probabilities,
175
- actions: Array.isArray(value.actions) ? value.actions.filter(isJsonString) : [],
176
- askedToMove: value.askedToMove === true,
177
- confidence: Number.isFinite(value.confidence) ? Number(value.confidence) : null,
178
- decisionMs: num(value.decisionMs),
179
- inputTokens: num(value.inputTokens),
180
- move: value.move,
181
- outputTokens: num(value.outputTokens),
182
- progress: Number.isFinite(value.progress) ? Number(value.progress) : null,
183
- reflexFrames: num(value.reflexFrames),
184
- tick: num(value.tick),
185
- window,
186
- };
187
- };
188
- /** The agent's records, folded into metrics and a timeline. */
189
- export const resultFromAgent = (published, epsilon = THRESHOLDS.displacement * THRESHOLDS.motionEpsilonRatio) => {
190
- if (!isJsonObject(published)) {
191
- throw new HarnessError("the page lost the agent before its result could be read.");
192
- }
193
- if (isJsonString(published.error)) {
194
- throw new HarnessError(published.error);
195
- }
196
- const records = Array.isArray(published.records) ? published.records.map(readRecord) : [];
197
- const metrics = {
198
- distance: 0,
199
- longestStuckRun: 0,
200
- maxTickDisplacement: 0,
201
- stuckRun: 0,
202
- stuckTicks: 0,
203
- tickOfFirstScore: null,
204
- };
205
- const timeline = [];
206
- const usage = { calls: 0, inputTokens: 0, maxDecisionMs: 0, outputTokens: 0, totalDecisionMs: 0 };
207
- let lastWindow = null;
208
- for (const record of records) {
209
- const { progressed, stuck } = measure(metrics, record.window, record.askedToMove, record.tick, epsilon);
210
- timeline.push(timelineEntry(record, progressed, stuck));
211
- usage.calls += 1;
212
- usage.inputTokens += record.inputTokens;
213
- usage.outputTokens += record.outputTokens;
214
- usage.totalDecisionMs += record.decisionMs;
215
- usage.maxDecisionMs = Math.max(usage.maxDecisionMs, record.decisionMs);
216
- lastWindow = record.window;
217
- }
218
- return {
219
- completedAtTick: Number.isFinite(published.completedAtTick)
220
- ? Number(published.completedAtTick)
221
- : null,
222
- lastWindow,
223
- metrics,
224
- timeline,
225
- usage,
226
- wallMs: num(published.wallMs),
227
- };
228
- };
229
- /** Inject the agent, wait for it to finish, and read its result. */
230
- export const runInPage = async (browser, opts, session) => {
231
- browser.inject(agentSource(agentConfig(opts, session)));
232
- const deadline = Date.now() + budgetMs(opts);
233
- for (;;) {
234
- const status = browser.agentStatus();
235
- if (!status) {
236
- throw new HarnessError("the page lost the agent; it probably navigated mid-run.");
237
- }
238
- if (status.done) {
239
- break;
240
- }
241
- if (Date.now() > deadline) {
242
- browser.stopAgent();
243
- throw new HarnessError(`the run did not finish within ${Math.round(budgetMs(opts) / 1000)} s.`);
244
- }
245
- await delay(POLL_MS);
246
- }
247
- return resultFromAgent(browser.agentResult(), motionEpsilon(opts.controls));
248
- };
249
- /**
250
- * The model's own progress judgments folded into one trajectory — its read at
251
- * the first and last decision, 0–1, plus the mean and the high-water mark —
252
- * or null when it gave none. Inferred rather than named so the report stays
253
- * a plain JSON shape for `--json` / `--field`.
254
- */
255
- const summarizeProgress = (timeline) => {
256
- const scored = timeline.map((entry) => entry.progress).filter((p) => p !== null);
257
- const [first] = scored;
258
- const last = scored.at(-1);
259
- if (first === undefined || last === undefined) {
260
- return null;
261
- }
262
- let sum = 0;
263
- let max = 0;
264
- for (const value of scored) {
265
- sum += value;
266
- max = Math.max(max, value);
267
- }
268
- return {
269
- first: round(first),
270
- last: round(last),
271
- max: round(max),
272
- mean: round(sum / scored.length),
273
- };
274
- };
275
- /** Per-run histograms of what the model chose, how sure it was about moving, and how it judged the run. */
276
- const summarizeDecisions = (timeline) => {
277
- const moves = {};
278
- const actions = {};
279
- let confidenceSum = 0;
280
- let confidenceCount = 0;
281
- let reflexFrames = 0;
282
- for (const entry of timeline) {
283
- moves[entry.move] = (moves[entry.move] ?? 0) + 1;
284
- for (const label of entry.actions) {
285
- actions[label] = (actions[label] ?? 0) + 1;
286
- }
287
- if (entry.confidence !== null) {
288
- confidenceSum += entry.confidence;
289
- confidenceCount += 1;
290
- }
291
- reflexFrames += entry.reflexFrames;
292
- }
293
- return {
294
- actions,
295
- meanConfidence: confidenceCount > 0 ? round(confidenceSum / confidenceCount) : null,
296
- moves,
297
- progress: summarizeProgress(timeline),
298
- reflexFrames,
299
- };
300
- };
301
- export const buildReport = (opts, input) => {
302
- const { before, run } = input;
303
- const last = run.lastWindow;
304
- const seconds = run.wallMs / 1000;
305
- return {
306
- complete: last ? last.complete : before.complete,
307
- completedAtTick: run.completedAtTick,
308
- consoleErrors: input.consoleErrors,
309
- decisions: summarizeDecisions(run.timeline),
310
- decisionsPerSecond: seconds > 0 ? round(run.timeline.length / seconds) : null,
311
- distanceTravelled: round(run.metrics.distance),
312
- framesAdvanced: (last ? last.frame : before.frame) - before.frame,
313
- goal: opts.controls.goal,
314
- // Which GPU rasterized the run. Under software rendering the functional
315
- // checks still hold; any frame-rate read from the run does not.
316
- gpu: input.gpu,
317
- longestStuckRun: run.metrics.longestStuckRun,
318
- maxTickDisplacement: round(run.metrics.maxTickDisplacement),
319
- // The gate `maxTickDisplacement` was held to, so the number reads in context.
320
- minDisplacement: displacementGate(opts.controls),
321
- model: {
322
- calls: run.usage.calls,
323
- id: opts.model,
324
- inputTokens: run.usage.inputTokens,
325
- maxDecisionMs: run.usage.maxDecisionMs,
326
- meanDecisionMs: run.usage.calls > 0 ? Math.round(run.usage.totalDecisionMs / run.usage.calls) : null,
327
- outputTokens: run.usage.outputTokens,
328
- },
329
- pageErrors: input.pageErrors,
330
- scoreAfter: last ? last.score : before.score,
331
- scoreBefore: before.score,
332
- seed: input.seed,
333
- // How the seed actually landed, so a reader can tell a real seeded run
334
- // from one where the hook quietly did nothing.
335
- seedApplied: input.seedApplied,
336
- stuckTicks: run.metrics.stuckTicks,
337
- target: input.target,
338
- tickMs: opts.tickMs,
339
- tickOfFirstScore: run.metrics.tickOfFirstScore,
340
- ticks: opts.ticks,
341
- ticksRun: run.timeline.length,
342
- timeline: run.timeline,
343
- wallMs: run.wallMs,
344
- };
345
- };
346
- /** Failures fail the run; warnings are findings a reader should weigh. */
347
- export const verdict = (report, opts) => {
348
- const failures = [];
349
- const warnings = [];
350
- const framesRequired = Math.min(THRESHOLDS.framesAdvanced, Math.round((report.wallMs / 1000) * THRESHOLDS.minFps));
351
- if (report.framesAdvanced <= framesRequired) {
352
- failures.push(`game loop stalled (framesAdvanced ${report.framesAdvanced} over ${report.wallMs} ms)`);
353
- }
354
- // Gated on the largest displacement any ONE tick achieved, not on the
355
- // summed path: path accumulates every sampled wobble, and an idle bob
356
- // would drift past a total-distance threshold.
357
- const gate = displacementGate(opts.controls);
358
- const holdsInput = (label) => {
359
- const option = opts.controls.move[label];
360
- return (option !== undefined && (option.keys.length > 0 || option.pointer !== null || option.reflex));
361
- };
362
- const triedToMove = report.timeline.some((entry) => holdsInput(entry.move));
363
- if (!triedToMove && report.timeline.length > 0) {
364
- // Not dead input: input was never tried. Blaming the controls here sends
365
- // the author to the wrong file.
366
- failures.push("the model never chose a movement — every decision held nothing. The diagnostics gave it no reason to go anywhere: expose where the goal, threats and pickups are (dx/dy from the player) in __GAME_DIAGNOSTICS__, and say which way progress is in the goal");
367
- }
368
- else if (report.maxTickDisplacement <= gate) {
369
- failures.push(`player did not respond to input (maxTickDisplacement ${report.maxTickDisplacement}, needs > ${gate}) — if this game steers with the mouse, give it pointer moves in __GAME_PLAYTEST__ or --controls; if \`player\` is in world units rather than pixels, set \`minDisplacement\` in __GAME_PLAYTEST__ or pass --min-displacement`);
370
- }
371
- if (report.longestStuckRun >= THRESHOLDS.wedgedRun) {
372
- failures.push(`player wedged for ${report.longestStuckRun} consecutive movement ticks (longestStuckRun) — the model kept choosing moves that went nowhere`);
373
- }
374
- if (report.scoreAfter <= report.scoreBefore) {
375
- const { progress } = report.decisions;
376
- // The model's read of the goal is the tie-breaker the score field lacks:
377
- // a goal like "survive the wave" never raises `score`, but a model that
378
- // judged the player closer to it at the end than at the start did play.
379
- let judged = "";
380
- if (progress !== null) {
381
- const trend = `progress ${progress.first} → ${progress.last}`;
382
- judged =
383
- progress.last > progress.first
384
- ? ` (though the model judged the player closer to the goal by the end: ${trend})`
385
- : ` (and the model agreed: ${trend})`;
386
- }
387
- const message = `the run never progressed the objective${judged}`;
388
- if (opts.expectProgress) {
389
- failures.push(message);
390
- }
391
- else {
392
- warnings.push(`${message} — pass --expect-progress once the controls express this game's scoring verb, to make that an assertion`);
393
- }
394
- }
395
- if (report.completedAtTick !== null) {
396
- warnings.push(`the run ended at tick ${report.completedAtTick} of ${opts.ticks} (complete became true) — a win, or a fail state the playtester couldn't avoid; read the timeline to tell which`);
397
- }
398
- const { meanConfidence } = report.decisions;
399
- if (meanConfidence !== null && meanConfidence < THRESHOLDS.confidence) {
400
- warnings.push(`the model was rarely sure which way to move (mean confidence ${meanConfidence}) — the diagnostics probably don't expose what a player sees; add hazards, goals and nearby entities with positions to __GAME_DIAGNOSTICS__`);
401
- }
402
- if (report.consoleErrors.length > 0) {
403
- failures.push(`${report.consoleErrors.length} console error(s)`);
404
- }
405
- if (report.pageErrors.length > 0) {
406
- failures.push(`${report.pageErrors.length} uncaught page error(s)`);
407
- }
408
- return { failures, warnings };
409
- };
package/dist/lib/run.d.ts DELETED
@@ -1,19 +0,0 @@
1
- export interface RunResult {
2
- code: number;
3
- output: string;
4
- }
5
- export interface RunOptions {
6
- /**
7
- * Mirror the child's output to this process as it arrives. Long steps
8
- * (`npx skills add` clones a repo per skill) otherwise look hung: the
9
- * buffered output is only readable once the child has already exited.
10
- */
11
- stream?: boolean;
12
- }
13
- /**
14
- * True when the command never started, as opposed to running and failing.
15
- * `run` turns a spawn error into an exit code, so the message is the only
16
- * thing that separates "no such binary" from "the binary said no".
17
- */
18
- export declare const isMissingCommand: (result: RunResult) => boolean;
19
- export declare const run: (cmd: string, args: string[], options?: RunOptions) => Promise<RunResult>;
package/dist/lib/run.js DELETED
@@ -1,23 +0,0 @@
1
- import spawn from "cross-spawn";
2
- /**
3
- * True when the command never started, as opposed to running and failing.
4
- * `run` turns a spawn error into an exit code, so the message is the only
5
- * thing that separates "no such binary" from "the binary said no".
6
- */
7
- export const isMissingCommand = (result) => result.code !== 0 && /ENOENT|not found|not recognized/iu.test(result.output);
8
- export const run = (cmd, args, options = {}) =>
9
- // oxlint-disable-next-line promise/avoid-new -- child_process.spawn is event-based
10
- new Promise((resolve) => {
11
- const chunks = [];
12
- const child = spawn(cmd, args, { stdio: ["ignore", "pipe", "pipe"] });
13
- const collect = (stream) => (c) => {
14
- chunks.push(c);
15
- if (options.stream) {
16
- stream.write(c);
17
- }
18
- };
19
- child.stdout?.on("data", collect(process.stderr));
20
- child.stderr?.on("data", collect(process.stderr));
21
- child.on("error", (err) => resolve({ code: 1, output: `${err.message}\n` }));
22
- child.on("close", (code) => resolve({ code: code ?? 1, output: Buffer.concat(chunks).toString("utf-8") }));
23
- });
@@ -1,27 +0,0 @@
1
- /**
2
- * Reject flags a command does not declare.
3
- *
4
- * citty hard-codes `strict: false` on node's `parseArgs`, so an unknown flag is
5
- * parsed and then dropped: `vg deploy ./dist --slugg wrong` deploys to the
6
- * *default* slug and exits 0. A human notices the wrong URL in the output; an
7
- * agent reads exit 0 and carries on. The skill scripts already fail this way
8
- * (`unrecognized arguments: …`, exit 2), so this matches them.
9
- *
10
- * Only for commands whose flags are a closed set. `vg generate run` forwards
11
- * arbitrary `--param value` pairs to a model's schema and must stay permissive,
12
- * and `vg playtest`/`vg factory` are passthroughs to another binary's grammar.
13
- */
14
- /** The subset of citty's `ArgDef` this check reads. */
15
- interface ArgSpec {
16
- type?: string;
17
- alias?: string | string[];
18
- }
19
- /**
20
- * The long flags in `rawArgs` that `argsDef` does not declare, in the order
21
- * they were typed. Everything after a bare `--` is a passthrough payload and is
22
- * left alone.
23
- */
24
- export declare const unknownFlags: (rawArgs: string[], argsDef: Record<string, ArgSpec>) => string[];
25
- /** Exit 2 naming every undeclared flag, or return so the command can run. */
26
- export declare const assertKnownFlags: (rawArgs: string[], argsDef: Record<string, ArgSpec>) => void;
27
- export {};
@@ -1,78 +0,0 @@
1
- /**
2
- * Reject flags a command does not declare.
3
- *
4
- * citty hard-codes `strict: false` on node's `parseArgs`, so an unknown flag is
5
- * parsed and then dropped: `vg deploy ./dist --slugg wrong` deploys to the
6
- * *default* slug and exits 0. A human notices the wrong URL in the output; an
7
- * agent reads exit 0 and carries on. The skill scripts already fail this way
8
- * (`unrecognized arguments: …`, exit 2), so this matches them.
9
- *
10
- * Only for commands whose flags are a closed set. `vg generate run` forwards
11
- * arbitrary `--param value` pairs to a model's schema and must stay permissive,
12
- * and `vg playtest`/`vg factory` are passthroughs to another binary's grammar.
13
- */
14
- const UNRECOGNIZED_EXIT = 2;
15
- const declaredNames = (argsDef) => {
16
- const names = new Set();
17
- for (const [name, spec] of Object.entries(argsDef)) {
18
- if (spec.type === "positional") {
19
- continue;
20
- }
21
- names.add(name);
22
- // citty accepts a camelCase arg under its kebab spelling too.
23
- names.add(name.replaceAll(/[A-Z]/gu, (c) => `-${c.toLowerCase()}`));
24
- const { alias } = spec;
25
- if (Array.isArray(alias)) {
26
- for (const a of alias) {
27
- names.add(a);
28
- }
29
- }
30
- else if (alias !== undefined) {
31
- names.add(alias);
32
- }
33
- }
34
- // citty answers these itself; they never reach a command's `args`.
35
- names.add("help");
36
- names.add("version");
37
- return names;
38
- };
39
- /**
40
- * The long flags in `rawArgs` that `argsDef` does not declare, in the order
41
- * they were typed. Everything after a bare `--` is a passthrough payload and is
42
- * left alone.
43
- */
44
- export const unknownFlags = (rawArgs, argsDef) => {
45
- const known = declaredNames(argsDef);
46
- const unknown = [];
47
- for (const raw of rawArgs) {
48
- if (raw === "--") {
49
- break;
50
- }
51
- if (!raw.startsWith("--") || raw.length === 2) {
52
- continue;
53
- }
54
- const flag = (raw.slice(2).split("=")[0] ?? "").trim();
55
- if (flag.length === 0) {
56
- continue;
57
- }
58
- // `--no-foo` is citty's negation of the boolean `foo`.
59
- const negated = flag.startsWith("no-") ? flag.slice(3) : null;
60
- if (known.has(flag)) {
61
- continue;
62
- }
63
- if (negated !== null && known.has(negated)) {
64
- continue;
65
- }
66
- unknown.push(`--${flag}`);
67
- }
68
- return unknown;
69
- };
70
- /** Exit 2 naming every undeclared flag, or return so the command can run. */
71
- export const assertKnownFlags = (rawArgs, argsDef) => {
72
- const unknown = unknownFlags(rawArgs, argsDef);
73
- if (unknown.length === 0) {
74
- return;
75
- }
76
- process.stderr.write(`unrecognized arguments: ${unknown.join(" ")}\n`);
77
- process.exit(UNRECOGNIZED_EXIT);
78
- };
@@ -1,16 +0,0 @@
1
- /** JSON domain types and guards shared across CLI modules. */
2
- /**
3
- * What the CLI's I/O boundaries actually produce: fal responses proxied
4
- * through `generate.forward`, config files, and any other `JSON.parse`
5
- * output. Values are narrowed from this closed union instead of sniffed
6
- * with `typeof`.
7
- */
8
- export type JsonValue = string | number | boolean | null | JsonValue[] | {
9
- [key: string]: JsonValue;
10
- };
11
- export interface JsonObject {
12
- [key: string]: JsonValue;
13
- }
14
- export declare const isJsonObject: (value: JsonValue | undefined) => value is JsonObject;
15
- export declare const isJsonString: (value: JsonValue | undefined) => value is string;
16
- export declare const isJsonNumber: (value: JsonValue | undefined) => value is number;
package/dist/lib/types.js DELETED
@@ -1,10 +0,0 @@
1
- /** JSON domain types and guards shared across CLI modules. */
2
- export const isJsonObject = (value) =>
3
- // Object() is the identity only on objects; arrays are split off explicitly.
4
- Object(value) === value && !Array.isArray(value);
5
- export const isJsonString = (value) =>
6
- // String() is the identity only on strings.
7
- String(value) === value;
8
- export const isJsonNumber = (value) =>
9
- // JSON cannot encode NaN/Infinity, so isFinite matches every JSON number.
10
- Number.isFinite(value);
@@ -1,10 +0,0 @@
1
- export declare const markUpdateChecked: () => void;
2
- export declare const isNewerVersion: (latest: string, current: string) => boolean;
3
- export declare const fetchLatestVersion: () => Promise<string | null>;
4
- /**
5
- * Fire-and-forget background update: at most once per day (and never in CI
6
- * or with VG_NO_AUTO_UPDATE set), re-invoke this CLI as a detached
7
- * `vg update --auto`, which only applies anything when npm has a newer
8
- * version. The foreground command pays no latency and prints nothing.
9
- */
10
- export declare const maybeScheduleAutoUpdate: () => void;