orchestrated-discussions/smarttools/discussion-config/config.yaml

116 lines
3.9 KiB
YAML

# discussion-config - Modify discussion metadata (phase, status, participants)
# Usage: cat discussion.md | discussion-config --set-phase detailed_review > discussion-updated.md
name: discussion-config
description: Modify discussion metadata (phase, status, participants)
category: Discussion
arguments:
- flag: --set-phase
variable: set_phase
default: ""
description: Set the discussion phase
- flag: --set-status
variable: set_status
default: ""
description: Set the discussion status
- flag: --add-participant
variable: add_participant
default: ""
description: Add a participant to the discussion
- flag: --remove-participant
variable: remove_participant
default: ""
description: Remove a participant from the discussion
- flag: --insert-marker
variable: insert_marker
default: ""
description: Insert a system marker (e.g., PHASE-TRANSITION, VOTE-RESET)
steps:
- type: code
code: |
import re
from datetime import datetime
content = input
changes_made = []
# Update phase
if set_phase:
old_phase_match = re.search(r'<!--\s*Phase:\s*(\w+)\s*-->', content)
old_phase = old_phase_match.group(1) if old_phase_match else "unknown"
content = re.sub(
r'(<!--\s*Phase:\s*)(\w+)(\s*-->)',
rf'\g<1>{set_phase}\g<3>',
content
)
# Add phase transition marker at the end
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
marker = f"\n<!-- PHASE-TRANSITION: {old_phase} -> {set_phase} at {timestamp} -->\n"
content = content.rstrip() + marker
changes_made.append(f"Phase: {old_phase} -> {set_phase}")
# Update status
if set_status:
old_status_match = re.search(r'<!--\s*Status:\s*(\w+)\s*-->', content)
old_status = old_status_match.group(1) if old_status_match else "unknown"
content = re.sub(
r'(<!--\s*Status:\s*)(\w+)(\s*-->)',
rf'\g<1>{set_status}\g<3>',
content
)
changes_made.append(f"Status: {old_status} -> {set_status}")
# Add participant
if add_participant:
match = re.search(r'(<!--\s*Participants:\s*)([^>]+)(-->)', content)
if match:
current = match.group(2).strip()
participants = [p.strip() for p in current.split(',')]
if add_participant not in participants:
participants.append(add_participant)
new_list = ', '.join(participants)
content = (
content[:match.start()] +
f"<!-- Participants: {new_list} -->" +
content[match.end():]
)
changes_made.append(f"Added participant: {add_participant}")
# Remove participant
if remove_participant:
match = re.search(r'(<!--\s*Participants:\s*)([^>]+)(-->)', content)
if match:
current = match.group(2).strip()
participants = [p.strip() for p in current.split(',')]
if remove_participant in participants:
participants.remove(remove_participant)
new_list = ', '.join(participants)
content = (
content[:match.start()] +
f"<!-- Participants: {new_list} -->" +
content[match.end():]
)
changes_made.append(f"Removed participant: {remove_participant}")
# Insert custom marker
if insert_marker:
timestamp = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%SZ")
marker = f"\n<!-- {insert_marker} at {timestamp} -->\n"
content = content.rstrip() + marker
changes_made.append(f"Inserted marker: {insert_marker}")
result = content
output_var: result
output: "{result}"