refine assembly editor styling and metadata

This commit is contained in:
2025-10-03 04:02:17 -06:00
parent 0e3304ef95
commit 22e149ed99
3 changed files with 321 additions and 200 deletions

View File

@@ -682,7 +682,8 @@ def _empty_assembly_document(default_type: str = "powershell") -> Dict[str, Any]
"category": "application" if (default_type or "").lower() == "ansible" else "script",
"type": default_type or "powershell",
"script": "",
"timeout_seconds": 0,
"script_lines": [],
"timeout_seconds": 3600,
"sites": {"mode": "all", "values": []},
"variables": [],
"files": []
@@ -703,12 +704,21 @@ def _normalize_assembly_document(obj: Any, default_type: str, base_name: str) ->
if typ in ("powershell", "batch", "bash", "ansible"):
doc["type"] = typ
script_val = obj.get("script")
if isinstance(script_val, str):
script_lines = obj.get("script_lines")
if isinstance(script_lines, list):
try:
doc["script"] = "\n".join(str(line) for line in script_lines)
except Exception:
doc["script"] = ""
elif isinstance(script_val, str):
doc["script"] = script_val
else:
content_val = obj.get("content")
if isinstance(content_val, str):
doc["script"] = content_val
normalized_script = (doc["script"] or "").replace("\r\n", "\n")
doc["script"] = normalized_script
doc["script_lines"] = normalized_script.split("\n") if normalized_script else []
timeout_val = obj.get("timeout_seconds", obj.get("timeout"))
if timeout_val is not None:
try:
@@ -786,7 +796,9 @@ def _load_assembly_document(abs_path: str, island: str, type_hint: str = "") ->
content = ""
doc = _empty_assembly_document(default_type)
doc["name"] = base_name
doc["script"] = content
normalized_script = (content or "").replace("\r\n", "\n")
doc["script"] = normalized_script
doc["script_lines"] = normalized_script.split("\n") if normalized_script else []
if default_type == "ansible":
doc["category"] = "application"
return doc