Release v1.0.120: document bind.visibleWhen for row menu visibility
All checks were successful
技能自动化发布 / release (push) Successful in 7s

This commit is contained in:
2026-09-29 20:41:23 +08:00
parent c49fcba157
commit afe0788488
13 changed files with 215 additions and 58 deletions

View File

@@ -74,7 +74,14 @@ def _validate_bind_tables(action_id: str, bind: object) -> list[str]:
errors: list[str] = []
if not isinstance(bind, dict):
return [f"{action_id}: bind must be object"]
allowed = {"tables", "inputMapping", "columnMapping", "labelColumn", "selectionMode"}
allowed = {
"tables",
"inputMapping",
"columnMapping",
"labelColumn",
"selectionMode",
"visibleWhen",
}
unknown = set(bind.keys()) - allowed
if unknown:
errors.append(f"{action_id}: bind only allows {sorted(allowed)}, got {sorted(bind.keys())}")
@@ -103,6 +110,9 @@ def _validate_bind_tables(action_id: str, bind: object) -> list[str]:
errors.append(
f"{action_id}: bind.selectionMode must be required|none|optional, got {selection_mode!r}"
)
visible_when = bind.get("visibleWhen")
if visible_when is not None and (not isinstance(visible_when, dict) or not visible_when):
errors.append(f"{action_id}: bind.visibleWhen must be a non-empty object")
return errors
@@ -522,6 +532,51 @@ class TestActionsManifest(unittest.TestCase):
}
jsonschema.validate(instance=manifest, schema=schema)
def test_schema_allows_bind_visible_when(self) -> None:
try:
import jsonschema
except ImportError:
self.fail("jsonschema is required")
schema = _load_actions_schema()
bind_props = schema["$defs"]["bind"]["properties"]
self.assertIn("visibleWhen", bind_props)
self.assertIn("visibleWhenRule", schema["$defs"])
manifest = {
"schemaVersion": 1,
"skill": "your-skill-slug",
"actions": [
{
"id": "probe-bind-visible-when",
"label": "采用",
"description": "验证 bind.visibleWhen 可通过 Schema",
"placements": ["row"],
"executionProfile": "sync",
"interaction": "direct",
"bind": {
"tables": ["demo_items"],
"visibleWhen": {
"field": "status",
"in": ["pending_review", "skipped"],
},
"inputMapping": {"itemId": "$row.$pk"},
},
"inputSchema": {
"type": "object",
"required": ["itemId"],
"properties": {
"itemId": {"type": "number", "readOnly": True},
},
},
"entrypoint": {
"type": "cli",
"command": "approve",
"args": ["--id", "{{itemId}}"],
},
}
],
}
jsonschema.validate(instance=manifest, schema=schema)
def test_action_examples_user_facing_copy_avoids_jargon(self) -> None:
"""示例 Action 的用户可见字符串不得含常见开发黑话(属性名本身除外)。"""
examples_dir = os.path.join(get_skill_root(), "assets", "examples")
@@ -740,6 +795,8 @@ class TestActionsManifest(unittest.TestCase):
"labelColumn",
"selectionMode",
"勾选驱动",
"行菜单显隐",
"bind.visibleWhen",
"用户可见文案",
"双受众",
"已选择",

View File

@@ -464,6 +464,7 @@ class TestDocsStandards(unittest.TestCase):
def test_visible_when_example_is_listed(self) -> None:
text = self._read("assets/examples/README.md")
self.assertIn("visible-when-action.example.json", text)
self.assertIn("bind-visible-when-row.action.example.json", text)
self.assertIn("selection-mode-optional.action.example.json", text)
self.assertIn("skill-cell-presentation.example.json", text)
self.assertIn("skill-grid-presentation.example.json", text)
@@ -475,15 +476,20 @@ class TestDocsStandards(unittest.TestCase):
self.assertIn("A4-9", checklist)
self.assertIn("selectionMode", checklist)
self.assertIn("A4-10", checklist)
self.assertIn("A4-11", checklist)
self.assertIn("bind.visibleWhen", checklist)
self.assertIn("用户可见文案", checklist)
runtime = self._read("development/SKILL_ACTION_RUNTIME.md")
self.assertIn("visibleWhen", runtime)
self.assertIn("revealInForm", runtime)
self.assertIn("selectionMode", runtime)
self.assertIn("bind.visibleWhen", runtime)
self.assertIn("用户可见文案", runtime)
actions = self._read("references/ACTIONS.md")
self.assertIn("用户可见文案", actions)
self.assertIn("双受众", actions)
self.assertIn("行菜单显隐", actions)
self.assertIn("bind.visibleWhen", actions)
def test_guarded_docs_do_not_reference_amazon_implementation(self) -> None:
forbidden = (