@riddledc/riddle-proof 0.7.72 → 0.7.74

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.
package/dist/cli.cjs CHANGED
@@ -10980,7 +10980,7 @@ function usage() {
10980
10980
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
10981
10981
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
10982
10982
  " riddle-proof-loop status --state-path <path>",
10983
- " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false] [--output <dir>] [--quiet]",
10983
+ " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false] [--poll-attempts n] [--output <dir>] [--quiet]",
10984
10984
  " riddle-proof-loop riddle-preview-deploy <build-dir> <label>",
10985
10985
  " riddle-proof-loop riddle-server-preview <directory> --script-file <file> [--path /route] [--wait-for-selector selector]",
10986
10986
  " riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720] [--strict true|false]",
@@ -11032,6 +11032,13 @@ function optionBoolean(options, key) {
11032
11032
  const flag = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
11033
11033
  throw new Error(`--${flag} must be true or false.`);
11034
11034
  }
11035
+ function optionNumber(options, ...keys) {
11036
+ for (const key of keys) {
11037
+ const value = optionString(options, key);
11038
+ if (value !== void 0) return Number(value);
11039
+ }
11040
+ return void 0;
11041
+ }
11035
11042
  function readStdin() {
11036
11043
  return (0, import_node_fs6.readFileSync)(0, "utf-8");
11037
11044
  }
@@ -11245,7 +11252,7 @@ function profileResultMarkdown(result) {
11245
11252
  ""
11246
11253
  ];
11247
11254
  for (const check of result.checks) {
11248
- lines.push(`- ${check.status}: ${check.label || check.type}`);
11255
+ lines.push(`- ${check.status}: ${profileCheckMarkdownLabel(check)}`);
11249
11256
  if (check.message) lines.push(` ${check.message}`);
11250
11257
  }
11251
11258
  const setupSummaryLines = profileSetupSummaryMarkdown(result);
@@ -11269,6 +11276,76 @@ function profileResultMarkdown(result) {
11269
11276
  return `${lines.join("\n")}
11270
11277
  `;
11271
11278
  }
11279
+ function markdownInlineCode(value, maxLength = 80) {
11280
+ const normalized = value.replace(/\s+/g, " ").trim();
11281
+ const clipped = normalized.length > maxLength ? `${normalized.slice(0, Math.max(0, maxLength - 3))}...` : normalized;
11282
+ return `\`${clipped.replace(/`/g, "'")}\``;
11283
+ }
11284
+ function profileCheckTextTarget(evidence) {
11285
+ const text = cliString(evidence.text);
11286
+ if (text) return markdownInlineCode(text);
11287
+ const pattern = cliString(evidence.pattern);
11288
+ return pattern ? `pattern ${markdownInlineCode(pattern)}` : void 0;
11289
+ }
11290
+ function profileCheckMarkdownTarget(check) {
11291
+ const evidence = cliRecord(check.evidence);
11292
+ if (!evidence) return void 0;
11293
+ const selector = cliString(evidence.selector);
11294
+ if (check.type === "route_loaded") {
11295
+ const expectedPath = cliString(evidence.expected_path);
11296
+ return expectedPath ? markdownInlineCode(expectedPath) : void 0;
11297
+ }
11298
+ if (check.type === "selector_visible" || check.type === "selector_absent") {
11299
+ return selector ? markdownInlineCode(selector) : void 0;
11300
+ }
11301
+ if (check.type === "selector_count_at_least") {
11302
+ const minCount = cliFiniteNumber(evidence.min_count);
11303
+ return selector && minCount !== void 0 ? `${markdownInlineCode(selector)} >= ${minCount}` : void 0;
11304
+ }
11305
+ if (check.type === "selector_count_equals" || check.type === "selector_count_equal" || check.type === "selector_count_eq") {
11306
+ const expectedCount = cliFiniteNumber(evidence.expected_count);
11307
+ return selector && expectedCount !== void 0 ? `${markdownInlineCode(selector)} = ${expectedCount}` : void 0;
11308
+ }
11309
+ if (check.type === "selector_text_order") {
11310
+ return selector ? `${markdownInlineCode(selector)} text order` : void 0;
11311
+ }
11312
+ if (check.type === "text_visible" || check.type === "text_absent") {
11313
+ return profileCheckTextTarget(evidence);
11314
+ }
11315
+ if (check.type === "frame_text_visible") {
11316
+ const textTarget = profileCheckTextTarget(evidence);
11317
+ if (selector && textTarget) return `${markdownInlineCode(selector)} contains ${textTarget}`;
11318
+ return selector ? markdownInlineCode(selector) : textTarget;
11319
+ }
11320
+ if (check.type === "frame_url_equals") {
11321
+ const expectedUrl = cliString(evidence.expected_url);
11322
+ if (selector && expectedUrl) return `${markdownInlineCode(selector)} = ${markdownInlineCode(expectedUrl)}`;
11323
+ return selector ? markdownInlineCode(selector) : expectedUrl ? markdownInlineCode(expectedUrl) : void 0;
11324
+ }
11325
+ if (check.type === "frame_url_matches") {
11326
+ const pattern = cliString(evidence.pattern);
11327
+ if (selector && pattern) return `${markdownInlineCode(selector)} matches ${markdownInlineCode(pattern)}`;
11328
+ return selector ? markdownInlineCode(selector) : pattern ? `pattern ${markdownInlineCode(pattern)}` : void 0;
11329
+ }
11330
+ if (check.type === "frame_no_horizontal_overflow") {
11331
+ const maxOverflow = cliFiniteNumber(evidence.max_overflow_px);
11332
+ if (selector && maxOverflow !== void 0) return `${markdownInlineCode(selector)} <= ${maxOverflow}px`;
11333
+ return selector ? markdownInlineCode(selector) : maxOverflow !== void 0 ? `<= ${maxOverflow}px` : void 0;
11334
+ }
11335
+ if (check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow") {
11336
+ const maxOverflow = cliFiniteNumber(evidence.max_overflow_px);
11337
+ return maxOverflow !== void 0 ? `<= ${maxOverflow}px` : void 0;
11338
+ }
11339
+ if (check.type === "no_fatal_console_errors") {
11340
+ return "0 unallowed fatal errors";
11341
+ }
11342
+ return void 0;
11343
+ }
11344
+ function profileCheckMarkdownLabel(check) {
11345
+ const label = check.label || check.type;
11346
+ const target = profileCheckMarkdownTarget(check);
11347
+ return target ? `${label} (${target})` : label;
11348
+ }
11272
11349
  function cliRecord(value) {
11273
11350
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
11274
11351
  }
@@ -11496,9 +11573,9 @@ async function runProfileForCli(profile, options) {
11496
11573
  }
11497
11574
  const poll = await client.pollJob(jobId, {
11498
11575
  wait: true,
11499
- attempts: optionString(options, "attempts") ? Number(optionString(options, "attempts")) : void 0,
11500
- intervalMs: optionString(options, "intervalMs") ? Number(optionString(options, "intervalMs")) : void 0,
11501
- progressEveryMs: optionString(options, "progressEveryMs") ? Number(optionString(options, "progressEveryMs")) : void 0,
11576
+ attempts: optionNumber(options, "pollAttempts", "attempts"),
11577
+ intervalMs: optionNumber(options, "intervalMs"),
11578
+ progressEveryMs: optionNumber(options, "progressEveryMs"),
11502
11579
  onProgress: options.quiet !== true ? (snapshot) => {
11503
11580
  process.stderr.write(`${riddlePollProgressLine(snapshot)}
11504
11581
  `);
package/dist/cli.js CHANGED
@@ -44,7 +44,7 @@ function usage() {
44
44
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
45
45
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
46
46
  " riddle-proof-loop status --state-path <path>",
47
- " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false] [--output <dir>] [--quiet]",
47
+ " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--strict true|false] [--poll-attempts n] [--output <dir>] [--quiet]",
48
48
  " riddle-proof-loop riddle-preview-deploy <build-dir> <label>",
49
49
  " riddle-proof-loop riddle-server-preview <directory> --script-file <file> [--path /route] [--wait-for-selector selector]",
50
50
  " riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720] [--strict true|false]",
@@ -96,6 +96,13 @@ function optionBoolean(options, key) {
96
96
  const flag = key.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
97
97
  throw new Error(`--${flag} must be true or false.`);
98
98
  }
99
+ function optionNumber(options, ...keys) {
100
+ for (const key of keys) {
101
+ const value = optionString(options, key);
102
+ if (value !== void 0) return Number(value);
103
+ }
104
+ return void 0;
105
+ }
99
106
  function readStdin() {
100
107
  return readFileSync(0, "utf-8");
101
108
  }
@@ -309,7 +316,7 @@ function profileResultMarkdown(result) {
309
316
  ""
310
317
  ];
311
318
  for (const check of result.checks) {
312
- lines.push(`- ${check.status}: ${check.label || check.type}`);
319
+ lines.push(`- ${check.status}: ${profileCheckMarkdownLabel(check)}`);
313
320
  if (check.message) lines.push(` ${check.message}`);
314
321
  }
315
322
  const setupSummaryLines = profileSetupSummaryMarkdown(result);
@@ -333,6 +340,76 @@ function profileResultMarkdown(result) {
333
340
  return `${lines.join("\n")}
334
341
  `;
335
342
  }
343
+ function markdownInlineCode(value, maxLength = 80) {
344
+ const normalized = value.replace(/\s+/g, " ").trim();
345
+ const clipped = normalized.length > maxLength ? `${normalized.slice(0, Math.max(0, maxLength - 3))}...` : normalized;
346
+ return `\`${clipped.replace(/`/g, "'")}\``;
347
+ }
348
+ function profileCheckTextTarget(evidence) {
349
+ const text = cliString(evidence.text);
350
+ if (text) return markdownInlineCode(text);
351
+ const pattern = cliString(evidence.pattern);
352
+ return pattern ? `pattern ${markdownInlineCode(pattern)}` : void 0;
353
+ }
354
+ function profileCheckMarkdownTarget(check) {
355
+ const evidence = cliRecord(check.evidence);
356
+ if (!evidence) return void 0;
357
+ const selector = cliString(evidence.selector);
358
+ if (check.type === "route_loaded") {
359
+ const expectedPath = cliString(evidence.expected_path);
360
+ return expectedPath ? markdownInlineCode(expectedPath) : void 0;
361
+ }
362
+ if (check.type === "selector_visible" || check.type === "selector_absent") {
363
+ return selector ? markdownInlineCode(selector) : void 0;
364
+ }
365
+ if (check.type === "selector_count_at_least") {
366
+ const minCount = cliFiniteNumber(evidence.min_count);
367
+ return selector && minCount !== void 0 ? `${markdownInlineCode(selector)} >= ${minCount}` : void 0;
368
+ }
369
+ if (check.type === "selector_count_equals" || check.type === "selector_count_equal" || check.type === "selector_count_eq") {
370
+ const expectedCount = cliFiniteNumber(evidence.expected_count);
371
+ return selector && expectedCount !== void 0 ? `${markdownInlineCode(selector)} = ${expectedCount}` : void 0;
372
+ }
373
+ if (check.type === "selector_text_order") {
374
+ return selector ? `${markdownInlineCode(selector)} text order` : void 0;
375
+ }
376
+ if (check.type === "text_visible" || check.type === "text_absent") {
377
+ return profileCheckTextTarget(evidence);
378
+ }
379
+ if (check.type === "frame_text_visible") {
380
+ const textTarget = profileCheckTextTarget(evidence);
381
+ if (selector && textTarget) return `${markdownInlineCode(selector)} contains ${textTarget}`;
382
+ return selector ? markdownInlineCode(selector) : textTarget;
383
+ }
384
+ if (check.type === "frame_url_equals") {
385
+ const expectedUrl = cliString(evidence.expected_url);
386
+ if (selector && expectedUrl) return `${markdownInlineCode(selector)} = ${markdownInlineCode(expectedUrl)}`;
387
+ return selector ? markdownInlineCode(selector) : expectedUrl ? markdownInlineCode(expectedUrl) : void 0;
388
+ }
389
+ if (check.type === "frame_url_matches") {
390
+ const pattern = cliString(evidence.pattern);
391
+ if (selector && pattern) return `${markdownInlineCode(selector)} matches ${markdownInlineCode(pattern)}`;
392
+ return selector ? markdownInlineCode(selector) : pattern ? `pattern ${markdownInlineCode(pattern)}` : void 0;
393
+ }
394
+ if (check.type === "frame_no_horizontal_overflow") {
395
+ const maxOverflow = cliFiniteNumber(evidence.max_overflow_px);
396
+ if (selector && maxOverflow !== void 0) return `${markdownInlineCode(selector)} <= ${maxOverflow}px`;
397
+ return selector ? markdownInlineCode(selector) : maxOverflow !== void 0 ? `<= ${maxOverflow}px` : void 0;
398
+ }
399
+ if (check.type === "no_horizontal_overflow" || check.type === "no_mobile_horizontal_overflow") {
400
+ const maxOverflow = cliFiniteNumber(evidence.max_overflow_px);
401
+ return maxOverflow !== void 0 ? `<= ${maxOverflow}px` : void 0;
402
+ }
403
+ if (check.type === "no_fatal_console_errors") {
404
+ return "0 unallowed fatal errors";
405
+ }
406
+ return void 0;
407
+ }
408
+ function profileCheckMarkdownLabel(check) {
409
+ const label = check.label || check.type;
410
+ const target = profileCheckMarkdownTarget(check);
411
+ return target ? `${label} (${target})` : label;
412
+ }
336
413
  function cliRecord(value) {
337
414
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
338
415
  }
@@ -560,9 +637,9 @@ async function runProfileForCli(profile, options) {
560
637
  }
561
638
  const poll = await client.pollJob(jobId, {
562
639
  wait: true,
563
- attempts: optionString(options, "attempts") ? Number(optionString(options, "attempts")) : void 0,
564
- intervalMs: optionString(options, "intervalMs") ? Number(optionString(options, "intervalMs")) : void 0,
565
- progressEveryMs: optionString(options, "progressEveryMs") ? Number(optionString(options, "progressEveryMs")) : void 0,
640
+ attempts: optionNumber(options, "pollAttempts", "attempts"),
641
+ intervalMs: optionNumber(options, "intervalMs"),
642
+ progressEveryMs: optionNumber(options, "progressEveryMs"),
566
643
  onProgress: options.quiet !== true ? (snapshot) => {
567
644
  process.stderr.write(`${riddlePollProgressLine(snapshot)}
568
645
  `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.7.72",
3
+ "version": "0.7.74",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",