bpmax-cli 0.2.1-beta.58 → 0.2.1-beta.59

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.
@@ -0,0 +1,3 @@
1
+ # Source contract
2
+
3
+ 维护者从前端 `riIconList` 导出生成 `assets/ri-icons.json`。分发后的 CLI 只读取该 JSON,不要求用户拥有前端 checkout。
@@ -51,6 +51,7 @@ description: "用于通过 bpmax-cli typed config 创建或编辑 BPMAX 项目
51
51
  10. 高风险改动必须以真实用户身份打开运行态列表页,只读验证目标列、操作按钮、图标/头像/badge/图片预览、筛选和 console/network 错误;不得把接口提交伪装成页面回归。
52
52
 
53
53
  ## 核心配置门禁
54
+ - 任何 icon 选择或修改前,必须先读取 `../bpmax-icon-catalog/SKILL.md` 并运行 `bpmax-cli icon search/get/validate`;只使用 catalog 返回的完整 class。
54
55
  - 列表模板是 `flow_page_template.type = 1`,主体是 `content: JSON.stringify({ level, config })`;不是表单模板,不使用 `rule/value/field_type/publish`。
55
56
  - 当项目列表为空时,先查流程 `meta.table_list_template` 和 `GET /api/flow_page_template?flow_type=<flow_type>&type=1`,不要直接归因到 ES 数据为空。
56
57
  - 列表模板 `data_set_id` 必须指向当前流程实际发布并可刷新的数据集;切换数据集后必须重新检查所有字段 key。
@@ -98,7 +99,7 @@ description: "用于通过 bpmax-cli typed config 创建或编辑 BPMAX 项目
98
99
  - 若使用 `disabled`,必须反向写成 `return !ctx.$CAN_DELETE`;不得把 `confirm`、`onClick` 或事件脚本当成权限 guard。
99
100
  - 项目状态可以作为额外业务限制,但不能替代权限 guard;禁止要求 `current_flow_step_id/name` 为空,创建即进入首节点的流程会使该条件恒为 false。
100
101
  - 操作列列根不得配置 `icon` / `iconColor`;每个操作按钮必须带按钮级 icon。
101
- - icon 必须写完整 class:`ri ri_*`;普通数据列至少 1 列、最多 3 列带 icon。
102
+ - icon 必须写完整且存在于 catalog 的 class:`ri ri_<name-with-hyphens>`,例如 `ri ri_bank-line`;普通数据列至少 1 列、最多 3 列带 icon。
102
103
  - 人员列必须渲染头像,优先 `el-avatar + span`;只显示姓名文本不合格。
103
104
  - 至少一个非操作数据列必须自适应:不写 `props.width`,可用 `props.minWidth` 保证最低可读宽度;操作/选择/序号列不计入自适应列。
104
105
  - 固定数据列可只写 `width`;需要同时约束下限时再写 `minWidth`,并保证 `minWidth <= width`。标题必须能在列宽内完整展示,禁止 `auto`、百分比、非正数等不可验证宽度。
@@ -184,6 +184,7 @@ description: "用于通过 bpmax-cli typed config 创建或编辑 BPMAX PC导航
184
184
  - 如果用户提供的是跨工作区路径,默认不擅自改写 workspace 前缀。
185
185
 
186
186
  ### 7. Icon 规则
187
+ - 开始选 icon 前必须读取 `../bpmax-icon-catalog/SKILL.md`,先用 `bpmax-cli icon search` 获取候选并用 `icon validate` 校验;只提交 catalog 返回的完整 class。
187
188
  - 不要凭源码文件名或历史配置猜 icon 格式。
188
189
  - 必须优先以当前页面弹窗里的图标选择器为准,直接读取界面上实际可选的 icon。
189
190
  - 当前页面实际可选图标来自 `IconPicker` 弹窗,而不是旧版 `iconList` 下拉。
@@ -1,12 +1,39 @@
1
1
  ---
2
2
  name: bpmax-plugin-config
3
3
  version: 1.0.0
4
- description: Discover BPMAX plugin-scoped Agent skills and install them explicitly with bpmax-cli.
4
+ description: Manage BPMAX plugin activation, plugin-scoped Agent skills, and plugin-owned configuration through typed bpmax-cli workflows.
5
5
  ---
6
6
 
7
7
  # BPMAX Plugin Config
8
8
 
9
- Use this skill when a BPMAX task involves a plugin-provided capability and the exact plugin-specific skill may need to be discovered, installed, or updated locally first.
9
+ Use this skill when a BPMAX task involves installing or activating a plugin, discovering its Agent Skill, or changing plugin-owned configuration.
10
+
11
+ ## Distinguish the four plugin states
12
+
13
+ - **Installed** means the organization has the plugin package. It does not mean the plugin is active in any workspace.
14
+ - **Activated** means the installed plugin is effective in selected workspaces. Organization defaults are mandatory in every existing and future workspace and cannot be disabled from one workspace.
15
+ - **Skill installed** means the current Agent has the plugin's local instructions, lint, and config adapters. It does not activate the runtime plugin.
16
+ - **Configured** means plugin-owned business settings have been written after activation and Skill discovery. Activation does not create those settings.
17
+
18
+ ## Activation flow
19
+
20
+ 1. Read the centralized activation overview before changing anything:
21
+
22
+ ```bash
23
+ bpmax-cli plugin activation overview --profile <profile> --format json
24
+ ```
25
+
26
+ 2. Choose one typed mutation scope and review its dry-run:
27
+
28
+ ```bash
29
+ bpmax-cli plugin activation workspace set --workspace <workspace> --plugin <plugin_name> --profile <profile> --format json
30
+ bpmax-cli plugin activation plugin set-workspaces --plugin <plugin_name> --workspace <workspace> --profile <profile> --format json
31
+ bpmax-cli plugin activation defaults set --plugin <plugin_name> --profile <profile> --format json
32
+ ```
33
+
34
+ 3. After the user accepts the displayed scope, repeat the same command with `--confirm`. The CLI must submit through `config.plugin.activation.submit`, read back `config.plugin.activation.export`, and return `readback_confirmed: true`.
35
+
36
+ 4. Only after effective activation is proven should the Agent install/update the plugin Skill and edit plugin-owned configuration.
10
37
 
11
38
  ## Automatic discovery
12
39
 
@@ -36,6 +63,12 @@ bpmax-cli plugin skills ensure <plugin_name> --profile <profile> --agent codex -
36
63
 
37
64
  ## Safety Rules
38
65
 
66
+ - Do not confuse plugin installation, workspace activation, local Skill installation, and plugin configuration.
67
+ - Never infer activation from an installed plugin row or a local Skill directory. Use `plugin activation overview`.
68
+ - A workspace mutation cannot remove an organization default plugin. Do not generate a single-workspace disable attempt for `default_active: true`.
69
+ - Setting organization defaults affects all existing and future workspaces. Always show the dry-run scope before using `--confirm`.
70
+ - A successful PUT is not completion. Require typed overview readback and report `submitted_readback_mismatch` as an unresolved remote mutation, not as success.
71
+ - Removing a plugin from organization defaults does not prove it is disabled in every workspace; inspect the returned effective workspace activation.
39
72
  - Do not assume plugin installation also installed local Agent skills.
40
73
  - Do not manually copy plugin skill folders unless `bpmax-cli plugin skills ensure` fails and the user explicitly approves a fallback.
41
74
  - Treat `config.plugin.*` capabilities like other BPMAX configuration capabilities: they require an authorized profile and organization-admin configuration access.
@@ -55,4 +88,5 @@ bpmax-cli plugin skills check --profile <profile> --agent codex --format json
55
88
  bpmax-cli plugin skills ensure <plugin_name> --profile <profile> --agent codex --format json
56
89
  bpmax-cli plugin skills update <plugin_name> --profile <profile> --agent codex --format json
57
90
  bpmax-cli plugin skills state --profile <profile> --agent codex --format json
91
+ bpmax-cli plugin activation overview --profile <profile> --format json
58
92
  ```
@@ -524,22 +524,45 @@ function isMockActionRevealRequired(error) {
524
524
  return /identity_action_(?:label_not_found|not_visible)/.test(message);
525
525
  }
526
526
 
527
+ function cssAttributeValue(value) {
528
+ return String(value).replace(/\\/g, '\\\\').replace(/"/g, '\\"');
529
+ }
530
+
527
531
  async function inspectExactTargetAction(tab, request, labels, timeoutMs) {
528
532
  const targetUserId = String(request.target_user_id);
529
533
  const targetUserName = String(request.target_user_name).trim();
530
- return tab.playwright.evaluate(async ({ id, name, buttonLabels, waitMs, stableMs }) => {
534
+ return tab.playwright.evaluate(async ({ id, name, buttonLabels, waitMs, stableMs, managementUrl }) => {
535
+ const trusted = new URL(managementUrl);
536
+ const workspaceMatch = trusted.pathname.match(/^\/w:([^/]+)(?:\/|$)/);
537
+ const allowedProfilePaths = new Set(['/userProfileEditor', '/userProfileEditor/']);
538
+ if (workspaceMatch) {
539
+ allowedProfilePaths.add(`/w:${workspaceMatch[1]}/userProfileEditor`);
540
+ allowedProfilePaths.add(`/w:${workspaceMatch[1]}/userProfileEditor/`);
541
+ }
542
+ const trustedProfileId = (href) => {
543
+ try {
544
+ const url = new URL(href, trusted.origin);
545
+ if (url.origin !== trusted.origin || !allowedProfilePaths.has(url.pathname)) return null;
546
+ const value = Number(url.searchParams.get('id'));
547
+ return Number.isSafeInteger(value) && value > 0 ? String(value) : null;
548
+ } catch {
549
+ return null;
550
+ }
551
+ };
531
552
  const inspect = () => {
532
553
  const input = document.querySelector('.button-line > .el-input input');
533
- const rows = Array.from(document.querySelectorAll('tbody tr')).filter((row) => (
534
- Array.from(row.querySelectorAll('td')).some((cell) => String(cell.textContent || '').trim() === id)
554
+ const allRows = Array.from(document.querySelectorAll('tbody tr'));
555
+ const rows = allRows.filter((row) => Array.from(row.querySelectorAll('a[href]')).some(
556
+ (anchor) => trustedProfileId(anchor.getAttribute('href')) === id,
535
557
  ));
536
558
  if (rows.length !== 1) {
537
559
  return { status: rows.length > 1 ? 'ambiguous' : 'missing', row_count: rows.length };
538
560
  }
539
561
  const row = rows[0];
540
- const idCount = Array.from(row.querySelectorAll('td')).filter(
541
- (cell) => String(cell.textContent || '').trim() === id,
542
- ).length;
562
+ const profileLinks = Array.from(row.querySelectorAll('a[href]')).filter(
563
+ (anchor) => trustedProfileId(anchor.getAttribute('href')) === id,
564
+ );
565
+ const idCount = profileLinks.length;
543
566
  const nameNodes = Array.from(row.querySelectorAll('.user-name-text'));
544
567
  const actualName = nameNodes.length === 1 ? String(nameNodes[0].textContent || '').trim() : null;
545
568
  const buttons = Array.from(row.querySelectorAll('button')).filter(
@@ -577,6 +600,8 @@ async function inspectExactTargetAction(tab, request, labels, timeoutMs) {
577
600
  action_label: actionLabel,
578
601
  button_count: buttons.length,
579
602
  input_value: String(input?.value || ''),
603
+ row_index: allRows.indexOf(row),
604
+ profile_href: profileLinks.length === 1 ? profileLinks[0].getAttribute('href') : null,
580
605
  };
581
606
  };
582
607
 
@@ -604,6 +629,7 @@ async function inspectExactTargetAction(tab, request, labels, timeoutMs) {
604
629
  id: targetUserId,
605
630
  name: targetUserName,
606
631
  buttonLabels: labels.simulation,
632
+ managementUrl: request.user_management_url,
607
633
  waitMs: timeoutMs,
608
634
  stableMs: 750,
609
635
  }, { timeoutMs: timeoutMs + 5_000 });
@@ -619,16 +645,15 @@ async function resolveExactTargetAction(tab, request, labels, timeoutMs) {
619
645
  if (state.status === 'action_disabled') throw new Error('identity_action_disabled');
620
646
  if (state.status !== 'ready') return { state, resolved: null };
621
647
 
622
- const targetUserId = String(request.target_user_id);
623
648
  const targetUserName = String(request.target_user_name).trim();
624
- const row = tab.playwright
625
- .locator('tbody tr')
626
- .filter({
627
- has: tab.playwright.getByText(targetUserId, { exact: true }),
628
- hasText: targetUserName,
629
- });
630
- if (await row.count() !== 1
631
- || await row.getByText(targetUserId, { exact: true }).count() !== 1
649
+ const profileHref = String(state.profile_href || '');
650
+ const profileId = profileHref ? profileRouteUserId(new URL(profileHref, request.origin).toString(), request.user_management_url) : null;
651
+ const row = profileHref
652
+ ? tab.playwright.locator(`tbody tr:has(a[href="${cssAttributeValue(profileHref)}"])`)
653
+ : null;
654
+ if (!row
655
+ || profileId !== request.target_user_id
656
+ || await row.count() !== 1
632
657
  || await row.locator('.user-name-text', {}).count() !== 1) {
633
658
  return { state: { ...state, status: 'overwritten' }, resolved: null };
634
659
  }
@@ -641,6 +666,7 @@ async function resolveExactTargetAction(tab, request, labels, timeoutMs) {
641
666
  resolved: {
642
667
  simulation,
643
668
  targetName: String(state.actual_name || '').trim(),
669
+ actionLabel: state.action_label,
644
670
  },
645
671
  };
646
672
  }
@@ -688,6 +714,22 @@ async function waitForExactTargetAction(tab, search, request, labels, actions) {
688
714
  throw new Error('identity_exact_user_row_count_0');
689
715
  }
690
716
 
717
+ async function clickUniqueVisibleAction(tab, actionLabels, fallbackLocator) {
718
+ if (!tab.dom_cua?.get_visible_dom || !tab.dom_cua?.click) {
719
+ await fallbackLocator.click({});
720
+ return;
721
+ }
722
+ const visibleDom = String(await tab.dom_cua.get_visible_dom());
723
+ const labelPattern = actionLabels
724
+ .map((label) => label.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
725
+ .join('|');
726
+ const matches = Array.from(visibleDom.matchAll(
727
+ new RegExp(`<button\\s+[^>]*node_id=["']?([^\\s"'>]+)["']?[^>]*>(?:(?!</button>)[\\s\\S])*(?:${labelPattern})(?:(?!</button>)[\\s\\S])*</button>`, 'g'),
728
+ ));
729
+ if (matches.length !== 1) throw new Error(`identity_visible_action_count_${matches.length}`);
730
+ await tab.dom_cua.click({ node_id: matches[0][1] });
731
+ }
732
+
691
733
  async function clickMock(tab, request, labels, actions, onMutationAttempt = async () => undefined) {
692
734
  await navigateAndWait(
693
735
  tab,
@@ -701,7 +743,7 @@ async function clickMock(tab, request, labels, actions, onMutationAttempt = asyn
701
743
  'identity_user_search',
702
744
  );
703
745
  actions.push(`search target user name and verify exact id ${request.target_user_id}`);
704
- const { simulation, targetName } = await waitForExactTargetAction(tab, search, request, labels, actions);
746
+ let { simulation, targetName } = await waitForExactTargetAction(tab, search, request, labels, actions);
705
747
  const simulationCount = await simulation.count();
706
748
  if (simulationCount !== 1) throw new Error(`identity_exact_simulation_button_count_${simulationCount}`);
707
749
  if (typeof simulation.isVisible === 'function' && !await simulation.isVisible()) {
@@ -711,14 +753,18 @@ async function clickMock(tab, request, labels, actions, onMutationAttempt = asyn
711
753
  throw new Error('identity_exact_simulation_button_disabled');
712
754
  }
713
755
  await dismissGuideBeforeMutation(tab, actions);
756
+ const beforeTrial = await resolveExactTargetAction(tab, request, labels, 1_000);
757
+ if (!beforeTrial.resolved) throw new Error('identity_exact_user_row_changed_before_click');
758
+ simulation = beforeTrial.resolved.simulation;
759
+ targetName = beforeTrial.resolved.targetName;
714
760
  await simulation.click({ trial: true });
715
761
  actions.push(`verify simulation action is clickable for exact user id ${request.target_user_id}`);
762
+ const beforeMutation = await resolveExactTargetAction(tab, request, labels, 1_000);
763
+ if (!beforeMutation.resolved) throw new Error('identity_exact_user_row_changed_before_click');
764
+ simulation = beforeMutation.resolved.simulation;
765
+ targetName = beforeMutation.resolved.targetName;
716
766
  await onMutationAttempt();
717
- const managementUrl = await tab.url();
718
- await tab.playwright.expectNavigation(
719
- () => simulation.click({}),
720
- { url: managementUrl, waitUntil: 'domcontentloaded', timeoutMs: ROUTE_READY_TIMEOUT_MS },
721
- );
767
+ await clickUniqueVisibleAction(tab, labels.simulation, simulation);
722
768
  actions.push(`click simulation for exact user id ${request.target_user_id}`);
723
769
  await navigateAndWait(
724
770
  tab,
@@ -4,6 +4,7 @@ description: "用于在 BPMAX 中创建、编辑、导出、验证或删除平
4
4
  ---
5
5
 
6
6
  # BPMAX Workspace Editor
7
+ - 若配置包含 icon,开始前先读取 `../bpmax-icon-catalog/SKILL.md`,通过 `bpmax-cli icon search/get/validate` 选择并校验,禁止猜名。
7
8
 
8
9
  ## 写入路径硬约束
9
10
  - 执行前必须先运行 `bpmax-cli config adapters --format json` 核对 `workspace`;只有 `export_status`、`build_status`、`submit_status`、`create_status`、`delete_status` 都是 `supported` 时,才允许进入真实写入。