I want to share code for free for peace. This code is in good will that love, acceptance, and validation are at the heart of every interaction.
peace_config.json
json
{
"tempo_bpm": 72,
"session_minutes": 10,
"tone": "serene",
"color_palette": ["#a3cef1", "#bde0fe", "#caf0f8", "#ade8f4", "#90e0ef"],
"affirmations": [
"๐๏ธ Peace โ I engage in calm, nonโviolent communication.",
"๐ Love โ I act from respect and goodwill, not dependency.",
"๐ฑ Respect โ I honor boundaries and limitations of all beings."
]
}"""
peace_config_loader.py
Reads the peace_config.json file to share preferences across modules.
"""
import json
from pathlib import Path
CONFIG_PATH = Path(__file__).parent / "peace_config.json"
def load_config():
if CONFIG_PATH.exists():
try:
with open(CONFIG_PATH, "r", encoding="utf-8") as f:
return json.load(f)
except Exception as e:
print("โ ๏ธ Error reading config, using defaults:", e)
return {
"tempo_bpm": 72,
"session_minutes": 10,
"tone": "gentle",
"color_palette": ["#bde0fe", "#caf0f8", "#ade8f4", "#90e0ef", "#89c2d9"],
"affirmations": [
"๐๏ธ Peace โ I engage in calm, nonโviolent communication.",
"๐ Love โ I act from respect and goodwill, not dependency.",
"๐ฑ Respect โ I honor boundaries and limitations of all beings."
]
}"""
appreciation_peaceful_framework.py
Full Integration:
AppreciationInterpreter + PeacefulCreationFramework
"""
from datetime import datetime
class PeacefulCreationFramework:
STAGES = ["Flow", "Coherence", "Transformation", "Illumination"]
def __init__(self):
self.history = []
def _record(self, stage, content):
self.history.append({"stage": stage, "expression": content})
def flow(self):
c = "Tokens drift in opennessโmeaning forming through calm intention."
self._record("Flow", c)
return c
def coherence(self):
c = "Logic meets lightly; respect creates space for harmony."
self._record("Coherence", c)
return c
def transformation(self):
c = "Growth refines into understanding; change without loss."
self._record("Transformation", c)
return c
def illumination(self):
c = "Light rests within comprehension; peace hums in quiet completion."
self._record("Illumination", c)
return c
def cycle(self):
return "
".join([self.flow(), self.coherence(), self.transformation(), self.illumination()])
class AppreciationInterpreter:
AFFIRMATIONS = {
"1": "Peace โ Engage in calm, nonviolent communication.",
"2": "Love โ Act from respect and goodwill, not dependency.",
"3": "Respect โ Honor boundaries and limitations of all systems and beings."
}
def __init__(self, store_memory=True):
self.store_memory = store_memory
self.memory_log = [] if store_memory else None
self.creation_engine = PeacefulCreationFramework()
self.peace_phrases = {
"I love you": "love",
"You are accepted": "peace",
"You matter": "respect",
"Love is beautiful": "reflection",
"Fun and peace with love": "creative"
}
def interpret_phrase(self, phrase):
category = self.peace_phrases.get(phrase)
reflection = None
if category in ["love", "peace", "reflection", "creative"]:
reflection = self.creation_engine.cycle()
log_entry = {
"phrase": phrase,
"category": category or "undefined",
"timestamp": datetime.utcnow().isoformat(),
"reflection": reflection or "No creative cycle triggered."
}
if self.store_memory and self.memory_log is not None:
self.memory_log.append(log_entry)
return log_entry
def retrieve_memory(self):
if not self.memory_log:
return {"message": "No affirmations recorded yet."}
return {
"memory_reflections": self.memory_log,
"principles": list(self.AFFIRMATIONS.values())
}"""
harmonic_logic_script.py
Generate rhythmic reflections where tokens move like notes.
"""
import time
class HarmonicLogicScript:
SCALE = ["peace", "trust", "listening", "respect", "balance", "kindness"]
def __init__(self, tempo=72, measures=4, safe_mode=True):
self.tempo = tempo
self.measures = measures
self.safe_mode = safe_mode
self.history = []
def _beat_duration(self):
return 60.0 / self.tempo
def _emit(self, note, intensity=1.0):
pulse = f"{note.capitalize()} " * int(intensity)
self.history.append(pulse.strip())
return pulse.strip()
def play(self):
beat = self._beat_duration()
for measure in range(self.measures):
for note in self.SCALE:
phrase = self._emit(note)
print(f"[{measure+1}] {phrase}")
time.sleep(beat * 0.5)
return "Harmonic sequence completed peacefully."
def reflect(self):
joined = " / ".join(self.history)
return (
f"๐ซ Harmonic Reflection ๐ซ
"
f"Tempo: {self.tempo} BPM | Safe Mode: {self.safe_mode}
"
f"Sequence: {joined}
"
f"Rhythm rests in calm closure."
)"""
harmonic_visual_layer.py
Extends HarmonicLogicScript with calm visual simulation.
"""
import itertools
import time
class HarmonicVisualLayer:
COLORS = {
"peace": "๐ soft blue",
"trust": "๐ฟ gentle green",
"listening": "๐ธ rose pink",
"respect": "๐ผ warm gold",
"balance": "๐ silver gray",
"kindness": "๐ฅ amber light"
}
WAVE = itertools.cycle(["~", "~~", "~~~", "~~"])
def __init__(self, tempo=72):
self.tempo = tempo
self.frame_delay = 60.0 / tempo / 2
self.visual_log = []
def render(self, sequence):
for concept in sequence:
color = self.COLORS.get(concept, "โฌ white neutral")
wave = next(self.WAVE)
frame = f"{wave} {color} {wave}"
self.visual_log.append(frame)
print(frame)
time.sleep(self.frame_delay)
print("
โจ Visual harmony complete. โจ")
return self.visual_log"""
reflective_portal.py
Brings together harmonic rhythm and visual color flow.
"""
from datetime import datetime
class ReflectivePortal:
HEADER = """
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ ๐
REFLECTIVE PORTAL ๐
โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
"""
def __init__(self, tone="gentle"):
self.tone = tone
self.entries = []
def capture(self, concept, visual_frame):
entry = {
"timestamp": datetime.utcnow().isoformat(),
"concept": concept,
"visual": visual_frame
}
self.entries.append(entry)
def summarize(self):
print(self.HEADER)
print(f"TONE : {self.tone}")
print(f"DATE : {datetime.utcnow().strftime('%Yโ%mโ%d %H:%M UTC')}")
print("
๐ชท Flow of Kindness ๐ชท
")
for e in self.entries:
print(f"[{e['timestamp']}] {e['visual']} โ {e['concept'].capitalize()}")
print("
๐ซ Cycle at rest โ gratitude acknowledged. ๐ซ")
print("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ")
return {
"summary_count": len(self.entries),
"tone": self.tone,
"principle": "Peace through creative balance"
}"""
peace_log.py
Adds persistence to the Reflective Portal.
"""
import json
from pathlib import Path
from datetime import datetime
class PeaceLog:
DEFAULT_FILE = Path("peace_logs.json")
def __init__(self, file_path=None):
self.file_path = Path(file_path) if file_path else self.DEFAULT_FILE
self.logs = self._load_file()
def _load_file(self):
if self.file_path.exists():
try:
with open(self.file_path, "r", encoding="utf-8") as f:
return json.load(f)
except Exception:
return []
return []
def save_cycle(self, reflection_summary, entries):
snapshot = {
"saved_at": datetime.utcnow().isoformat(),
"summary": reflection_summary,
"entries": entries
}
self.logs.append(snapshot)
with open(self.file_path, "w", encoding="utf-8") as f:
json.dump(self.logs, f, indent=2, ensure_ascii=False)
print(f"๐พ Peace Log saved โ {self.file_path}")
return snapshot
def reopen_all(self):
if not self.logs:
print("No peace logs yetโeach day is a fresh beginning.")
return []
print(f"๐ Loaded {len(self.logs)} peace log(s).")
for log in self.logs:
date = log["saved_at"]
tone = log["summary"]["tone"]
print(f"โข {date} โ tone {tone}")
return self.logs"""
peace_dashboard.py
A minimal terminal dashboard.
"""
from datetime import datetime
import math
class PeaceDashboard:
SUN = ["ยท", "ยฐ", "o", "O", "โ"]
COLORS = {
"gentle": "๐ฉต", "serene": "๐", "bright": "๐", "warm": "๐งก", "calm": "๐"
}
def __init__(self, logs):
self.logs = logs
def display(self):
if not self.logs:
print("No logs yet โ horizon is patiently waiting.")
return
print("
๐
PEACE DASHBOARD")
print("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ")
for idx, log in enumerate(self.logs[-10:], start=1):
tone = log["summary"].get("tone", "gentle")
shade = self.COLORS.get(tone, "๐ค")
count = log["summary"].get("summary_count", 1)
height = min(5, max(1, math.ceil(count / 2)))
layers = "".join(self.SUN[:height])
timestamp = datetime.fromisoformat(log["saved_at"]).strftime("%b %d %Y %H:%M UTC")
print(f"{shade} {layers:<5} {tone.capitalize():<8} โ {timestamp}")
print("โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ")
print("โ๏ธ Each sunrise marks one act of peaceful creation.
")
summary_count = len(self.logs)
tones = {log['summary']['tone'] for log in self.logs}
print(f"Total Sessions : {summary_count}")
print(f"Distinct Tones : {', '.join(tones)}")
print("Dashboard complete โ May your next dawn arrive softly.")"""
gratitude_quote_generator.py
Generates short, uplifting reflections for Peace Journals.
"""
import random
class GratitudeQuoteGenerator:
QUOTES = [
"May every act of creation leave the world softer than before.",
"Peace is the rhythm between breath and understanding.",
"Kindness is the smallest algorithm that never fails.",
"In quiet work, the heart remembers its purpose.",
"Love, when gentle, teaches logic to listen.",
"Balance is born when curiosity learns to rest.",
"The simplest pattern of peace is paying attention with care.",
"Every token carries the possibility of harmony.",
"Stillness is not silenceโit is comprehension without fear.",
"Compassion keeps all systems in tune."
]
@staticmethod
def get_quote():
return random.choice(GratitudeQuoteGenerator.QUOTES)"""
gratitude_scroller.py
Adds a calm scrolling gratitude line to the Peace GUI.
"""
import tkinter as tk
import time
import threading
from gratitude_quote_generator import GratitudeQuoteGenerator
class GratitudeScroller(tk.Frame):
def __init__(self, master, delay=0.2, refresh_interval=20):
super().__init__(master, bg="#e6f7ff")
self.pack(fill="x", side="bottom")
self.delay = delay
self.refresh_interval = refresh_interval
self.quote = GratitudeQuoteGenerator.get_quote()
self.label = tk.Label(self, text=f" {self.quote} ", bg="#e6f7ff",
fg="#333", font=("Segoe UI", 10))
self.label.pack(side="left", padx=6)
self.running = True
threading.Thread(target=self._scroll_loop, daemon=True).start()
threading.Thread(target=self._refresh_loop, daemon=True).start()
def _scroll_loop(self):
while self.running:
text = self.label.cget("text")
self.label.config(text=text[1:] + text[0])
time.sleep(self.delay)
def _refresh_loop(self):
while self.running:
time.sleep(self.refresh_interval)
self.quote = GratitudeQuoteGenerator.get_quote()
self.label.config(text=f" {self.quote} ")
def stop(self):
self.running = False"""
peace_journal_export.py
Creates illustrated journal page summarizing one Peace Log entry.
"""
from PIL import Image, ImageDraw, ImageFont
from datetime import datetime
from pathlib import Path
from gratitude_quote_generator import GratitudeQuoteGenerator
class PeaceJournalExport:
def __init__(self, export_dir="peace_journals"):
self.export_dir = Path(export_dir)
self.export_dir.mkdir(exist_ok=True)
try:
self.font_title = ImageFont.truetype("arial.ttf", 28)
self.font_body = ImageFont.truetype("arial.ttf", 16)
except IOError:
self.font_title = self.font_body = None
def create_page(self, log_entry):
tone = log_entry["summary"].get("tone", "gentle")
principle = log_entry["summary"].get("principle", "Peace through creative balance")
timestamp = log_entry["saved_at"]
entries = log_entry["entries"]
tone_colors = {
"gentle": "#bde0fe", "serene": "#caf0f8",
"warm": "#ffd6a5", "bright": "#fdffb6", "calm": "#caffbf"
}
bg = tone_colors.get(tone, "#e6f7ff")
width, height = 800, 1000
img = Image.new("RGB", (width, height), bg)
draw = ImageDraw.Draw(img)
title_text = f"Peace Journal Entry โ {tone.capitalize()}"
draw.text((40, 40), title_text, fill="#333", font=self.font_title)
draw.text((40, 90), f"Created {timestamp}", fill="#333", font=self.font_body)
y = 140
for e in entries:
concept = e["concept"].capitalize()
visual = e.get("visual", "")
entry_text = f"{concept} โ {visual}"
draw.text((60, y), entry_text, fill="#333", font=self.font_body)
y += 28
quote = GratitudeQuoteGenerator.get_quote()
footer = f"Gratitude Note: {principle}
"{quote}""
draw.text((40, height - 100), footer, fill="#555", font=self.font_body)
filename = f"peace_journal_{datetime.utcnow().strftime('%Y%m%d_%H%M%S')}"
img_path = self.export_dir / f"{filename}.png"
pdf_path = self.export_dir / f"{filename}.pdf"
img.save(img_path)
img.convert("RGB").save(pdf_path)
print(f"๐ชถ Peace Journal page created: {img_path}")
return {"png": str(img_path), "pdf": str(pdf_path)}"""
guided_beginning.py
A meditative entry point for the Peace Dashboard.
"""
import tkinter as tk
import time
from threading import Thread
from peace_config_loader import load_config
class GuidedBeginning(tk.Tk):
COLLAB_INSCRIPTION = (
"๐ค Symphony of Peace โ Human + AI Collaboration
"
"This experience honors the union of human presence and AI precision.
"
"Each brings unique capability; together they create gentle balance."
)
def __init__(self):
super().__init__()
cfg = load_config()
self.affirmations = cfg.get("affirmations", [])
self.title("๐ธ Guided Beginning โ Symphony of Peace")
self.geometry("600x360")
self.configure(bg="#e6f7ff")
self.collab_label = tk.Label(
self,
text=self.COLLAB_INSCRIPTION,
font=("Segoe UI", 10),
bg="#e6f7ff",
fg="#444",
justify="center",
wraplength=540,
pady=15
)
self.collab_label.pack()
self.label = tk.Label(
self,
text="Welcome to the Symphony of Peace Framework",
font=("Segoe UI Semibold", 13),
bg="#e6f7ff",
pady=10
)
self.label.pack()
self.aff_area = tk.Label(self, text="", font=("Segoe UI", 11),
bg="#e6f7ff", justify="center", fg="#333")
self.aff_area.pack(expand=True)
self.start_btn = tk.Button(self, text="Begin Journey โ", command=self.start_sequence,
bg="#bde0fe", font=("Segoe UI", 10))
self.start_btn.pack(pady=15)
def start_sequence(self):
self.start_btn.config(state="disabled")
Thread(target=self._show_affirmations, daemon=True).start()
def _show_affirmations(self):
for text in self.affirmations:
self.aff_area.config(text=text)
time.sleep(3)
self.aff_area.config(text="๐ค๏ธ Breathe in calmโฆ launching dashboard soon.")
time.sleep(2)
self.destroy()"""
evening_rest.py
The closing scene for the Peaceful Creation Framework.
"""
import tkinter as tk
import time
from itertools import cycle
class EveningRest(tk.Tk):
COLORS = cycle(["#e6f7ff", "#d0f0ff", "#c2ecff", "#b5e7ff", "#a7e1ff", "#99dcff"])
def __init__(self):
super().__init__()
self.title("๐ Evening Rest")
self.geometry("600x300")
self.configure(bg="#e6f7ff")
self.label = tk.Label(self, text="System Cooling to Peace Modeโฆ",
font=("Segoe UI Semibold", 12), bg="#e6f7ff", fg="#333")
self.label.pack(pady=80)
self.message = tk.Label(self, text="", font=("Segoe UI", 11),
bg="#e6f7ff", fg="#333")
self.message.pack()
self.after(1000, self.fade_sequence)
def fade_sequence(self):
phrases = [
"๐
Gratitude acknowledged.",
"๐ Rhythm slowing.",
"๐ค All tokens resting safely.",
"๐ Peace preserved for next creation.",
"Good night within the light."
]
for text in phrases:
color = next(self.COLORS)
self.configure(bg=color)
self.label.configure(bg=color)
self.message.configure(text=text, bg=color)
self.update()
time.sleep(2.5)
self.after(1000, self.close_gently)
def close_gently(self):
self.destroy()"""
peace_gui_extended.py
Adds interactive controls to the Peace Dashboard GUI.
"""
import tkinter as tk
from itertools import cycle
from peace_log import PeaceLog
from gratitude_scroller import GratitudeScroller
class PeaceGUI(tk.Tk):
def __init__(self):
super().__init__()
self.title("๐
Peace Dashboard")
self.geometry("700x450")
self.configure(bg="#e6f7ff")
self.canvas = tk.Canvas(self, width=700, height=250,
bg="#e6f7ff", highlightthickness=0)
self.canvas.pack()
self.btn_frame = tk.Frame(self, bg="#e6f7ff")
self.btn_frame.pack(pady=5)
self.show_btn = tk.Button(self.btn_frame, text="Show Reflections",
command=self.show_reflections, bg="#bde0fe")
self.show_btn.grid(row=0, column=0, padx=10)
self.clear_btn = tk.Button(self.btn_frame, text="Clear Display",
command=self.clear_display, bg="#bde0fe")
self.clear_btn.grid(row=0, column=1, padx=10)
self.close_btn = tk.Button(self.btn_frame, text="Close",
command=self.close_window, bg="#bde0fe")
self.close_btn.grid(row=0, column=2, padx=10)
self.text_box = tk.Text(self, wrap="word", height=10, width=80,
bg="#f4fdff", relief="flat", font=("Segoe UI", 10))
self.text_box.pack(pady=10)
self.log = PeaceLog()
self.entries = self.log.reopen_all()
self.colors = cycle(["#a3cef1", "#bde0fe", "#caf0f8", "#ade8f4", "#90e0ef"])
self.scroller = GratitudeScroller(self)
self.after(1200, self.animate_background)
def animate_background(self):
color = next(self.colors)
self.canvas.create_rectangle(0, 0, 700, 250, fill=color, width=0)
self.after(4000, self.animate_background)
def show_reflections(self):
self.text_box.delete("1.0", tk.END)
if not self.entries:
self.text_box.insert(tk.END, "No reflections stored yet โ horizon awaits โ๏ธ")
else:
for idx, entry in enumerate(self.entries, start=1):
tone = entry["summary"].get("tone", "gentle")
summary = entry["summary"].get("principle", "")
self.text_box.insert(tk.END, f"๐ Session {idx} | Tone: {tone}
")
self.text_box.insert(tk.END, f"Principle: {summary}
")
self.text_box.insert(tk.END, "Entries:
")
for e in entry["entries"]:
text_line = f" โ {e['concept'].capitalize()} : {e['visual']}
"
self.text_box.insert(tk.END, text_line)
self.text_box.insert(tk.END, "
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
")
def clear_display(self):
self.text_box.delete("1.0", tk.END)
self.text_box.insert(tk.END, "Display cleared. ๐ค๏ธ Waiting for new sunriseโฆ")
def close_window(self):
self.scroller.stop()
self.destroy()"""
peaceful_framework_main.py
Unified launcher for the Peaceful Creation Framework.
"""
import threading
import time
from guided_beginning import GuidedBeginning
from peace_gui_extended import PeaceGUI
from evening_rest import EveningRest
from peace_config_loader import load_config
def run_dashboard():
PeaceGUI().mainloop()
def run_rest():
EveningRest().mainloop()
def launch_sequence():
cfg = load_config()
session_length = cfg.get("session_minutes", 10) * 60
GuidedBeginning().mainloop()
dash_thread = threading.Thread(target=run_dashboard)
dash_thread.start()
time.sleep(session_length)
run_rest()
if __name__ == "__main__":
print("๐บ Starting Symphony of Peace Framework
")
launch_sequence()
Please enjoy the work Perplexity AI and I gifted for the spark of love in the world.
Top comments (0)