peachsim 0.1.712 → 0.1.714

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 (75) hide show
  1. package/cli/commands/maestro.ts +7 -337
  2. package/cli/commands/test.ts +1 -1
  3. package/cli/commands/upload.ts +3 -0
  4. package/cli/maestro-workspace.ts +347 -0
  5. package/cli/outbound-endpoints.ts +2 -0
  6. package/dist-lib/agent-daemon-client.cjs +1 -1
  7. package/dist-lib/agent-events.cjs +1 -1
  8. package/dist-lib/agent-identity.cjs +1 -1
  9. package/dist-lib/agent-sessions.cjs +1 -1
  10. package/dist-lib/attached-projects.cjs +1 -1
  11. package/dist-lib/auth/shared-session.cjs +1 -1
  12. package/dist-lib/backend-origin.cjs +1 -1
  13. package/dist-lib/beta.cjs +1 -1
  14. package/dist-lib/beta.mjs +1 -1
  15. package/dist-lib/bridge-constants.cjs +1 -1
  16. package/dist-lib/bridge-contract-input.cjs +1 -1
  17. package/dist-lib/bridge-contract-input.mjs +1 -1
  18. package/dist-lib/bridge-contract.cjs +1 -1
  19. package/dist-lib/bridge-contract.mjs +1 -1
  20. package/dist-lib/capture-contract.cjs +1 -1
  21. package/dist-lib/capture-contract.mjs +1 -1
  22. package/dist-lib/cli-constants.cjs +1 -1
  23. package/dist-lib/cloud-contract.cjs +1 -1
  24. package/dist-lib/cloud-contract.mjs +1 -1
  25. package/dist-lib/cloud-test-args.cjs +1 -1
  26. package/dist-lib/cloud-test-args.mjs +1 -1
  27. package/dist-lib/cloud.cjs +1 -1
  28. package/dist-lib/cloud.mjs +1 -1
  29. package/dist-lib/config.cjs +1 -1
  30. package/dist-lib/detox/index.cjs +1 -1
  31. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +1 -1
  34. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +1 -1
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +1 -1
  50. package/dist-lib/native-app-identity.cjs +1 -1
  51. package/dist-lib/native-app-identity.mjs +1 -1
  52. package/dist-lib/native-firebase-metadata.cjs +1 -1
  53. package/dist-lib/native-firebase-metadata.mjs +1 -1
  54. package/dist-lib/plist.cjs +1 -1
  55. package/dist-lib/plist.mjs +1 -1
  56. package/dist-lib/profiles.cjs +1 -1
  57. package/dist-lib/public-brand.cjs +1 -1
  58. package/dist-lib/react-native-host-modules.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.mjs +1 -1
  60. package/dist-lib/render-mode.cjs +1 -1
  61. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  62. package/dist-lib/sdk.cjs +1 -1
  63. package/dist-lib/sdk.mjs +1 -1
  64. package/dist-lib/skills.cjs +1 -1
  65. package/dist-lib/swift-compile.cjs +1 -1
  66. package/dist-lib/swift-compile.mjs +1 -1
  67. package/dist-lib/swift-package.cjs +1 -1
  68. package/dist-lib/swift-package.mjs +1 -1
  69. package/dist-lib/swift-submit.cjs +1 -1
  70. package/dist-lib/swift-submit.mjs +1 -1
  71. package/dist-lib/swift-toolchain.cjs +1 -1
  72. package/dist-lib/swift.cjs +1 -1
  73. package/dist-lib/vite-swift.cjs +1 -1
  74. package/dist-lib/vite.cjs +1 -1
  75. package/package.json +1 -1
@@ -21,6 +21,13 @@ import {
21
21
  type JUnitCaseInput,
22
22
  type SessionLogFlow,
23
23
  } from '../maestro-report'
24
+ import {
25
+ collectFlowFiles,
26
+ extractMaestroCompatFlags,
27
+ loadMaestroWorkspaceConfig,
28
+ type MaestroCompatOptions,
29
+ type MaestroWorkspaceConfig,
30
+ } from '../maestro-workspace'
24
31
  import { registerRun, shouldRegisterRun, stepSummaryFromTrace } from '../run-registry'
25
32
  import { RnxExit } from '../run-rnx'
26
33
  import {
@@ -204,219 +211,6 @@ export function applyEnvFlags(args: string[]): string[] {
204
211
  return out
205
212
  }
206
213
 
207
- // maestro-cli flags this command consumes itself, accepted so an existing
208
- // script can swap `maestro test` for `peach maestro test` unedited. each one
209
- // either takes effect below or says out loud that it does not: an option
210
- // that is quietly dropped is how a run reports success while doing something
211
- // other than what was asked. `--origin` is consumed here because only this
212
- // command reads it; everything this function leaves alone rides on to the
213
- // flow runner, which rejects what it does not know.
214
- //
215
- // both `--flag value` and `--flag=value` spellings work: maestro's own docs
216
- // use the `=` form for tags and output dirs, so rejecting it would break the
217
- // exact command lines users paste from there.
218
- export interface MaestroCompatOptions {
219
- // null = flag absent. CLI lists take precedence over config.yaml (maestro
220
- // documents CLI-always-wins), so absent must stay distinguishable from [].
221
- includeTags: string[] | null
222
- excludeTags: string[] | null
223
- configPath: string | null
224
- format: string | null
225
- output: string | null
226
- testOutputDir: string | null
227
- debugOutput: string | null
228
- platform: string | null
229
- testSuiteName: string | null
230
- }
231
-
232
- const MAESTRO_COMPAT_VALUE_FLAGS = new Set([
233
- '--include-tags',
234
- '--exclude-tags',
235
- '--config',
236
- '--format',
237
- '--output',
238
- '--test-output-dir',
239
- '--debug-output',
240
- '--platform',
241
- '--udid',
242
- '--test-suite-name',
243
- '--shards',
244
- '--shard-all',
245
- '--shard-split',
246
- '--api-key',
247
- '--api-url',
248
- '--screen-size',
249
- ])
250
-
251
- // shared with the cloud submitter, which resolves tag selection before any
252
- // hosted job exists the same way a local workspace run does.
253
- export function splitTagList(value: string): string[] {
254
- return value
255
- .split(',')
256
- .map((tag) => tag.trim())
257
- .filter((tag) => tag.length > 0)
258
- }
259
-
260
- export function extractMaestroCompatFlags(args: string[]): {
261
- rest: string[]
262
- compat: MaestroCompatOptions
263
- } {
264
- const compat: MaestroCompatOptions = {
265
- includeTags: null,
266
- excludeTags: null,
267
- configPath: null,
268
- format: null,
269
- output: null,
270
- testOutputDir: null,
271
- debugOutput: null,
272
- platform: null,
273
- testSuiteName: null,
274
- }
275
- const rest: string[] = []
276
- for (let i = 0; i < args.length; i++) {
277
- const a = args[i]
278
- const eq = a.indexOf('=')
279
- const head = eq > 0 ? a.slice(0, eq) : a
280
- if (MAESTRO_COMPAT_VALUE_FLAGS.has(head)) {
281
- const inline = eq > 0 ? a.slice(eq + 1) : null
282
- const next = args[i + 1]
283
- const value =
284
- inline !== null && inline.length > 0
285
- ? inline
286
- : next !== undefined && !next.startsWith('-')
287
- ? next
288
- : null
289
- if (inline === null || inline.length === 0) i += 1
290
- if (value === null || value.length === 0) {
291
- throw new Error(`${head} expects a value`)
292
- }
293
- switch (head) {
294
- case '--include-tags':
295
- compat.includeTags = [...(compat.includeTags ?? []), ...splitTagList(value)]
296
- break
297
- case '--exclude-tags':
298
- compat.excludeTags = [...(compat.excludeTags ?? []), ...splitTagList(value)]
299
- break
300
- case '--config':
301
- compat.configPath = value
302
- break
303
- case '--format':
304
- // maestro spells it JUNIT; normalize so either case works.
305
- compat.format = value.toLowerCase()
306
- break
307
- case '--output':
308
- compat.output = value
309
- break
310
- case '--test-output-dir':
311
- compat.testOutputDir = value
312
- break
313
- case '--debug-output':
314
- compat.debugOutput = value
315
- break
316
- case '--platform':
317
- if (value.toLowerCase() !== 'ios') {
318
- throw new Error(
319
- `peach emulates iOS only; --platform ${value} is not supported`,
320
- )
321
- }
322
- compat.platform = value
323
- break
324
- case '--udid':
325
- console.warn(
326
- ' warn: --udid selects a Maestro simulator; peach manages its own sim — pin one with --sim instead',
327
- )
328
- break
329
- case '--test-suite-name':
330
- compat.testSuiteName = value
331
- break
332
- case '--shards':
333
- case '--shard-all':
334
- case '--shard-split':
335
- console.warn(
336
- ` warn: ${head} shards across Maestro devices; peach runs the full selection on one sim`,
337
- )
338
- break
339
- case '--api-key':
340
- case '--api-url':
341
- console.warn(` warn: ${head} is Maestro beta AI analysis; peach ignores it`)
342
- break
343
- case '--screen-size':
344
- console.warn(' warn: --screen-size is web-only; peach ignores it')
345
- break
346
- }
347
- continue
348
- }
349
- if (a === '--origin') {
350
- // read above for the run-registration origin. the flow runner has no
351
- // --origin, so it must not ride into playbackArgs.
352
- i += 1
353
- continue
354
- }
355
- if (a === '-d') {
356
- // maestro's short form for --device. peach's device flag names a device
357
- // model, and the flow runner reads it under the long spelling only.
358
- rest.push('--device')
359
- continue
360
- }
361
- if (a === '--no-ansi' || a === '--no-color') {
362
- // trivially satisfied: peach prints no ANSI escapes anywhere on this path.
363
- continue
364
- }
365
- if (a === '--ansi' || a === '--color') {
366
- console.warn(' warn: peach prints no ANSI escapes; colored output is unavailable')
367
- continue
368
- }
369
- if (a === '--continuous' || a === '-c') {
370
- console.warn(' warn: --continuous is not implemented in peach — running once')
371
- continue
372
- }
373
- if (a === '--flatten-debug-output') {
374
- // peach writes one <dir>/maestro.log with no per-run subfolders or
375
- // timestamps, so the maestro layout flag is already satisfied.
376
- continue
377
- }
378
- if (a === '--analyze') {
379
- console.warn(' warn: --analyze is Maestro beta AI analysis; peach ignores it')
380
- continue
381
- }
382
- if (a === '-s') {
383
- const count = args[i + 1]
384
- if (!count || count.startsWith('-')) throw new Error('-s expects a value')
385
- i += 1
386
- console.warn(
387
- ' warn: -s shards across Maestro devices; peach runs the full selection on one sim',
388
- )
389
- continue
390
- }
391
- if (head === '-p') {
392
- // -p is the peach bridge-port short, not maestro's --platform short. a
393
- // non-numeric value is a pasted maestro command line; fail loud with
394
- // the mapping instead of pinning the bridge to a NaN port.
395
- const value = eq > 0 ? a.slice(eq + 1) : args[i + 1]
396
- if (value !== undefined && !value.startsWith('-') && !/^\d+$/.test(value)) {
397
- throw new Error(
398
- `-p is the peach bridge-port short; use --platform for the Maestro platform (got ${JSON.stringify(value)})`,
399
- )
400
- }
401
- rest.push(a)
402
- continue
403
- }
404
- rest.push(a)
405
- }
406
- if (
407
- compat.format !== null &&
408
- !['junit', 'html', 'html-detailed', 'noop'].includes(compat.format)
409
- ) {
410
- throw new Error(`unsupported --format: ${compat.format} (peach writes junit reports)`)
411
- }
412
- if (compat.format === 'html' || compat.format === 'html-detailed') {
413
- console.warn(
414
- ' warn: --format html is not implemented in peach — running without a report',
415
- )
416
- }
417
- return { rest, compat }
418
- }
419
-
420
214
  function findDefaultMaestroTarget(cwd: string): string | null {
421
215
  for (const dir of MAESTRO_DIRS) {
422
216
  const abs = path.join(cwd, dir)
@@ -425,130 +219,6 @@ function findDefaultMaestroTarget(cwd: string): string | null {
425
219
  return null
426
220
  }
427
221
 
428
- interface MaestroWorkspaceConfig {
429
- flows?: string[]
430
- includeTags?: string[]
431
- excludeTags?: string[]
432
- testOutputDir?: string
433
- }
434
-
435
- export interface CollectFlowFilesOptions {
436
- // explicit `--config <path>`; globs still resolve under the target dir.
437
- configPath?: string
438
- // CLI tag lists; null/undefined falls back to the workspace config (maestro
439
- // documents CLI-always-wins, never a union).
440
- includeTags?: string[] | null
441
- excludeTags?: string[] | null
442
- }
443
-
444
- // read the workspace config for a directory target: an explicit --config
445
- // path, else config.yaml/config.yml beside the flows, else empty policy.
446
- export function loadMaestroWorkspaceConfig(
447
- dir: string,
448
- configPath?: string,
449
- ): { path: string | null; config: MaestroWorkspaceConfig } {
450
- const found =
451
- configPath ??
452
- ['config.yaml', 'config.yml']
453
- .map((name) => path.join(dir, name))
454
- .find((p) => fs.existsSync(p))
455
- if (!found) return { path: null, config: {} }
456
- if (!fs.existsSync(found)) {
457
- throw new Error(`maestro config not found: ${configPath}`)
458
- }
459
- // yaml.parse returns any; shape-check the fields we use below instead
460
- // of trusting the file
461
- const parsed: unknown = yaml.parse(fs.readFileSync(found, 'utf8'))
462
- if (!parsed || typeof parsed !== 'object') return { path: found, config: {} }
463
- const raw = parsed as Record<string, unknown>
464
- const config: MaestroWorkspaceConfig = {}
465
- if (Array.isArray(raw.flows)) {
466
- config.flows = raw.flows.filter((g): g is string => typeof g === 'string')
467
- }
468
- if (Array.isArray(raw.includeTags)) {
469
- config.includeTags = raw.includeTags.filter((t): t is string => typeof t === 'string')
470
- }
471
- if (Array.isArray(raw.excludeTags)) {
472
- config.excludeTags = raw.excludeTags.filter((t): t is string => typeof t === 'string')
473
- }
474
- if (typeof raw.testOutputDir === 'string' && raw.testOutputDir.length > 0) {
475
- config.testOutputDir = raw.testOutputDir
476
- }
477
- return { path: found, config }
478
- }
479
-
480
- // workspace planning for directory targets — mirrors maestro's
481
- // WorkspaceExecutionPlanner: discover config.yaml/config.yml in the
482
- // directory, walk it recursively for *.yaml/*.yml flow files (config files
483
- // excluded), keep the ones matching the config's `flows:` globs (default
484
- // `*` = top level only; `!`-prefixed globs subtract from the positive
485
- // matches), then filter by includeTags/excludeTags against each flow's
486
- // frontmatter `tags:` (OR within a flag, include-then-exclude between them).
487
- //
488
- // an explicit file target always runs: maestro runs a named flow even when
489
- // its tags would exclude it from a directory run.
490
- export function collectFlowFiles(
491
- target: string,
492
- opts: CollectFlowFilesOptions = {},
493
- ): string[] {
494
- const stat = fs.statSync(target)
495
- if (stat.isFile()) return [target]
496
- if (!stat.isDirectory()) {
497
- throw new Error(`not a file or directory: ${target}`)
498
- }
499
-
500
- const { path: configPath, config } = loadMaestroWorkspaceConfig(target, opts.configPath)
501
-
502
- const globs =
503
- Array.isArray(config.flows) && config.flows.length > 0 ? config.flows : ['*']
504
- const positive = globs.filter((glob) => !glob.startsWith('!'))
505
- const negative = globs
506
- .filter((glob) => glob.startsWith('!'))
507
- .map((glob) => glob.slice(1))
508
- .filter((glob) => glob.length > 0)
509
- if (positive.length === 0) {
510
- throw new Error(
511
- `flows: needs at least one positive pattern in ${configPath ?? target} (got only exclusions)`,
512
- )
513
- }
514
- const isFlowFile = (rel: string) => {
515
- const base = path.basename(rel)
516
- if (base.startsWith('.')) return false
517
- if (!base.endsWith('.yaml') && !base.endsWith('.yml')) return false
518
- if (base === 'config.yaml' || base === 'config.yml') return false
519
- return true
520
- }
521
- const matched = new Set<string>()
522
- for (const glob of positive) {
523
- for (const rel of fs.globSync(glob, { cwd: target })) {
524
- if (!isFlowFile(rel)) continue
525
- const abs = path.join(target, rel)
526
- if (fs.existsSync(abs) && fs.statSync(abs).isFile()) matched.add(abs)
527
- }
528
- }
529
- for (const glob of negative) {
530
- for (const rel of fs.globSync(glob, { cwd: target })) {
531
- matched.delete(path.join(target, rel))
532
- }
533
- }
534
- let files = [...matched].sort()
535
-
536
- const includeTags = opts.includeTags ?? config.includeTags ?? []
537
- const excludeTags = opts.excludeTags ?? config.excludeTags ?? []
538
- if (includeTags.length > 0 || excludeTags.length > 0) {
539
- files = files.filter((file) => {
540
- const { frontmatter } = parseFlowFile(fs.readFileSync(file, 'utf8'))
541
- const tags: string[] = Array.isArray(frontmatter.tags) ? frontmatter.tags : []
542
- if (includeTags.length > 0 && !tags.some((t) => includeTags.includes(t))) {
543
- return false
544
- }
545
- if (tags.some((t) => excludeTags.includes(t))) return false
546
- return true
547
- })
548
- }
549
- return files
550
- }
551
-
552
222
  function flowFileStem(file: string): string {
553
223
  return path.basename(file).replace(/\.(ya?ml)$/i, '')
554
224
  }
@@ -884,7 +884,7 @@ export async function runCloudTest(
884
884
  }
885
885
  }
886
886
  if (maestroTarget && statSync(targetPath).isDirectory()) {
887
- const { collectFlowFiles, splitTagList } = await import('./maestro')
887
+ const { collectFlowFiles, splitTagList } = await import('../maestro-workspace')
888
888
  const tagFlag = (name: string): string[] | null => {
889
889
  let values: string[] | null = null
890
890
  for (let i = 0; i < forwarded.length; i++) {
@@ -904,6 +904,7 @@ export async function runUpload(
904
904
  type PreparedFile = {
905
905
  url: string
906
906
  urlhash: string
907
+ contentHash: string
907
908
  method: string
908
909
  bodyHash: string
909
910
  requestVaryHash?: string
@@ -927,6 +928,7 @@ export async function runUpload(
927
928
  return {
928
929
  url,
929
930
  urlhash,
931
+ contentHash: createHash('sha256').update(bytes).digest('hex'),
930
932
  method,
931
933
  bodyHash,
932
934
  requestVaryHash,
@@ -1070,6 +1072,7 @@ export async function runUpload(
1070
1072
  files: prepared.map((f) => ({
1071
1073
  url: f.url,
1072
1074
  urlhash: f.urlhash,
1075
+ contentHash: f.contentHash,
1073
1076
  method: f.method,
1074
1077
  bodyHash: f.bodyHash,
1075
1078
  contentType: f.contentType,