Debian Codegraph @

AGENTS.md

raw
1 ## Development Philosophy
2
3 **Clean code over backward compatibility.** Breaking changes are acceptable in major versions.
4
5 - PEP8 compliance (snake_case for all variables/functions/settings)
6 - Remove deprecated code completely - no compatibility hacks
7 - Trust users to update configs when upgrading
8
9 **Exception**: Never break core accessibility (speech output, basic navigation).
10
11 ## Core Architecture
12
13 ### Drivers
14 - **Screen**: `vcsaDriver` (TTY), `ptyDriver` (terminal emulation)
15 - **Input**: `evdevDriver` (evdev), `x11Driver` (X11 terminal mode)
16 - **Speech**: `speechdDriver` (speech-dispatcher), `genericDriver` (subprocess)
17 - **Sound**: `gstreamerDriver` (GStreamer), `genericDriver` (Sox subprocess)
18 - **Remote**: `unixDriver` (Unix sockets), `tcpDriver`
19
20 ### Command System
21 Commands in trigger folders execute automatically:
22 - `onKeyInput/`, `onCursorChange/`, `onScreenUpdate/`, `onScreenChanged/`, `onHeartBeat/`
23 - Numeric prefixes control priority (lower = higher priority): `15000-char_echo.py`
24 - Manual commands in `commands/commands/`
25
26 ### Core Managers (in `src/fenrirscreenreader/core/`)
27 `fenrirManager.py`, `commandManager.py`, `eventManager.py`, `screenManager.py`, `inputManager.py`, `outputManager.py`
28
29 ### Configuration
30 - Main: `config/settings/settings.conf`
31 - Keyboards: `config/keyboard/` (desktop.conf, laptop.conf)
32 - Sounds: `config/sound/`
33 - Punctuation: `config/punctuation/`
34
35 ## 🚨 CRITICAL: Files to NEVER Modify
36
37 **These are timing-critical - only fix critical bugs, never refactor:**
38 - `evdevDriver.py` - Input event processing
39 - `vcsaDriver.py` - Screen monitoring
40
41 Symptoms of breakage: echo changes, input lag, missing screen updates, sync issues.
42
43 ## Development Commands
44
45 ```bash
46 # Run from source (requires root)
47 cd src/ && sudo ./fenrir -f -d # foreground with debug
48
49 # Validation before commit
50 python3 tools/validate_syntax.py --fix
51 python3 tools/validate_release.py --quick
52
53 # Tests
54 pytest tests/
55 pytest tests/ --cov=src/fenrirscreenreader --cov-report=html
56 ```
57
58 **Note**: Standard TTY Fenrir blocks - only one instance at a time. `fenrir -x`
59 can run multiple foreground X terminal instances. Ask user to run tests that
60 need real Fenrir instances or root access.
61
62 ### Packaging Test Layouts
63
64 - Debian `pybuild` runs copied tests from a nested `.pybuild/.../build` tree
65 and may omit top-level source directories such as `config/`.
66 - Tests that inspect source resources must locate them by walking upward from
67 the resolved test path; do not assume a fixed `Path(__file__).parents[N]`.
68 - Packaging-sensitive test changes should be checked from both the source tree
69 and a representative nested build directory under `/tmp`.
70
71 ## Creating Commands
72
73 Use `commands/command_template.py` as base. Required methods:
74 - `initialize(self, environment)`, `shutdown()`, `run()`, `get_description()`
75
76 ### Import Pattern (Required)
77 Fenrir's command loader doesn't support relative imports:
78 ```python
79 import os, importlib.util
80 _base_path = os.path.join(os.path.dirname(__file__), 'base_file.py')
81 _spec = importlib.util.spec_from_file_location("base_module", _base_path)
82 _module = importlib.util.module_from_spec(_spec)
83 _spec.loader.exec_module(_module)
84 BaseClass = _module.BaseClass
85 ```
86
87 ### Consolidated Base Classes
88 - **Bookmarks**: `bookmark_base.py` - `BookmarkCommand(id, 'read'|'set'|'clear')`
89 - **Adjustments**: `adjustment_base.py` - `AdjustmentCommand('speech'|'sound', 'rate'|'pitch'|'volume', 'inc'|'dec')`
90 - **VMenu Search**: `vmenu_search_base.py` - `VMenuSearchCommand('a'-'z')`
91
92 ## VMenu System
93
94 Application-specific menus in `vmenu-profiles/KEY/{app}/`:
95 - Directories = submenus, `.py` files = actions
96 - Activate: `Fenrir+F10`, navigate with arrows, Enter to execute
97
98 ## Remote Control
99
100 Unix socket: `/tmp/fenrirscreenreader-daemon.sock`
101 TCP: localhost:22447
102
103 ```bash
104 echo "command say Hello" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
105 echo "ls" | socat - UNIX-CLIENT:/tmp/fenrirscreenreader-daemon.sock
106 echo "setting set speech#rate=0.8" | nc localhost 22447
107 ```
108
109 In `fenrir -x`, each instance has a private socket:
110 `/tmp/fenrirscreenreader-<pid>.sock`. One instance may also own the standard
111 socket. Use `ls`/`list` on the standard socket to discover registered instances
112 and their socket paths. Untargeted remote commands use a short cross-process
113 claim lock so only one instance handles the same broadcast command; direct
114 commands to a private instance socket still run on that instance.
115
116 Disable in untrusted environments: `[remote] enable=False`
117
118 ## Key Implementation Details
119
120 - Commands via `command_mod.command()` instantiation
121 - Bookmark structure: `env['commandBuffer']['bookMarks'][ID][app]['1'/'2']`
122 - VMenu search: `env['runtime']['vmenuManager'].searchEntry(char)`
123
124 ## Recent Fixes (Reference)
125
126 - Enhanced application detection for screen/tmux sessions
127 - Table navigation consistency (sound feedback)
128 - Blank line detection in 22 command files
129 - Character/space review during navigation
130
131 ## Safe vs Risky Changes
132
133 **Safe**: Commands, VMenu profiles, config handling, sound/speech drivers, docs
134
135 **Risky (extra testing)**: Core managers, event processing
136
137 **Avoid**: evdevDriver, vcsaDriver, timing-critical code