This file provides guidance to agents when working with code in this repository.
Python file synchronization utility for .kilocode directories across multiple project folders.
GUI: py main_gui.py or py app.py
CLI: python cli_sync.py <folder1> <folder2> ...
--- do not remove this ---
- Context: Windows 11, VS Code, PowerShell Core (
pwsh). - Base folder:
d:/Dropbox/Projects/AgentAutoFlow/app/. - Rule: Always use forward slashes
/in paths to avoid escaping errors. - Terminal: STRICTLY PowerShell. Do not use
cmd.exe,bash, orwsl. - Syntax Rules:
- Chaining: Use
;(sequential) or&&(conditional). - Variables: Use
$env:VAR = 'val'(notexportorset). - Replacements: Use
Select-String(notgrep),Get-Content(notcat),New-Item(nottouch),Remove-Item(notrm). - NO terminal line feeds:
- No::
python -c " print('stuff') print('more') " - Yes::
python -c "print('stuff'); print('more')"
- No::
- Chaining: Use
- Prohibited:
tail,sed,awk,sudo, andcmd.exeflags (like/d).
- Never use Linux commands in terminal.
- Start app:
py app.py(notflask run). Do not test to see if it worked. - Activate venv:
.\activate.ps1--- do not remove this ---
- Scaffold folder:
.kilocode. - Scaffold_file_modes:
.kilocodemodes.
main_gui.py(module entrypoint): creates the Tk root window.MainApp.__init__(): loads config, creates the event queue, and constructs the sync engine.MainApp._create_widgets(): builds the UI.MainApp._process_events(): starts periodic polling of the event queue.- Tkinter event loop:
root.mainloop().
- User clicks Load Favorites →
MainApp._load_favorite_folders(). - Loads the favorites list from in-memory
MainApp.favorite_folders(initialized from config duringMainApp.__init__()). - For each favorite folder:
file_path_utils.normalize_path(fav)file_path_utils.ensure_roo_dir(normalized)(creates{base folder}/{scaffold_folder}/for new projects)file_path_utils.has_roo_dir(normalized)(validates folder has{scaffold_folder}/)- if valid and not already selected, appends to
MainApp.selected_folders.
- If any folders were added, refreshes the folder list via
MainApp._update_folder_list_ui(). - If any favorites were invalid, shows an informational dialog via
messagebox.showinfo("Favorites Skipped", ...).
- User clicks Scan →
MainApp._start_sync(). SyncEngine.scan_folders(folders)- emits
EventType.SCAN_START, then manyEventType.SCAN_FILEevents while walking each{base folder}/{scaffold_folder}/*. - also scans any
root_allowlistfiles at the folder root.
- emits
SyncEngine.plan_actions(file_index, scanned_folders=folders)- computes the newest source file per relative path, then creates a list of copy actions for older/missing destinations.
- GUI stores the planned actions and renders previews via
MainApp._update_overwrite_previews().
- User clicks Execute →
MainApp._confirm_sync(). SyncWorker.__init__(sync_engine, folders, actions=planned_actions)thenSyncWorker.start().- Background thread runs
SyncWorker.run():- calls
SyncEngine.execute_actions(actions). - for each copy action, emits
EventType.COPY(orEventType.SKIPin dry-run) and finallyEventType.COMPLETE.
- calls
- GUI receives updates in
MainApp._process_events()and updates folder row statuses.
cli_sync.py(module entrypoint) →_parse_args()→run_cli_sync(args.folders).load_config(args.config).- Ensures each folder has a
{scaffold_folder}/directory (creates it if missing). - Constructs
SyncEngine(config, event_queue). - Runs sync:
- tries
SyncEngine.run_sync(folders)if present; otherwise falls back to: SyncEngine.scan_folders(folders)→SyncEngine.plan_actions(file_index, scanned_folders=folders)→SyncEngine.execute_actions(actions).
- tries
- Drains the queue and prints events via
_print_event().
- Scans
{base folder}/{scaffold_folder}/subdirectories ONLY (not entire project folders) - Uses mtime (modification time) to determine newest file as source
- Root-level files require explicit
root_allowlistin config.txt - Atomic copy: temp file + rename (not direct copy)
- Timestamped backups:
filename_YYYYMMDDTHHMMSSZ.bakformat - Dry-run mode emits EventType.SKIP events without file operations
Settings in config.txt (NOT .ini, .json, or .yaml):
root_allowlist: Comma-separated list of root files to sync (e.g.,.kilocodemodes)backup_mode: "timestamped" or "none"preserve_mtime: Must be true to maintain file timestamps
There is no database for this project. Ignore any references to a database.
- Thread-safe event queue system for GUI/CLI coordination
- EventType enum in utils_sync/progress_events.py
- Workers use SyncWorker.run() on background threads
- Primary testing folder:
{base folder}/tests/. - Integration tests:
{base folder}/test_integration/with project_a and project_b folders. - Tests verify .roo sync behavior, not general file sync.
- Use
pytestfor this application. - Pytest fixtures in
{base folder}/tests/create temporary .roo structures.
Primary: Use web browser.
Fallback: browser_action