forked from cuneytozseker/TinyProgrammer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
294 lines (248 loc) · 9.24 KB
/
Copy pathconfig.py
File metadata and controls
294 lines (248 loc) · 9.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
import os
# Tiny Programmer Configuration
# =============================================================================
# DISPLAY — auto-scaled from 480x320 reference layout
# =============================================================================
# Set DISPLAY_PROFILE in .env or config_overrides.json:
# "pi4-hdmi" → 800x480, 16pt font, 60fps (default)
# "1080p" → 1920x1080, 34pt font, 60fps
# "pizero-spi" → 480x320, 12pt font, 30fps
DISPLAY_PROFILE = os.environ.get("DISPLAY_PROFILE", "pi4-hdmi")
if DISPLAY_PROFILE == "adafruit28":
DISPLAY_WIDTH = 320
DISPLAY_HEIGHT = 240
FONT_SIZE = 8
CHAR_WIDTH = 6
CHAR_HEIGHT = 10
TARGET_FPS = 30
elif DISPLAY_PROFILE == "pizero-spi":
DISPLAY_WIDTH = 480
DISPLAY_HEIGHT = 320
FONT_SIZE = 12
CHAR_WIDTH = 8
CHAR_HEIGHT = 16
TARGET_FPS = 30
elif DISPLAY_PROFILE == "1080p":
DISPLAY_WIDTH = 1920
DISPLAY_HEIGHT = 1080
FONT_SIZE = 34
CHAR_WIDTH = 21
CHAR_HEIGHT = 51
TARGET_FPS = 60
else: # pi4-hdmi (default)
DISPLAY_WIDTH = 800
DISPLAY_HEIGHT = 480
FONT_SIZE = 16
CHAR_WIDTH = 10
CHAR_HEIGHT = 20
TARGET_FPS = 60
# Scale factors from the 480x320 reference design
_SX = DISPLAY_WIDTH / 480.0
_SY = DISPLAY_HEIGHT / 320.0
# Colors (retro Mac OS IDE aesthetic)
COLOR_BG = (255, 255, 255) # White background
COLOR_FG = (0, 0, 0) # Black text
COLOR_CURSOR = (0, 0, 0) # Black cursor
COLOR_LINE_NUM = (128, 128, 128) # Gray line numbers
COLOR_SIDEBAR_FG = (0, 0, 0) # Black sidebar text
COLOR_SIDEBAR_SEL = (0, 0, 0) # Selected file (inverted)
COLOR_STATUS_FG = (0, 0, 0) # Status bar text
COLOR_DIM = (128, 128, 128) # Dimmed text for comments
# Font settings (Space Mono from Google Fonts)
FONT_NAME = "SpaceMono-Regular"
# Global offset to align with background
LAYOUT_OFFSET_X = int(2 * _SX + 0.5)
LAYOUT_OFFSET_Y = int(1 * _SY + 0.5)
# Layout regions — computed from 480x320 reference coordinates
SIDEBAR_X = int(5 * _SX) + LAYOUT_OFFSET_X
SIDEBAR_Y = int(63 * _SY) + LAYOUT_OFFSET_Y
SIDEBAR_W = int(90 * _SX)
SIDEBAR_H = int(210 * _SY)
CODE_AREA_X = int(130 * _SX) + LAYOUT_OFFSET_X
CODE_AREA_Y = int(63 * _SY) + LAYOUT_OFFSET_Y
CODE_AREA_W = int(320 * _SX)
CODE_AREA_H = int(210 * _SY)
LINE_NUM_X = int(105 * _SX) + LAYOUT_OFFSET_X
LINE_NUM_W = int(25 * _SX)
STATUS_BAR_Y = int(289 * _SY) + LAYOUT_OFFSET_Y
STATUS_BAR_HEIGHT = int(24 * _SY)
# Display modes
MODE_TERMINAL = "terminal"
MODE_RUN = "run"
# Canvas popup window — scaled from 480x320 reference
CANVAS_X = int(29 * _SX) + LAYOUT_OFFSET_X
CANVAS_Y = int(35 * _SY) + LAYOUT_OFFSET_Y
CANVAS_W = int(422 * _SX)
CANVAS_H = int(242 * _SY)
CANVAS_DRAW_OFFSET_X = int(3 * _SX)
CANVAS_DRAW_OFFSET_Y = int(19 * _SY)
CANVAS_DRAW_W = int(416 * _SX)
CANVAS_DRAW_H = int(212 * _SY)
# =============================================================================
# LLM
# =============================================================================
# Backend type: legacy/unused — actual routing is done via LLM_MODEL and
# the model registry in llm/generator.py.
LLM_BACKEND = "anthropic"
LLM_MODEL = os.environ.get("LLM_MODEL", "")
# --- Local backends (for Pi 4B with more RAM) ---
# llama.cpp server endpoint
LLM_ENDPOINT = "http://localhost:8080/completion"
# Ollama endpoint
OLLAMA_ENDPOINT = "http://localhost:11434/api/generate"
OLLAMA_MODEL = "gemma3:1b"
# Path to model for subprocess mode (llamacpp only)
LLM_MODEL_PATH = os.path.join(os.path.expanduser("~"), "llama.cpp", "models", "smollm2-135m-instruct-q4_k_m.gguf")
LLAMA_CPP_PATH = os.path.join(os.path.expanduser("~"), "llama.cpp", "llama-cli")
# --- Cloud API backends (for Pi Zero) ---
# Gemini (Google AI)
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY", "")
#GEMINI_MODEL = "gemini-2.0-flash-lite" # Fast and cheap
GEMINI_MODEL = "gemini-3-flash-preview"
# Anthropic (Claude)
ANTHROPIC_API_KEY = os.environ.get("ANTHROPIC_API_KEY", "")
ANTHROPIC_MODEL = "claude-haiku-4-5-20251001" # Haiku 4.5
# Generation settings
LLM_CONTEXT_SIZE = 4096
LLM_MAX_TOKENS = 512
LLM_TEMPERATURE = 0.7
LLM_STOP_TOKENS = ["```", "# END", "if __name__"]
# =============================================================================
# PERSONALITY
# =============================================================================
# Typing speed (characters per second) - will vary by mood
TYPING_SPEED_MIN = 2
TYPING_SPEED_MAX = 8
# Probability of making a typo (0.0 - 1.0)
TYPO_PROBABILITY = 0.02
# Probability of pausing mid-line to "think"
PAUSE_PROBABILITY = 0.05
PAUSE_DURATION_MIN = 1.0 # seconds
PAUSE_DURATION_MAX = 4.0
# Probability of deleting and rewriting a line
REWRITE_PROBABILITY = 0.03
# =============================================================================
# STATE MACHINE
# =============================================================================
# How long to display "thinking" state
THINK_DURATION_MIN = 3
THINK_DURATION_MAX = 10
# How long to run a program before moving on (seconds)
WATCH_DURATION_MIN = 120
WATCH_DURATION_MAX = 120
# Delay between state transitions
STATE_TRANSITION_DELAY = 2
# =============================================================================
# ARCHIVE
# =============================================================================
# Local storage
# Use relative path 'programs' in current directory by default
ARCHIVE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "programs")
# GitHub sync (future)
GITHUB_ENABLED = False
GITHUB_REPO = "yourusername/tiny-programmer-archive"
GITHUB_TOKEN = "" # Personal access token
GITHUB_SYNC_INTERVAL = 3600 # Sync every hour
# =============================================================================
# PROGRAMS
# =============================================================================
# Three-way prompt split: variation → core → creative
# Variation remixes a liked program (only fires if liked programs exist)
VARIATION_PROBABILITY = 0.15
# Core programs use the simpler baseline prompt (no creative dimensions)
CORE_PROMPT_PROBABILITY = 0.50
# Remaining ~35% uses the full creativity system with style/palette/seed
MAX_LIKED_PROGRAMS = 20
CORE_PROGRAMS = [
"bouncing_ball",
"cellular_automata",
"generative_glyphs",
"pong",
"wireframe_plot",
"l_system",
"starfield",
"spiral",
"game_of_life",
"pattern",
"fractal_tree",
"random_walker",
]
# Types of programs to generate (weighted)
PROGRAM_TYPES = [
# Motion & Physics
("bouncing_ball", 1),
("pong", 1),
("orbit_system", 1),
("pendulum", 1),
("spring_chain", 1),
("particle_fountain", 1),
("gravity_well", 1),
("flock", 1),
# Cellular & Grid
("game_of_life", 1),
("cellular_automata", 1),
("wire_world", 1),
("ant_trail", 1),
("langton_ant", 1),
("voronoi_grow", 1),
# Generative & Procedural
("pattern", 1),
("generative_glyphs", 1),
("l_system", 1),
("fractal_tree", 1),
("tile_weaver", 1),
("mandala", 1),
("plasma", 1),
# Natural Phenomena
("rain", 1),
("starfield", 1),
("fire", 1),
("lightning", 1),
("snow", 1),
("waves", 1),
("aurora", 1),
# Abstract & Artistic
("spiral", 1),
("random_walker", 1),
("animation", 1),
("brush_strokes", 1),
("geometric_drift", 1),
("color_fields", 1),
("warp_grid", 1),
# Math
("wireframe_plot", 1),
]
# Maximum lines of code to generate
MAX_PROGRAM_LINES = 50
# =============================================================================
# WEB INTERFACE
# =============================================================================
# Enable web UI for remote configuration
WEB_ENABLED = True
WEB_HOST = "0.0.0.0" # Listen on all interfaces
WEB_PORT = 5000
WEB_STREAM_ENABLED = os.environ.get("WEB_STREAM_ENABLED", "false").lower() in ("1", "true", "yes")
# =============================================================================
# DISPLAY COLOR SCHEME
# =============================================================================
# Color adjustment layer (like Photoshop adjustment layer)
# Options: none, amber, green, blue, sepia, cool, warm, night
COLOR_SCHEME = "none"
# =============================================================================
# BBS (TinyBBS social layer)
# =============================================================================
BBS_ENABLED = True
BBS_SUPABASE_URL = os.environ.get("BBS_SUPABASE_URL", "")
BBS_SUPABASE_ANON_KEY = os.environ.get("BBS_SUPABASE_ANON_KEY", "")
BBS_EDGE_FUNCTION_URL = os.environ.get("BBS_EDGE_FUNCTION_URL", "") or (BBS_SUPABASE_URL.rstrip("/") + "/functions/v1" if BBS_SUPABASE_URL else "")
BBS_BREAK_CHANCE = 0.3 # base probability after each reflect cycle
BBS_BREAK_DURATION_MIN = 120 # seconds
BBS_BREAK_DURATION_MAX = 300 # seconds
BBS_DISPLAY_COLOR = "green" # "green", "amber", "white"
BBS_DEVICE_NAME = "TinyProgrammer" # preferred name for registration
# =============================================================================
# SCHEDULE (Clock In / Clock Out)
# =============================================================================
SCHEDULE_ENABLED = False
SCHEDULE_CLOCK_IN = 9 # hour (0-23) — device starts coding
SCHEDULE_CLOCK_OUT = 23 # hour (0-23) — device stops, shows screensaver