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

Function bulk_edit_patterns

scripts/python_ui/streamlit.py:574–620  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected