bpmax-cli 0.2.1-beta.35 → 0.2.1-beta.37

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 (29) hide show
  1. package/README.md +4 -0
  2. package/dist/bin.js +748 -52
  3. package/dist/bin.js.map +1 -1
  4. package/package.json +2 -2
  5. package/skills/bpmax-console-template-editor/scripts/console_template_editor_common.py +238 -4
  6. package/skills/bpmax-console-template-editor/tests/test_console_template_editor.py +258 -0
  7. package/skills/bpmax-e2e-flow-config-orchestrator/SKILL.md +6 -0
  8. package/skills/bpmax-e2e-flow-config-orchestrator/agents/openai.yaml +2 -2
  9. package/skills/bpmax-e2e-flow-config-orchestrator/references/orchestration-matrix.md +13 -9
  10. package/skills/bpmax-e2e-flow-test-operator/SKILL.md +14 -6
  11. package/skills/bpmax-e2e-flow-test-operator/agents/openai.yaml +2 -2
  12. package/skills/bpmax-e2e-flow-test-operator/references/ai-test-suite.md +15 -0
  13. package/skills/bpmax-e2e-flow-test-operator/references/full-detail-guide.md +3 -1
  14. package/skills/bpmax-flow-template-editor/references/requirement-to-node-mapping.md +5 -0
  15. package/skills/bpmax-flow-template-editor/references/runtime-verified-node-fields.md +6 -0
  16. package/skills/bpmax-functional-test-design/LICENSE.upstream +24 -0
  17. package/skills/bpmax-functional-test-design/SKILL.md +80 -0
  18. package/skills/bpmax-functional-test-design/agents/openai.yaml +4 -0
  19. package/skills/bpmax-functional-test-design/references/bpmax-test-suite-output.md +95 -0
  20. package/skills/bpmax-functional-test-design/references/decision-table-testing.md +50 -0
  21. package/skills/bpmax-functional-test-design/references/domain-testing.md +43 -0
  22. package/skills/bpmax-functional-test-design/references/state-transition-testing.md +47 -0
  23. package/skills/bpmax-functional-test-design/references/technique-selection.md +38 -0
  24. package/skills/bpmax-functional-test-design/references/use-case-testing.md +55 -0
  25. package/skills/bpmax-ui-ux-audit/LICENSE.upstream +23 -0
  26. package/skills/bpmax-ui-ux-audit/SKILL.md +42 -0
  27. package/skills/bpmax-ui-ux-audit/agents/openai.yaml +4 -0
  28. package/skills/bpmax-ui-ux-audit/references/audit-framework.md +39 -0
  29. package/skills/bpmax-ui-ux-audit/references/bpmax-ux-findings.md +56 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bpmax-cli",
3
- "version": "0.2.1-beta.35",
3
+ "version": "0.2.1-beta.37",
4
4
  "description": "CLI for BPMAX environments with multi-profile config and local login callback flow",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,7 +20,7 @@
20
20
  "build": "tsup",
21
21
  "dev": "tsx src/bin.ts",
22
22
  "install:skills": "node scripts/install-skills.mjs",
23
- "test": "vitest run",
23
+ "test": "vitest run --exclude '.worktrees/**'",
24
24
  "typecheck": "tsc --noEmit"
25
25
  },
26
26
  "engines": {
@@ -448,11 +448,245 @@ def _check_frontend_detail_counting(
448
448
  ) -> None:
449
449
  if not isinstance(script, str):
450
450
  return
451
- has_row_loop = bool(re.search(r"\.(?:forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(?:of|in)\b", script))
452
- has_metric = bool(re.search(r"count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数", script, re.IGNORECASE))
453
451
  source_text = data_source if isinstance(data_source, str) else json.dumps(data_source, ensure_ascii=False, sort_keys=True)
454
- has_aggregation = bool(re.search(r"(?:aggs|aggregations)\b|(?:['\"]?size['\"]?)\s*:\s*0", f"{source_text}\n{script}", re.IGNORECASE))
455
- if has_row_loop and has_metric and not has_aggregation:
452
+ def strip_js_non_code(value: str) -> str:
453
+ output: list[str] = []
454
+ state = "code"
455
+ escaped = False
456
+ index = 0
457
+ while index < len(value):
458
+ char = value[index]
459
+ next_char = value[index + 1] if index + 1 < len(value) else ""
460
+ if state == "code" and char == "/" and next_char == "/":
461
+ state = "line"; output.extend((" ", " ")); index += 2; continue
462
+ if state == "code" and char == "/" and next_char == "*":
463
+ state = "block"; output.extend((" ", " ")); index += 2; continue
464
+ if state == "code" and char in ("'", '"'):
465
+ end = index + 1
466
+ quote_escaped = False
467
+ while end < len(value):
468
+ if quote_escaped: quote_escaped = False
469
+ elif value[end] == "\\": quote_escaped = True
470
+ elif value[end] == char: break
471
+ end += 1
472
+ literal = value[index + 1:end]
473
+ previous = next((item for item in reversed(output) if not item.isspace()), "")
474
+ if end < len(value) and re.fullmatch(r"[A-Za-z_$][\w$]*", literal) and previous in ("{", ",") and re.match(r"\s*:", value[end + 1:]):
475
+ output.extend(f" {literal} "); index = end + 1; continue
476
+ state = "single" if char == "'" else "double"; output.append(" "); index += 1; continue
477
+ if state == "code" and char == "`":
478
+ state = "template"; output.append(" "); index += 1; continue
479
+ if state == "line":
480
+ if char == "\n": state = "code"; output.append("\n")
481
+ else: output.append(" ")
482
+ index += 1; continue
483
+ if state == "block":
484
+ if char == "*" and next_char == "/": state = "code"; output.extend((" ", " ")); index += 2
485
+ else: output.append("\n" if char == "\n" else " "); index += 1
486
+ continue
487
+ if state != "code":
488
+ output.append("\n" if char == "\n" else " ")
489
+ if escaped: escaped = False
490
+ elif char == "\\": escaped = True
491
+ elif (state == "single" and char == "'") or (state == "double" and char == '"') or (state == "template" and char == "`"): state = "code"
492
+ index += 1; continue
493
+ output.append(char); index += 1
494
+ return "".join(output)
495
+
496
+ pagination_code = strip_js_non_code(source_text)
497
+ frontend_code = strip_js_non_code(script)
498
+ has_frontend_detail_access = bool(re.search(r"\brows\b|\bctx\s*\[|\bctx\.data\?*\.hits\?*\.hits\b|\.(?:forEach|map|reduce|filter)\s*\(|for\s*\([^)]*\b(?:of|in)\b", frontend_code, re.IGNORECASE))
499
+ has_metric = bool(re.search(r"count|total|amount|qty|quantity|inventory|stock|sale|销量|库存|项目数|数量|金额|合计|总数", frontend_code, re.IGNORECASE))
500
+ def top_level_returned_objects(code: str) -> list[str]:
501
+ objects: list[str] = []
502
+ scan_depth = 0
503
+ scan_index = 0
504
+ for match in re.finditer(r"\breturn\s*{", code):
505
+ while scan_index < match.start():
506
+ if code[scan_index] == "{": scan_depth += 1
507
+ elif code[scan_index] == "}": scan_depth -= 1
508
+ scan_index += 1
509
+ if scan_depth != 0:
510
+ continue
511
+ start = code.find("{", match.start())
512
+ depth = 0
513
+ for index in range(start, len(code)):
514
+ if code[index] == "{": depth += 1
515
+ elif code[index] == "}": depth -= 1
516
+ if depth == 0:
517
+ objects.append(code[start:index + 1])
518
+ break
519
+ return objects
520
+
521
+ returned_objects = top_level_returned_objects(pagination_code)
522
+ returned_query = returned_objects[0] if len(returned_objects) == 1 else ""
523
+ frontend_returned_objects = top_level_returned_objects(frontend_code)
524
+ frontend_returned_query = frontend_returned_objects[0] if len(frontend_returned_objects) == 1 else ""
525
+ def top_level_properties(object_text: str) -> dict[str, list[str]] | None:
526
+ if not object_text.startswith("{") or not object_text.endswith("}"):
527
+ return None
528
+ entries: list[str] = []
529
+ depth = 0
530
+ start = 1
531
+ for index in range(1, len(object_text) - 1):
532
+ char = object_text[index]
533
+ if char in "{[(": depth += 1
534
+ elif char in "}])": depth -= 1
535
+ elif char == "," and depth == 0:
536
+ entries.append(object_text[start:index]); start = index + 1
537
+ entries.append(object_text[start:-1])
538
+ fields: dict[str, list[str]] = {}
539
+ for entry in entries:
540
+ value = entry.strip()
541
+ if not value:
542
+ continue
543
+ if value.startswith("..."):
544
+ return None
545
+ match = re.fullmatch(r"([A-Za-z_$][\w$]*)\s*:\s*([\s\S]*)", value)
546
+ if not match:
547
+ return None
548
+ fields.setdefault(match.group(1), []).append(match.group(2).strip())
549
+ return fields
550
+
551
+ returned_fields = top_level_properties(returned_query)
552
+ frontend_returned_fields = top_level_properties(frontend_returned_query)
553
+ aggregation_value = (returned_fields.get("aggs") or returned_fields.get("aggregations") or []) if returned_fields else []
554
+ has_aggregation = (
555
+ bool(returned_fields and returned_fields.get("size") == ["0"] and len(aggregation_value) == 1 and aggregation_value[0].strip().startswith("{"))
556
+ if isinstance(data_source, str)
557
+ else isinstance(data_source, dict) and data_source.get("size") == 0
558
+ and (isinstance(data_source.get("aggs"), dict) or isinstance(data_source.get("aggregations"), dict))
559
+ )
560
+ map_receivers = [match.group(1).lower() for match in re.finditer(r"\b([A-Za-z_$][\w$]*)\s*\.\s*map\s*\(", frontend_code, re.IGNORECASE)]
561
+ def unique_frontend_field(name: str) -> str:
562
+ values = frontend_returned_fields.get(name, []) if frontend_returned_fields else []
563
+ return values[0] if len(values) == 1 else ""
564
+ data_expression = unique_frontend_field("data")
565
+ data_map_match = re.fullmatch(r"hits\s*\.\s*map\s*\(\s*\(?\s*([A-Za-z_$][\w$]*)\s*\)?\s*=>\s*\1\s*\.\s*_source\s*\)", data_expression, re.IGNORECASE)
566
+ page_info_fields = top_level_properties(unique_frontend_field("pageInfo"))
567
+ count_values = page_info_fields.get("count", []) if page_info_fields else []
568
+ count_expression = count_values[0] if len(count_values) == 1 else ""
569
+ has_only_trusted_result_map = len(map_receivers) == 1 and map_receivers[0] == "hits" and bool(data_map_match)
570
+ def top_level_prefix_before(code: str, object_text: str) -> str:
571
+ object_index = code.find(object_text) if object_text else -1
572
+ if object_index < 0:
573
+ return ""
574
+ output: list[str] = []
575
+ depth = 0
576
+ for char in code[:object_index]:
577
+ if char == "{": depth += 1; output.append(" "); continue
578
+ if char == "}": depth -= 1; output.append(" "); continue
579
+ output.append(char if depth == 0 else ("\n" if char == "\n" else " "))
580
+ return "".join(output)
581
+ frontend_top_level_prefix = top_level_prefix_before(frontend_code, frontend_returned_query)
582
+ hits_binding_match = re.search(r"\bconst\s+hits\s*=\s*([^;]+);?", frontend_top_level_prefix, re.IGNORECASE)
583
+ hits_binding = hits_binding_match.group(1) if hits_binding_match else ""
584
+ has_trusted_hits_binding = bool(re.fullmatch(r"\s*ctx\.data\?*\.hits\?*\.hits(?:\s*(?:\|\||\?\?)\s*\[\])?\s*", hits_binding, re.IGNORECASE))
585
+ total_binding_match = re.search(r"\bconst\s+total\s*=\s*([^;]+);?", frontend_top_level_prefix, re.IGNORECASE)
586
+ total_binding = total_binding_match.group(1) if total_binding_match else ""
587
+ has_trusted_total_binding = bool(re.fullmatch(r"\s*ctx\.data\?*\.hits\?*\.total\?*\.value(?:\s*(?:\|\||\?\?)\s*0)?\s*", total_binding, re.IGNORECASE)) and count_expression == "total"
588
+ residual_frontend_prefix = frontend_top_level_prefix
589
+ if hits_binding_match: residual_frontend_prefix = residual_frontend_prefix.replace(hits_binding_match.group(0), "", 1)
590
+ if total_binding_match: residual_frontend_prefix = residual_frontend_prefix.replace(total_binding_match.group(0), "", 1)
591
+ has_readonly_frontend_inputs = not re.search(r"\bhits\b|\brows\b|\bctx\s*\[", residual_frontend_prefix, re.IGNORECASE)
592
+ has_disallowed_frontend_loop = bool(
593
+ re.search(r"\.(?:forEach|reduce|filter)\s*\(|for\s*\([^)]*\b(?:of|in)\b", frontend_code)
594
+ ) or any(receiver != "hits" for receiver in map_receivers) or bool(
595
+ re.search(r"\)\s*\.\s*map\s*\(", frontend_code, re.IGNORECASE)
596
+ ) or bool(re.search(r"\[\s*\]\s*\(", frontend_code)) or (bool(map_receivers) and not has_only_trusted_result_map)
597
+ top_level_prefix = top_level_prefix_before(pagination_code, returned_query)
598
+ top_level_const_declarations = list(re.finditer(r"\bconst\s+([A-Za-z_$][\w$]*)\s*=\s*([^;]+);?", top_level_prefix))
599
+ residual_pagination_prefix = top_level_prefix
600
+ for declaration in top_level_const_declarations:
601
+ residual_pagination_prefix = residual_pagination_prefix.replace(declaration.group(0), "", 1)
602
+ residual_pagination_prefix = re.sub(r"\breturn\s*$", "", residual_pagination_prefix)
603
+ has_only_const_pagination_prefix = not residual_pagination_prefix.strip() and all(
604
+ declaration.group(1) not in ("ctx", "Number") for declaration in top_level_const_declarations
605
+ )
606
+ def assignment(name: str) -> str:
607
+ match = re.search(rf"\bconst\s+{re.escape(name)}\s*=\s*([^;]+)", top_level_prefix)
608
+ if not match:
609
+ return ""
610
+ remaining = top_level_prefix[match.end():]
611
+ if re.search(rf"(?:^|[;\n])\s*{re.escape(name)}\s*=", remaining):
612
+ return ""
613
+ return match.group(1)
614
+
615
+ def unwrap_number(expression: str) -> str:
616
+ value = expression.strip()
617
+ match = re.fullmatch(r"Number\s*\(([\s\S]*)\)", value)
618
+ return (match.group(1) if match else value).strip()
619
+
620
+ def safe_fallback(expression: str, source: re.Pattern[str]) -> bool:
621
+ terms = [term.strip() for term in re.split(r"\|\||\?\?", unwrap_number(expression))]
622
+ if not any(source.fullmatch(term) for term in terms):
623
+ return False
624
+ return all(
625
+ source.fullmatch(term) or (term.isdigit() and 0 < int(term) <= 1000)
626
+ for term in terms
627
+ )
628
+
629
+ def safe_const_expression(expression: str, source: re.Pattern[str], seen: set[str] | None = None) -> bool:
630
+ value = expression.strip()
631
+ if re.fullmatch(r"[A-Za-z_$][\w$]*", value):
632
+ visited = seen or set()
633
+ if value in visited:
634
+ return False
635
+ binding = assignment(value)
636
+ return bool(binding) and safe_const_expression(binding, source, visited | {value})
637
+ return safe_fallback(value, source)
638
+
639
+ def safe_from_expression(expression: str) -> bool:
640
+ value = expression.strip()
641
+ offset_source = re.compile(r"ctx\.pageInfo\?*\.offset")
642
+ if safe_const_expression(value, offset_source):
643
+ return True
644
+ formula = re.fullmatch(r"\(\s*([A-Za-z_$][\w$]*)\s*-\s*1\s*\)\s*\*\s*([A-Za-z_$][\w$]*)", value)
645
+ if not formula:
646
+ return False
647
+ page_source = re.compile(r"ctx\.pageInfo\?*\.(?:page|pageIndex|current)")
648
+ size_source = re.compile(r"(?:ctx\.pageInfo\?*\.pageSize|ctx\.config\?*\.page_size|cfg\.page_size)")
649
+ return safe_const_expression(formula.group(1), page_source) and safe_const_expression(formula.group(2), size_source)
650
+
651
+ def unique_field(name: str) -> str:
652
+ values = returned_fields.get(name, []) if returned_fields else []
653
+ return values[0] if len(values) == 1 else ""
654
+ size_source = re.compile(r"(?:ctx\.pageInfo\?*\.pageSize|ctx\.config\?*\.page_size|cfg\.page_size)")
655
+ page_source = re.compile(r"ctx\.pageInfo\?*\.(?:page|pageIndex|current)")
656
+ offset_source = re.compile(r"ctx\.pageInfo\?*\.offset")
657
+ has_controlled_from = safe_from_expression(unique_field("from"))
658
+ has_controlled_size = safe_const_expression(unique_field("size"), size_source)
659
+ cfg_binding = assignment("cfg")
660
+ has_trusted_cfg_binding = not re.search(r"\bcfg\.page_size\b", top_level_prefix) or bool(
661
+ re.fullmatch(r"ctx\.config(?:\s*\|\|\s*)?", cfg_binding.strip())
662
+ )
663
+ def canonical_pagination_declaration(declaration: re.Match[str]) -> bool:
664
+ name = declaration.group(1)
665
+ expression = declaration.group(2)
666
+ if name == "cfg":
667
+ return bool(re.fullmatch(r"ctx\.config(?:\s*\|\|\s*)?", expression.strip()))
668
+ if name == "pageSize":
669
+ return safe_const_expression(expression, size_source)
670
+ if name == "page":
671
+ return safe_const_expression(expression, page_source)
672
+ if name == "offset":
673
+ return safe_const_expression(expression, offset_source)
674
+ return False
675
+ has_canonical_pagination_declarations = all(canonical_pagination_declaration(item) for item in top_level_const_declarations)
676
+ has_server_pagination = (
677
+ has_controlled_from
678
+ and has_controlled_size
679
+ and has_only_const_pagination_prefix
680
+ and has_trusted_cfg_binding
681
+ and has_canonical_pagination_declarations
682
+ and unique_field("track_total_hits").lower() == "true"
683
+ and has_trusted_hits_binding
684
+ and has_trusted_total_binding
685
+ and has_readonly_frontend_inputs
686
+ and has_only_trusted_result_map
687
+ and not has_disallowed_frontend_loop
688
+ )
689
+ if has_frontend_detail_access and has_metric and not has_aggregation and not has_server_pagination:
456
690
  errors.append(f"{module_name} must use ES size: 0 with aggs/aggregations instead of frontend row counting")
457
691
 
458
692
 
@@ -339,6 +339,264 @@ class ConsoleTemplateEditorTests(unittest.TestCase):
339
339
  self.assertFalse(lint["ok"])
340
340
  self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
341
341
 
342
+ def test_lint_allows_table_es_server_pagination_with_current_page_mapping(self) -> None:
343
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
344
+ work["modules"][1]["config"]["dataSource"] = (
345
+ "const cfg = ctx.config || {}; "
346
+ "const pageSize = Number(ctx.pageInfo?.pageSize || cfg.page_size || 20); "
347
+ "const page = Number(ctx.pageInfo?.page || 1); "
348
+ "return { driver: 'es', data_set_key: 'demo_dataset', "
349
+ "from: (page - 1) * pageSize, size: pageSize, track_total_hits: true };"
350
+ )
351
+ work["modules"][1]["config"]["config"] = (
352
+ "const hits = ctx.data?.hits?.hits || []; "
353
+ "const total = ctx.data?.hits?.total?.value || 0; "
354
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
355
+ )
356
+
357
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
358
+
359
+ self.assertTrue(lint["ok"], lint["errors"])
360
+
361
+ def test_lint_rejects_frontend_aggregation_mixed_with_server_pagination(self) -> None:
362
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
363
+ work["modules"][1]["config"]["dataSource"] = (
364
+ "return { driver: 'es', data_set_key: 'demo_dataset', "
365
+ "from: 0, size: pageSize, track_total_hits: true };"
366
+ )
367
+ work["modules"][1]["config"]["config"] = (
368
+ "const hits = ctx.data?.hits?.hits || []; "
369
+ "const total = ctx.data?.hits?.total?.value || 0; "
370
+ "const totalAmount = hits.reduce((sum, hit) => sum + Number(hit._source.amount || 0), 0); "
371
+ "return { data: hits.map(hit => hit._source), cols: [], totalAmount, pageInfo: { count: total } };"
372
+ )
373
+
374
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
375
+
376
+ self.assertFalse(lint["ok"])
377
+ self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
378
+
379
+ def test_lint_rejects_unbounded_variable_size_as_server_pagination(self) -> None:
380
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
381
+ work["modules"][1]["config"]["dataSource"] = (
382
+ "return { driver: 'es', data_set_key: 'demo_dataset', "
383
+ "from: 0, size: total, track_total_hits: true };"
384
+ )
385
+ work["modules"][1]["config"]["config"] = (
386
+ "const hits = ctx.data?.hits?.hits || []; "
387
+ "const total = ctx.data?.hits?.total?.value || 0; "
388
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
389
+ )
390
+
391
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
392
+
393
+ self.assertFalse(lint["ok"])
394
+ self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
395
+
396
+ def test_lint_rejects_pagination_named_variables_without_controlled_bindings(self) -> None:
397
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
398
+ work["modules"][1]["config"]["dataSource"] = (
399
+ "const offset = 0; const pageSize = total; "
400
+ "return { driver: 'es', data_set_key: 'demo_dataset', "
401
+ "from: offset, size: pageSize, track_total_hits: true };"
402
+ )
403
+ work["modules"][1]["config"]["config"] = (
404
+ "const hits = ctx.data?.hits?.hits || []; "
405
+ "const total = ctx.data?.hits?.total?.value || 0; "
406
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
407
+ )
408
+
409
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
410
+
411
+ self.assertFalse(lint["ok"])
412
+ self.assertTrue(any("frontend row counting" in err for err in lint["errors"]))
413
+
414
+ def test_lint_rejects_reassigned_or_case_colliding_pagination_bindings(self) -> None:
415
+ unsafe_sources = (
416
+ "let pageSize = ctx.pageInfo?.pageSize; pageSize = total; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
417
+ "const pagesize = ctx.pageInfo?.pageSize; const pageSize = total; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
418
+ "const pageSize = ctx.pageInfo?.pageSize || total; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
419
+ "const pageSize = ctx.pageInfo?.pageSize * 0 + 1000000; const offset = ctx.pageInfo?.offset; return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };",
420
+ )
421
+ for source in unsafe_sources:
422
+ with self.subTest(source=source):
423
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
424
+ work["modules"][1]["config"]["dataSource"] = source
425
+ work["modules"][1]["config"]["config"] = (
426
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
427
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
428
+ )
429
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
430
+ self.assertFalse(lint["ok"])
431
+
432
+ def test_lint_rejects_safe_looking_pagination_bindings_inside_comments_or_strings(self) -> None:
433
+ prefixes = (
434
+ "// const pageSize = ctx.pageInfo?.pageSize || 20;\n",
435
+ "/* const pageSize = ctx.pageInfo?.pageSize || 20; */ ",
436
+ 'const decoy = "const pageSize = ctx.pageInfo?.pageSize || 20;"; ',
437
+ )
438
+ for prefix in prefixes:
439
+ with self.subTest(prefix=prefix):
440
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
441
+ work["modules"][1]["config"]["dataSource"] = (
442
+ prefix + "const pageSize = 1000000; const offset = ctx.pageInfo?.offset; "
443
+ "return { driver: 'es', data_set_key: 'demo_dataset', from: offset, size: pageSize, track_total_hits: true };"
444
+ )
445
+ work["modules"][1]["config"]["config"] = (
446
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
447
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
448
+ )
449
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
450
+ self.assertFalse(lint["ok"])
451
+
452
+ def test_lint_rejects_aggregation_comments_and_decoy_query_objects(self) -> None:
453
+ unsafe_sources = (
454
+ "// aggs: {}, size: 0\nreturn { driver: 'es', data_set_key: 'demo_dataset', from: 0, size: 1000000, track_total_hits: true };",
455
+ "const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; "
456
+ "const decoy = { from: offset, size: pageSize, track_total_hits: true }; "
457
+ "return { driver: 'es', data_set_key: 'demo_dataset', from: 0, size: 1000000, track_total_hits: true };",
458
+ )
459
+ for source in unsafe_sources:
460
+ with self.subTest(source=source):
461
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
462
+ work["modules"][1]["config"]["dataSource"] = source
463
+ work["modules"][1]["config"]["config"] = (
464
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
465
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
466
+ )
467
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
468
+ self.assertFalse(lint["ok"])
469
+
470
+ def test_lint_rejects_ambiguous_query_structure_and_frontend_map_side_effects(self) -> None:
471
+ unsafe_sources = (
472
+ "const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true, size: 1000000 };",
473
+ "const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true, ...unsafe };",
474
+ "const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; { const pageSize = 1000000; return { from: offset, size: pageSize, track_total_hits: true }; }",
475
+ "const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true, 'size': 1000000 };",
476
+ "const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; const size = 1000000; return { from: offset, size: pageSize, track_total_hits: true, size };",
477
+ )
478
+ for source in unsafe_sources:
479
+ with self.subTest(source=source):
480
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
481
+ work["modules"][1]["config"]["dataSource"] = source
482
+ work["modules"][1]["config"]["config"] = (
483
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
484
+ "return { data: hits.map(hit => hit._source), cols: [], pageInfo: { count: total } };"
485
+ )
486
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
487
+ self.assertFalse(lint["ok"])
488
+
489
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
490
+ work["modules"][1]["config"]["dataSource"] = (
491
+ "const pageSize = Number(ctx.pageInfo?.pageSize || 20); const offset = ctx.pageInfo?.offset; "
492
+ "return { from: offset, size: pageSize, track_total_hits: true };"
493
+ )
494
+ work["modules"][1]["config"]["config"] = (
495
+ "let total = 0; ctx.rows.map(row => { total += row.amount || 0; }); "
496
+ "// hits.map( pageInfo: { count:\nreturn { data: ctx.rows, total };"
497
+ )
498
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
499
+ self.assertFalse(lint["ok"])
500
+
501
+ unsafe_frontend_scripts = (
502
+ "const hits = ctx.rows; let total = 0; const data = hits.map(row => { total += row.amount || 0; return row; }); return { data, pageInfo: { count: total } };",
503
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; (ctx.rows).map(row => row.amount); return { data: hits.map(hit => hit._source), pageInfo: { count: total } };",
504
+ "const hits = ctx.data?.hits?.hits || []; let total = 0; const data = hits.map(row => { total = total + Number(row._source.amount || 0); return row._source; }); return { data, pageInfo: { count: total } };",
505
+ "const hits = ctx.data?.hits?.hits || []; let total = 0; { const hits = ctx.rows; const data = hits.map(row => { total = total + row.amount; return row; }); return { data, pageInfo: { count: total } }; }",
506
+ "let total = 0; ctx.rows['forEach'](row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
507
+ "return [{ title: '项目数', amount: ctx.rows.length, icon: 'total' }];",
508
+ "let total = 0; const each = 'forEach'; ctx.rows[each](row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
509
+ "let total = 0; ctx.rows['for' + 'Each'](row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
510
+ "let total = 0; Array.prototype.forEach.call(ctx.rows, row => { total += row.amount || 0; }); return { data: ctx.rows, total };",
511
+ "const hits = ctx.data?.hits?.hits || []; return { decoy: hits.map(hit => hit._source), data: ctx.rows, pageInfo: { count: ctx.rows.length } };",
512
+ "return [{ title: '项目数', amount: ctx['rows'].length, icon: 'total' }];",
513
+ "const { rows } = ctx; return [{ title: '项目数', amount: rows.length, icon: 'total' }];",
514
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; hits.push(...ctx.rows); return { data: hits.map(hit => hit._source), pageInfo: { count: total } };",
515
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; hits.map = () => ctx.rows; return { data: hits.map(hit => hit._source), pageInfo: { count: total } };",
516
+ )
517
+ for script in unsafe_frontend_scripts:
518
+ with self.subTest(script=script):
519
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
520
+ work["modules"][1]["config"]["dataSource"] = (
521
+ "const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; "
522
+ "return { from: offset, size: pageSize, track_total_hits: true };"
523
+ )
524
+ work["modules"][1]["config"]["config"] = script
525
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
526
+ self.assertFalse(lint["ok"])
527
+
528
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
529
+ work["modules"][1]["config"]["dataSource"] = (
530
+ "const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; "
531
+ "return { 'from': offset, 'size': pageSize, 'track_total_hits': true };"
532
+ )
533
+ work["modules"][1]["config"]["config"] = (
534
+ "const hits = ctx.data?.hits?.hits || []; const total = ctx.data?.hits?.total?.value || 0; "
535
+ "return { data: hits.map(hit => hit._source), pageInfo: { count: total } };"
536
+ )
537
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
538
+ self.assertTrue(lint["ok"], lint["errors"])
539
+
540
+ for source in (
541
+ "const cfg = { page_size: 1000000 }; const pageSize = cfg.page_size; const offset = ctx.pageInfo?.offset; return { from: offset, size: pageSize, track_total_hits: true };",
542
+ "ctx.pageInfo.pageSize = 1000000; const pageSize = ctx.pageInfo.pageSize; const offset = ctx.pageInfo.offset; return { from: offset, size: pageSize, track_total_hits: true };",
543
+ "const evil = (ctx.pageInfo.pageSize = 1000000); const pageSize = ctx.pageInfo.pageSize; const offset = ctx.pageInfo.offset; return { from: offset, size: pageSize, track_total_hits: true };",
544
+ "const evil = ctx.rows.reduce((value, row) => value + row.amount, 0); const pageSize = ctx.pageInfo.pageSize; const offset = ctx.pageInfo.offset; return { from: offset, size: pageSize, track_total_hits: true };",
545
+ ):
546
+ with self.subTest(source=source):
547
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
548
+ work["modules"][1]["config"]["dataSource"] = source
549
+ work["modules"][1]["config"]["config"] = (
550
+ "const hits = ctx.data?.hits?.hits ?? []; const total = ctx.data?.hits?.total?.value ?? 0; "
551
+ "return { data: hits.map((hit) => hit._source), pageInfo: { count: total } };"
552
+ )
553
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
554
+ self.assertFalse(lint["ok"])
555
+
556
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
557
+ work["modules"][1]["config"]["dataSource"] = (
558
+ "const pageSize = ctx.pageInfo?.pageSize; const offset = ctx.pageInfo?.offset; "
559
+ "return { from: offset, size: pageSize, track_total_hits: true };"
560
+ )
561
+ work["modules"][1]["config"]["config"] = (
562
+ "const hits = ctx.data?.hits?.hits ?? []; const total = ctx.data?.hits?.total?.value ?? 0; "
563
+ "return { data: hits.map((hit) => hit._source), pageInfo: { count: total } };"
564
+ )
565
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
566
+ self.assertTrue(lint["ok"], lint["errors"])
567
+
568
+ def test_lint_does_not_accept_nested_object_size_zero_as_aggregation(self) -> None:
569
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
570
+ work["modules"][1]["config"]["dataSource"] = {"driver": "es", "size": 1000000, "note": {"size": 0}}
571
+ work["modules"][1]["config"]["config"] = (
572
+ "const rows = ctx.data?.hits?.hits || []; return rows.map(row => ({ title: row._source.name, amount: row._source.total }));"
573
+ )
574
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
575
+ self.assertFalse(lint["ok"])
576
+
577
+ for source in (
578
+ "return { driver: 'es', size: 1000000, aggs: null };",
579
+ "return { driver: 'es', size: 0, aggs: {}, size: 1000000 };",
580
+ ):
581
+ with self.subTest(source=source):
582
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
583
+ work["modules"][1]["config"]["dataSource"] = source
584
+ work["modules"][1]["config"]["config"] = (
585
+ "const rows = ctx.data?.hits?.hits || []; return rows.map(row => ({ title: row._source.name, amount: row._source.total }));"
586
+ )
587
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
588
+ self.assertFalse(lint["ok"])
589
+
590
+ work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
591
+ work["modules"][1]["config"]["dataSource"] = {
592
+ "driver": "es", "size": 0, "aggs": None, "aggregations": {}
593
+ }
594
+ work["modules"][1]["config"]["config"] = (
595
+ "const rows = ctx.data?.hits?.hits || []; return rows.map(row => ({ title: row._source.name, amount: row._source.total }));"
596
+ )
597
+ lint = lint_template_semantics(work, raw_payload=make_detail(), submit_payload=build_submit_payload(work))
598
+ self.assertTrue(lint["ok"], lint["errors"])
599
+
342
600
  def test_lint_rejects_object_project_list_waiver_to_match_typed_cli(self) -> None:
343
601
  work = detail_to_work_payload(make_detail(), workspace="store_mgr", mode="edit")
344
602
  work["modules"][0]["config"]["dataSource"] = {
@@ -29,6 +29,8 @@ description: "用于按 BPMAX 完整流程配置需求先调研、再出计划
29
29
 
30
30
  ## 核心原则
31
31
  - 这是编排型 skill,不重复实现各子 skill 的具体执行细节;它负责调研、计划、编排顺序、停机条件和结果闭环。
32
+ - 搭建前必须同时使用 [$bpmax-functional-test-design](../bpmax-functional-test-design/SKILL.md) 和 [$bpmax-ui-ux-audit](../bpmax-ui-ux-audit/SKILL.md) 思考主路径、分支、边界、状态、角色、表单信息架构、动作文案、错误恢复、状态反馈、可访问性和跨页一致性;把结论写入计划、任务书和各配置面的 typed config lint 检查项。
33
+ - 所有确认的体验问题都属于 `BUG`,设计期发现也不得降级为建议。配置 lint 通过不等于 UX/E2E 通过;配置完成后仍必须按双 skill 用例执行真实页面并通过 `bpmax-cli test-suite lint-report`。
32
34
  - 默认先进入计划模式;如果当前环境不能自动切换到计划模式,必须明确要求用户手动切换到计划模式,然后再继续。
33
35
  - 不直接开始执行。先把流程需求讲清楚,再把本次要做的配置面讲清楚,再看是否还缺高影响信息。
34
36
  - typed CLI 线上回读、实时接口返回和只读页面验收优先级高于本地 `think_*` 配置镜像;本地仓库只作为候选检索和结构参考。
@@ -178,6 +180,8 @@ bpmax-cli taskbook lint-prompt --prompt-source .codex/tmp/TASK_PROMPT.md
178
180
  - 哪些页面必须先在浏览器中打开
179
181
  - 哪些地方以 typed CLI 线上回读和只读页面验收为准
180
182
  - 新建场景使用哪个 typed create 命令、确认文本是什么、失败后停止在哪一步
183
+ - `bpmax-functional-test-design` 生成的主/备/异常/边界/状态/角色覆盖,以及 `bpmax-ui-ux-audit` 生成的界面体验 lint 清单
184
+ - 每个配置面的 typed config lint 如何吸收上述两份清单,最终如何进入双 skill E2E 和 `test-suite lint-report`
181
185
 
182
186
  ### 6. 计划后的执行编排
183
187
  - 用户切出计划模式并要求继续后,由同一个 skill 按计划推进。
@@ -193,6 +197,8 @@ bpmax-cli taskbook lint-prompt --prompt-source .codex/tmp/TASK_PROMPT.md
193
197
  - 最新配置同步:[$bpmax-config-latest](../bpmax-config-latest/SKILL.md)
194
198
  - AI 任务书:[$bpmax-ai-taskbook](../bpmax-ai-taskbook/SKILL.md)
195
199
  - 运行态验收:[$bpmax-e2e-flow-test-operator](../bpmax-e2e-flow-test-operator/SKILL.md)
200
+ - 功能用例设计:[$bpmax-functional-test-design](../bpmax-functional-test-design/SKILL.md)
201
+ - UI/UX 审计:[$bpmax-ui-ux-audit](../bpmax-ui-ux-audit/SKILL.md)
196
202
  - 若流程或表单需求依赖控件能力判断,先用 [$form-control-library](../form-control-library/SKILL.md)。
197
203
  - 若某一步要求浏览器已打开特定页面,而当前页面不对,必须先让用户打开到正确页面,不要盲目继续。
198
204
  - `flow-app create` 完成后,必须再执行工作区视角的只读验证:
@@ -1,4 +1,4 @@
1
1
  interface:
2
2
  display_name: "BPMAX E2E Flow Config Orchestrator"
3
- short_description: "先调研、出计划,再编排执行 BPMAX 完整流程配置"
4
- default_prompt: "使用 $bpmax-e2e-flow-config-orchestrator 先进入计划阶段,把 BPMAX 流程需求和配置范围调研清楚,生成执行计划后再按计划完成整套流程配置。"
3
+ short_description: "用功能与 UX 双门禁编排 BPMAX 完整流程配置"
4
+ default_prompt: "使用 $bpmax-e2e-flow-config-orchestrator 先调研和计划,并用 bpmax-functional-test-design、bpmax-ui-ux-audit 形成设计与 lint 门禁后完成整套流程配置。"
@@ -3,15 +3,17 @@
3
3
  ## 默认编排顺序
4
4
  - 完整流程配置:
5
5
  1. `bpmax-config-latest` -> `bpmax-cli config latest pull <env>`
6
- 2. `bpmax-flow-template-editor`
7
- 3. `bpmax-form-template-editor`
8
- 4. `bpmax-dataset-field-template-editor`
9
- 5. `bpmax-dataset-template-editor`
10
- 6. `bpmax-list-template-editor`
11
- 7. `bpmax-filter-template-editor`
12
- 8. `bpmax-nav-config-editor`
13
- 9. `bpmax-e2e-flow-test-operator` -> 真实浏览器运行态验收
14
- 10. `bpmax-config-latest` -> `bpmax-cli config latest pull <env>`
6
+ 2. 设计期双 skill gate:`bpmax-functional-test-design` + `bpmax-ui-ux-audit`,形成测试覆盖和界面体验 lint 清单
7
+ 3. `bpmax-flow-template-editor`
8
+ 4. `bpmax-form-template-editor`
9
+ 5. `bpmax-dataset-field-template-editor`
10
+ 6. `bpmax-dataset-template-editor`
11
+ 7. `bpmax-list-template-editor`
12
+ 8. `bpmax-filter-template-editor`
13
+ 9. `bpmax-nav-config-editor`
14
+ 10. `bpmax-e2e-flow-test-operator` -> 按双 skill 做真实浏览器运行态验收
15
+ 11. 交付期 lint-report gate:`bpmax-cli test-suite lint-report --root .ai_test/report/<run> --format json`
16
+ 12. `bpmax-config-latest` -> `bpmax-cli config latest pull <env>`
15
17
 
16
18
  ## 范围到 skill 的映射
17
19
  - 流程模板:`bpmax-flow-template-editor`
@@ -22,6 +24,8 @@
22
24
  - 筛选器模板:`bpmax-filter-template-editor`
23
25
  - 导航配置:`bpmax-nav-config-editor`
24
26
  - 运行态验收:`bpmax-e2e-flow-test-operator`
27
+ - 功能测试设计:`bpmax-functional-test-design`
28
+ - UI/UX BUG 审计:`bpmax-ui-ux-audit`
25
29
  - 控件判断:`form-control-library`
26
30
  - 环境同步:`bpmax-config-latest` -> `bpmax-cli config latest pull <env>`
27
31