MCPcopy Create free account
hub / github.com/danielmiessler/Fabric / bulk_edit_patterns

Function bulk_edit_patterns

scripts/python_ui/streamlit.py:573–619  ·  view source on GitHub ↗

Perform bulk edits on multiple patterns.

(patterns_to_edit, field_to_update, new_value)

Source from the content-addressed store, hash-verified

571
572
573def bulk_edit_patterns(patterns_to_edit, field_to_update, new_value):
574 """Perform bulk edits on multiple patterns."""
575 results = []
576 for pattern in patterns_to_edit:
577 try:
578 pattern_path = os.path.join(pattern_dir, pattern)
579 system_file = os.path.join(pattern_path, "system.md")
580
581 if not os.path.exists(system_file):
582 results.append((pattern, False, "system.md not found"))
583 continue
584
585 with open(system_file, "r") as f:
586 content = f.read()
587
588 if field_to_update == "purpose":
589 sections = content.split("#")
590 updated_sections = []
591 for section in sections:
592 if section.strip().startswith("IDENTITY and PURPOSE"):
593 lines = section.split("\n")
594 for i, line in enumerate(lines):
595 if "You are an AI assistant designed to" in line:
596 lines[i] = (
597 f"You are an AI assistant designed to {new_value}."
598 )
599 updated_sections.append("\n".join(lines))
600 else:
601 updated_sections.append(section)
602
603 new_content = "#".join(updated_sections)
604 with open(system_file, "w") as f:
605 f.write(new_content)
606 results.append((pattern, True, "Updated successfully"))
607 else:
608 results.append(
609 (
610 pattern,
611 False,
612 f"Field {field_to_update} not supported for bulk edit",
613 )
614 )
615
616 except Exception as e:
617 results.append((pattern, False, str(e)))
618
619 return results
620
621
622def pattern_creation_ui():

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected