Compare commits
235 Commits
b01dfc09cb
...
sim
| Author | SHA1 | Date | |
|---|---|---|---|
| fb1117becc | |||
| df90bad4a1 | |||
| 9f2ed38845 | |||
| 59f4df4475 | |||
| c4da60d1c5 | |||
| 47c4117763 | |||
| 8e63b31508 | |||
| 8bd280efc1 | |||
| 75e1cf84fe | |||
| ba97ccda3c | |||
| 0f04e066ef | |||
| 5e1b965311 | |||
| fdb9b59d36 | |||
| 9c4a72c734 | |||
| 6d16438477 | |||
| bd5dc16715 | |||
| 895004ddc5 | |||
| 76265319a7 | |||
| bfe9ef014d | |||
| d326242667 | |||
| f36d539c36 | |||
| 1d674c3a1e | |||
| 1db5ac57ec | |||
| d8e42a697b | |||
| 050d995660 | |||
| 0c5ac55053 | |||
| 450c17b96e | |||
| 36ab691fbf | |||
| 8cca046d96 | |||
| 22f8943619 | |||
| 5257db5aca | |||
| ebd81586bb | |||
| ae5dd328e1 | |||
| b3cf58adb4 | |||
| 4a4cf8c14b | |||
| e3767d2994 | |||
| c5d54cfae2 | |||
| 975fcde9bd | |||
| 97367fe537 | |||
| 72c898e8c2 | |||
| f8fb58db1f | |||
| c341de5515 | |||
| b1687f4a6b | |||
| 6a35da1eb2 | |||
| 0e06956d63 | |||
| 8448c71287 | |||
| d177c0bf3c | |||
| 040fec3613 | |||
| e757922c72 | |||
| 05cd1b6596 | |||
| e9126b47db | |||
| 0f9f235438 | |||
| f0eb5382fe | |||
| 842bfc407c | |||
| 5ec4283f41 | |||
| a359f19cdc | |||
| 6287f24e51 | |||
| faa37928cd | |||
| 094e729e89 | |||
| ad8c0e208b | |||
| ffeb6f50f5 | |||
| 58594e03df | |||
| da28d839f6 | |||
| 075d760721 | |||
| 2da1ef38af | |||
| 40fc35f176 | |||
| 1a428e3c6a | |||
| 66f728e7a3 | |||
| eaaf09dc3c | |||
| abc0639602 | |||
| b792e34a64 | |||
| 8caebbd226 | |||
| 2dd6145bd8 | |||
| 0c27aa6c6b | |||
| e24664c7b2 | |||
| 20ebab55a0 | |||
| c44026c06c | |||
| 776f4e4370 | |||
| cd3f3c89ed | |||
| 93e72b5530 | |||
| 637946b8c6 | |||
| 6677a6e55b | |||
| be20d80453 | |||
| db251a1038 | |||
| 28ab543d4a | |||
| 8ba5ed4d90 | |||
| 79ebc210bf | |||
| edc09895b3 | |||
| 4628813363 | |||
| d535fc7f38 | |||
| b415e4ec19 | |||
| 0535e436d5 | |||
| f1f3ed9925 | |||
| d804a32c0e | |||
| 8a056468de | |||
| 7aa9fe6099 | |||
| b91e72b749 | |||
| 8ccc3d60b5 | |||
| 9fdece9404 | |||
| 85fad6bb04 | |||
| 182a19716e | |||
| 161a4d062a | |||
| e783a03f74 | |||
| c2f4b161b4 | |||
| 2a35df9cbe | |||
| cc6a35ea05 | |||
| 7c45d26bea | |||
| 555cf29890 | |||
| 0625fe10c8 | |||
| 30d838c3a0 | |||
| 0b148325d0 | |||
| b92f2f32c8 | |||
| 3e9d362be3 | |||
| 4105f6154a | |||
| 9ec5ff309a | |||
| 932194d6fa | |||
| f5c9596b05 | |||
| 6917f708b3 | |||
| cdd06d4339 | |||
| e19e9130e4 | |||
| 5c7fd39249 | |||
| f9df7d4479 | |||
| 7fe117d357 | |||
| 3487c79cba | |||
| e3b483d983 | |||
| 2d22bd7b9c | |||
| 76582c821e | |||
| e47ee14c7b | |||
| e747a783a5 | |||
| 84f05079e3 | |||
| c35170786b | |||
| a52f3a2ef8 | |||
| 2668f88e8a | |||
| ac51ded52b | |||
| f10a2f2ffa | |||
| c61fcc6333 | |||
| 8aa70e287f | |||
| 27eb9bef95 | |||
| 56e275245f | |||
| eb9705bd93 | |||
| 10ca40dd35 | |||
| b575dcd1eb | |||
| f7d3e97f18 | |||
| 94b4f38c8c | |||
| 9c60936a0c | |||
| c7c8b89b4e | |||
| cf19530792 | |||
| f4a9ff82fa | |||
| 926cebe40a | |||
| f17c9e31b4 | |||
| 1b8b236433 | |||
| 2ec1ecfd50 | |||
| a70e4e2b21 | |||
| ce75f0e5a1 | |||
| 76e263c0c9 | |||
| bb4776e99c | |||
| dc64493f42 | |||
| 0070f61a40 | |||
| d3ca0fee98 | |||
| eaf229e144 | |||
| d7281dc16e | |||
| ef29902963 | |||
| 0d09007dc1 | |||
| 5f9bc193cb | |||
| 03db4190d7 | |||
| d9d056c80d | |||
| a65990f72b | |||
| 2bc7a3f0a5 | |||
| bf76a763c3 | |||
| 44c2585f95 | |||
| bd7ccf3a07 | |||
| 1306163446 | |||
| ddf6f0e1bc | |||
| d53f0e44ee | |||
| fb018e1291 | |||
| a7639fe24e | |||
| 1ac6eb9b7f | |||
| d042fa95e2 | |||
| 92aa33c6d3 | |||
| 1677d25298 | |||
| 9c5fcab9e8 | |||
| a88311b9fe | |||
| ccdba69214 | |||
| 94fe904d3f | |||
| 9e6b740950 | |||
| e34ff7ef79 | |||
| 4479c38395 | |||
| 243a0cc5ca | |||
| 68e895cb8a | |||
| b4734f4bba | |||
| 8a3c2d8e21 | |||
| 73fad80257 | |||
| 17eebff5f8 | |||
| 1581380a43 | |||
| 8bf95866dc | |||
| 4755f4b590 | |||
| 1b71b748db | |||
| da8df7a393 | |||
| bf2d09f3fd | |||
| 4a6721c3be | |||
| 7d294da942 | |||
| 254ca8cbda | |||
| 34ed257cd6 | |||
| 5103a256bf | |||
| 6d2f79acc8 | |||
| be42d21842 | |||
| 30b3c1ab1d | |||
| 96a013c3dc | |||
| b69338f880 | |||
| 7a32a5138f | |||
| 0cccaf05a3 | |||
| 3d3c4e80ae | |||
| bdd0fbc1c4 | |||
| dc8192b1dc | |||
| 3e94c9580e | |||
| 5f9b270841 | |||
| 954efdec74 | |||
| 813297c099 | |||
| d7d0583b4e | |||
| caa67206fa | |||
| 173e09059d | |||
| e481257eda | |||
| 00d14131a9 | |||
| 478dbb9b86 | |||
| 32af96b365 | |||
| f126cdcb21 | |||
| a6d7127d98 | |||
| 1ad985e27a | |||
| f6c06ec381 | |||
| 9a23941e59 | |||
| 2182bfbd4a | |||
| f258fc5765 | |||
| 59208b27ec | |||
| 0a591d58eb | |||
| d9a51332ef |
BIN
Binary file not shown.
@@ -0,0 +1,47 @@
|
|||||||
|
# Project Overview
|
||||||
|
|
||||||
|
**Manual Slop** is a local GUI application designed as an experimental, "manual" AI coding assistant. It allows users to curate and send context (files, screenshots, and discussion history) to AI APIs (Gemini and Anthropic). The AI can then execute PowerShell scripts within the project directory to modify files, requiring explicit user confirmation before execution.
|
||||||
|
|
||||||
|
**Main Technologies:**
|
||||||
|
* **Language:** Python 3.11+
|
||||||
|
* **Package Management:** `uv`
|
||||||
|
* **GUI Framework:** Dear PyGui (`dearpygui`), ImGui Bundle (`imgui-bundle`)
|
||||||
|
* **AI SDKs:** `google-genai` (Gemini), `anthropic`
|
||||||
|
* **Configuration:** TOML (`tomli-w`)
|
||||||
|
|
||||||
|
**Architecture:**
|
||||||
|
* **`gui.py`:** The main entry point and Dear PyGui application logic. Handles all panels, layouts, user input, and confirmation dialogs.
|
||||||
|
* **`ai_client.py`:** A unified wrapper for both Gemini and Anthropic APIs. Manages sessions, tool/function-call loops, token estimation, and context history management.
|
||||||
|
* **`aggregate.py`:** Responsible for building the `file_items` context. It reads project configurations, collects files and screenshots, and builds the context into markdown format to send to the AI.
|
||||||
|
* **`mcp_client.py`:** Implements MCP-like tools (e.g., `read_file`, `list_directory`, `search_files`, `web_search`) as native functions that the AI can call. Enforces a strict allowlist for file access.
|
||||||
|
* **`shell_runner.py`:** A sandboxed subprocess wrapper that executes PowerShell scripts (`powershell -NoProfile -NonInteractive -Command`) provided by the AI.
|
||||||
|
* **`project_manager.py`:** Manages per-project TOML configurations (`manual_slop.toml`), serializes discussion entries, and integrates with git (e.g., fetching current commit).
|
||||||
|
* **`session_logger.py`:** Handles timestamped logging of communication history (JSON-L) and tool calls (saving generated `.ps1` files).
|
||||||
|
|
||||||
|
# Building and Running
|
||||||
|
|
||||||
|
* **Setup:** The application uses `uv` for dependency management. Ensure `uv` is installed.
|
||||||
|
* **Credentials:** You must create a `credentials.toml` file in the root directory to store your API keys:
|
||||||
|
```toml
|
||||||
|
[gemini]
|
||||||
|
api_key = "****"
|
||||||
|
[anthropic]
|
||||||
|
api_key = "****"
|
||||||
|
```
|
||||||
|
* **Run the Application:**
|
||||||
|
```powershell
|
||||||
|
uv run .\gui.py
|
||||||
|
```
|
||||||
|
|
||||||
|
# Development Conventions
|
||||||
|
|
||||||
|
* **Configuration Management:** The application uses two tiers of configuration:
|
||||||
|
* `config.toml`: Global settings (UI theme, active provider, list of project paths).
|
||||||
|
* `manual_slop.toml`: Per-project settings (files to track, discussion history, specific system prompts).
|
||||||
|
* **Tool Execution:** The AI acts primarily by generating PowerShell scripts. These scripts MUST be confirmed by the user via a GUI modal before execution. The AI also has access to read-only MCP-style file exploration tools and web search capabilities.
|
||||||
|
* **Context Refresh:** After every tool call that modifies the file system, the application automatically refreshes the file contents in the context using the files' `mtime` to optimize reads.
|
||||||
|
* **UI State Persistence:** Window layouts and docking arrangements are automatically saved to and loaded from `dpg_layout.ini`.
|
||||||
|
* **Code Style:**
|
||||||
|
* Use type hints where appropriate.
|
||||||
|
* Internal methods and variables are generally prefixed with an underscore (e.g., `_flush_to_project`, `_do_generate`).
|
||||||
|
* **Logging:** All API communications are logged to `logs/comms_<ts>.log`. All executed scripts are saved to `scripts/generated/`.
|
||||||
+141
-37
@@ -1,11 +1,4 @@
|
|||||||
# Manual Slop
|
# Manual Slop
|
||||||
|
|
||||||
## Baseline
|
|
||||||
|
|
||||||
Make sure to update this file every time.
|
|
||||||
DO NOT EVER make a shell script unless told to. DO NOT EVER make a readme or a file describing your changes unless your are told to. If you have commands I should be entering into the command line or if you have something to explain to me, please just use code blocks or normal text output. DO NOT DO ANYTHING OTHER THAN WHAT YOU WERE TOLD TODO. DO NOT EVER, EVER DO ANYTHING OTHER THAN WHAT YOU WERE TOLD TO DO. IF YOU WANT TO DO OTHER THINGS, SIMPLY SUGGEST THEM, AND THEN I WILL REVIEW YOUR CHANGES, AND MAKE THE DECISION ON HOW TO PROCEED. WHEN WRITING SCRIPTS USE A 120-160 character limit per line. I don't want to see scrunched code.
|
|
||||||
|
|
||||||
Make destructive modifications to the project, ITS OK, I HAVE GIT HISTORY TO MANAGE THE PROJECTS.
|
|
||||||
|
|
||||||
## Summary
|
## Summary
|
||||||
|
|
||||||
@@ -19,17 +12,19 @@ Is a local GUI tool for manually curating and sending context to AI APIs. It agg
|
|||||||
- `uv` - package/env management
|
- `uv` - package/env management
|
||||||
|
|
||||||
**Files:**
|
**Files:**
|
||||||
- `gui.py` - main GUI, `App` class, all panels, all callbacks, confirmation dialog, layout persistence, rich comms rendering
|
- `gui.py` - main GUI, `App` class, all panels, all callbacks, confirmation dialog, layout persistence, rich comms rendering; `[+ Maximize]` buttons in `ConfirmDialog` and `win_script_output` now pass text directly as `user_data` / read from `self._last_script` / `self._last_output` instance vars instead of `dpg.get_value(tag)` — fixes glitch when word-wrap is ON or dialog is dismissed before viewer opens
|
||||||
- `ai_client.py` - unified provider wrapper, model listing, session management, send, tool/function-call loop, comms log, provider error classification
|
- `ai_client.py` - unified provider wrapper, model listing, session management, send, tool/function-call loop, comms log, provider error classification, token estimation, and aggressive history truncation
|
||||||
- `aggregate.py` - reads config, collects files/screenshots/discussion, writes numbered `.md` files to `output_dir`
|
- `aggregate.py` - reads config, collects files/screenshots/discussion, builds `file_items` with `mtime` for cache optimization, writes numbered `.md` files to `output_dir` using `build_markdown_from_items` to avoid double I/O; `run()` returns `(markdown_str, path, file_items)` tuple; `summary_only=False` by default (full file contents sent, not heuristic summaries)
|
||||||
- `shell_runner.py` - subprocess wrapper that runs PowerShell scripts sandboxed to `base_dir`, returns stdout/stderr/exit code as a string
|
- `shell_runner.py` - subprocess wrapper that runs PowerShell scripts sandboxed to `base_dir`, returns stdout/stderr/exit code as a string
|
||||||
- `session_logger.py` - opens timestamped log files at session start; writes comms entries as JSON-L and tool calls as markdown; saves each AI-generated script as a `.ps1` file
|
- `session_logger.py` - opens timestamped log files at session start; writes comms entries as JSON-L and tool calls as markdown; saves each AI-generated script as a `.ps1` file
|
||||||
- `project_manager.py` - per-project .toml load/save, entry serialisation (entry_to_str/str_to_entry with @timestamp support), default_project/default_discussion factories, migrate_from_legacy_config, flat_config for aggregate.run(), git helpers (get_git_commit, get_git_log)
|
- `project_manager.py` - per-project .toml load/save, entry serialisation (entry_to_str/str_to_entry with @timestamp support), default_project/default_discussion factories, migrate_from_legacy_config, flat_config for aggregate.run(), git helpers (get_git_commit, get_git_log)
|
||||||
- `theme.py` - palette definitions, font loading, scale, load_from_config/save_to_config
|
- `theme.py` - palette definitions, font loading, scale, load_from_config/save_to_config
|
||||||
- `gemini.py` - legacy standalone Gemini wrapper (not used by the main GUI; superseded by `ai_client.py`)
|
- `gemini.py` - legacy standalone Gemini wrapper (not used by the main GUI; superseded by `ai_client.py`)
|
||||||
- `file_cache.py` - stub; Anthropic Files API path removed; kept so stale imports don't break
|
- `file_cache.py` - stub; Anthropic Files API path removed; kept so stale imports don't break
|
||||||
- `config.toml` - global-only settings: [ai] provider+model, [theme] palette+font+scale, [projects] paths array + active path
|
- `mcp_client.py` - MCP-style tools (read_file, list_directory, search_files, get_file_summary, web_search, fetch_url); allowlist enforced against project file_items + base_dirs for file tools; web tools are unrestricted; dispatched by ai_client tool-use loop for both Anthropic and Gemini
|
||||||
- `manual_slop.toml` - per-project file: [project] name+git_dir, [output] namespace+output_dir, [files] base_dir+paths, [screenshots] base_dir+paths, [discussion] roles+active+[discussion.discussions.<name>] git_commit+last_updated+history
|
- `summarize.py` - local heuristic summariser (no AI); .py via AST, .toml via regex, .md headings, generic preview; used by mcp_client.get_file_summary and aggregate.build_summary_section
|
||||||
|
- `config.toml` - global-only settings: [ai] provider+model+system_prompt, [theme] palette+font+scale, [projects] paths array + active path
|
||||||
|
- `manual_slop.toml` - per-project file: [project] name+git_dir+system_prompt+main_context, [output] namespace+output_dir, [files] base_dir+paths, [screenshots] base_dir+paths, [discussion] roles+active+[discussion.discussions.<name>] git_commit+last_updated+history
|
||||||
- `credentials.toml` - gemini api_key, anthropic api_key
|
- `credentials.toml` - gemini api_key, anthropic api_key
|
||||||
- `dpg_layout.ini` - Dear PyGui window layout file (auto-saved on exit, auto-loaded on startup); gitignore this per-user
|
- `dpg_layout.ini` - Dear PyGui window layout file (auto-saved on exit, auto-loaded on startup); gitignore this per-user
|
||||||
|
|
||||||
@@ -43,6 +38,7 @@ Is a local GUI tool for manually curating and sending context to AI APIs. It agg
|
|||||||
- **Message** - multiline input, Gen+Send button, MD Only button, Reset session button, -> History button
|
- **Message** - multiline input, Gen+Send button, MD Only button, Reset session button, -> History button
|
||||||
- **Response** - readonly multiline displaying last AI response, -> History button
|
- **Response** - readonly multiline displaying last AI response, -> History button
|
||||||
- **Tool Calls** - scrollable log of every PowerShell tool call the AI made; Clear button
|
- **Tool Calls** - scrollable log of every PowerShell tool call the AI made; Clear button
|
||||||
|
- **System Prompts** - global (all projects) and project-specific multiline text areas for injecting custom system instructions. Combined with the built-in tool prompt.
|
||||||
- **Comms History** - rich structured live log of every API interaction; status line at top; colour legend; Clear button
|
- **Comms History** - rich structured live log of every API interaction; status line at top; colour legend; Clear button
|
||||||
|
|
||||||
**Layout persistence:**
|
**Layout persistence:**
|
||||||
@@ -59,7 +55,7 @@ Is a local GUI tool for manually curating and sending context to AI APIs. It agg
|
|||||||
- `_flush_to_project()` pulls widget values into `self.project` (the per-project dict) and serialises disc_entries into the active discussion's history list
|
- `_flush_to_project()` pulls widget values into `self.project` (the per-project dict) and serialises disc_entries into the active discussion's history list
|
||||||
- `_flush_to_config()` writes global settings ([ai], [theme], [projects]) into `self.config`
|
- `_flush_to_config()` writes global settings ([ai], [theme], [projects]) into `self.config`
|
||||||
- `_save_active_project()` writes `self.project` to the active `.toml` path via `project_manager.save_project()`
|
- `_save_active_project()` writes `self.project` to the active `.toml` path via `project_manager.save_project()`
|
||||||
- `_do_generate()` calls both flush methods, saves both files, then uses `project_manager.flat_config()` to produce the dict that `aggregate.run()` expects — so `aggregate.py` needs zero changes
|
- `_do_generate()` calls both flush methods, saves both files, then uses `project_manager.flat_config()` to produce the dict that `aggregate.run()` expects — so `aggregate.py` needs zero changes
|
||||||
- Switching projects: saves current project, loads new one, refreshes all GUI state, resets AI session
|
- Switching projects: saves current project, loads new one, refreshes all GUI state, resets AI session
|
||||||
- New project: file dialog for save path, creates default project structure, saves it, switches to it
|
- New project: file dialog for save path, creates default project structure, saves it, switches to it
|
||||||
|
|
||||||
@@ -75,14 +71,14 @@ Is a local GUI tool for manually curating and sending context to AI APIs. It agg
|
|||||||
- Timestamps: each disc entry carries a `ts` field (ISO datetime); shown next to the role combo; new entries from `-> History` or `+ Entry` get `now_ts()`
|
- Timestamps: each disc entry carries a `ts` field (ISO datetime); shown next to the role combo; new entries from `-> History` or `+ Entry` get `now_ts()`
|
||||||
|
|
||||||
**Entry serialisation (project_manager):**
|
**Entry serialisation (project_manager):**
|
||||||
- `entry_to_str(entry)` → `"@<ts>\n<role>:\n<content>"` (or `"<role>:\n<content>"` if no ts)
|
- `entry_to_str(entry)` → `"@<ts>\n<role>:\n<content>"` (or `"<role>:\n<content>"` if no ts)
|
||||||
- `str_to_entry(raw, roles)` → parses optional `@<ts>` prefix, then role line, then content; returns `{role, content, collapsed, ts}`
|
- `str_to_entry(raw, roles)` → parses optional `@<ts>` prefix, then role line, then content; returns `{role, content, collapsed, ts}`
|
||||||
- Round-trips correctly through TOML string arrays; handles legacy entries without timestamps
|
- Round-trips correctly through TOML string arrays; handles legacy entries without timestamps
|
||||||
|
|
||||||
**AI Tool Use (PowerShell):**
|
**AI Tool Use (PowerShell):**
|
||||||
- Both Gemini and Anthropic are configured with a `run_powershell` tool/function declaration
|
- Both Gemini and Anthropic are configured with a `run_powershell` tool/function declaration
|
||||||
- When the AI wants to edit or create files it emits a tool call with a `script` string
|
- When the AI wants to edit or create files it emits a tool call with a `script` string
|
||||||
- `ai_client` runs a loop (max `MAX_TOOL_ROUNDS = 5`) feeding tool results back until the AI stops calling tools
|
- `ai_client` runs a loop (max `MAX_TOOL_ROUNDS = 10`) feeding tool results back until the AI stops calling tools
|
||||||
- Before any script runs, `gui.py` shows a modal `ConfirmDialog` on the main thread; the background send thread blocks on a `threading.Event` until the user clicks Approve or Reject
|
- Before any script runs, `gui.py` shows a modal `ConfirmDialog` on the main thread; the background send thread blocks on a `threading.Event` until the user clicks Approve or Reject
|
||||||
- The dialog displays `base_dir`, shows the script in an editable text box (allowing last-second tweaks), and has Approve & Run / Reject buttons
|
- The dialog displays `base_dir`, shows the script in an editable text box (allowing last-second tweaks), and has Approve & Run / Reject buttons
|
||||||
- On approval the (possibly edited) script is passed to `shell_runner.run_powershell()` which prepends `Set-Location -LiteralPath '<base_dir>'` and runs it via `powershell -NoProfile -NonInteractive -Command`
|
- On approval the (possibly edited) script is passed to `shell_runner.run_powershell()` which prepends `Set-Location -LiteralPath '<base_dir>'` and runs it via `powershell -NoProfile -NonInteractive -Command`
|
||||||
@@ -90,6 +86,15 @@ Is a local GUI tool for manually curating and sending context to AI APIs. It agg
|
|||||||
- Rejections return `"USER REJECTED: command was not executed"` to the AI
|
- Rejections return `"USER REJECTED: command was not executed"` to the AI
|
||||||
- All tool calls (script + result/rejection) are appended to `_tool_log` and displayed in the Tool Calls panel
|
- All tool calls (script + result/rejection) are appended to `_tool_log` and displayed in the Tool Calls panel
|
||||||
|
|
||||||
|
**Dynamic file context refresh (ai_client.py):**
|
||||||
|
- After the last tool call in each round, project files from `file_items` are checked via `_reread_file_items()`. It uses `mtime` to only re-read modified files, returning only the `changed` files to build a minimal `[FILES UPDATED]` block.
|
||||||
|
- For Anthropic: the refreshed file contents are injected as a `text` block appended to the `tool_results` user message, prefixed with `[FILES UPDATED]` and an instruction not to re-read them.
|
||||||
|
- For Gemini: refreshed file contents are appended to the last function response's `output` string as a `[SYSTEM: FILES UPDATED]` block. On the next tool round, stale `[FILES UPDATED]` blocks are stripped from history and old tool outputs are truncated to `_history_trunc_limit` characters to control token growth.
|
||||||
|
- `_build_file_context_text(file_items)` formats the refreshed files as markdown code blocks (same format as the original context)
|
||||||
|
- The `tool_result_send` comms log entry filters out the injected text block (only logs actual `tool_result` entries) to keep the comms panel clean
|
||||||
|
- `file_items` flows from `aggregate.build_file_items()` → `gui.py` `self.last_file_items` → `ai_client.send(file_items=...)` → `_send_anthropic(file_items=...)` / `_send_gemini(file_items=...)`
|
||||||
|
- System prompt updated to tell the AI: "the user's context files are automatically refreshed after every tool call, so you do NOT need to re-read files that are already provided in the <context> block"
|
||||||
|
|
||||||
**Anthropic bug fixes applied (session history):**
|
**Anthropic bug fixes applied (session history):**
|
||||||
- Bug 1: SDK ContentBlock objects now converted to plain dicts via `_content_block_to_dict()` before storing in `_anthropic_history`; prevents re-serialisation failures on subsequent tool-use rounds
|
- Bug 1: SDK ContentBlock objects now converted to plain dicts via `_content_block_to_dict()` before storing in `_anthropic_history`; prevents re-serialisation failures on subsequent tool-use rounds
|
||||||
- Bug 2: `_repair_anthropic_history` simplified to dict-only path since history always contains dicts
|
- Bug 2: `_repair_anthropic_history` simplified to dict-only path since history always contains dicts
|
||||||
@@ -105,7 +110,7 @@ Is a local GUI tool for manually curating and sending context to AI APIs. It agg
|
|||||||
- `comms_log_callback` (injected by gui.py) is called from the background thread with each new entry; gui queues entries in `_pending_comms` (lock-protected) and flushes them to the DPG panel each render frame
|
- `comms_log_callback` (injected by gui.py) is called from the background thread with each new entry; gui queues entries in `_pending_comms` (lock-protected) and flushes them to the DPG panel each render frame
|
||||||
- `COMMS_CLAMP_CHARS = 300` in gui.py governs the display cutoff for heavy text fields
|
- `COMMS_CLAMP_CHARS = 300` in gui.py governs the display cutoff for heavy text fields
|
||||||
|
|
||||||
**Comms History panel — rich structured rendering (gui.py):**
|
**Comms History panel — rich structured rendering (gui.py):**
|
||||||
|
|
||||||
Rather than showing raw JSON, each comms entry is rendered using a kind-specific renderer function. Unknown kinds fall back to a generic key/value layout.
|
Rather than showing raw JSON, each comms entry is rendered using a kind-specific renderer function. Unknown kinds fall back to a generic key/value layout.
|
||||||
|
|
||||||
@@ -115,18 +120,18 @@ Colour maps:
|
|||||||
- Labels: grey `(180,180,180)`; values: near-white `(220,220,220)`; dict keys/indices: `(140,200,255)`; numbers/token counts: `(180,255,180)`; sub-headers: `(220,200,120)`
|
- Labels: grey `(180,180,180)`; values: near-white `(220,220,220)`; dict keys/indices: `(140,200,255)`; numbers/token counts: `(180,255,180)`; sub-headers: `(220,200,120)`
|
||||||
|
|
||||||
Helper functions:
|
Helper functions:
|
||||||
- `_add_text_field(parent, label, value)` — labelled text; strings longer than `COMMS_CLAMP_CHARS` render as an 80px readonly scrollable `input_text`; shorter strings render as `add_text`
|
- `_add_text_field(parent, label, value)` — labelled text; strings longer than `COMMS_CLAMP_CHARS` render as an 80px readonly scrollable `input_text`; shorter strings render as `add_text`
|
||||||
- `_add_kv_row(parent, key, val)` — single horizontal key: value row
|
- `_add_kv_row(parent, key, val)` — single horizontal key: value row
|
||||||
- `_render_usage(parent, usage)` — renders Anthropic token usage dict in a fixed display order (input → cache_read → cache_creation → output)
|
- `_render_usage(parent, usage)` — renders Anthropic token usage dict in a fixed display order (input → cache_read → cache_creation → output)
|
||||||
- `_render_tool_calls_list(parent, tool_calls)` — iterates tool call list, showing name, id, and all args via `_add_text_field`
|
- `_render_tool_calls_list(parent, tool_calls)` — iterates tool call list, showing name, id, and all args via `_add_text_field`
|
||||||
|
|
||||||
Kind-specific renderers (in `_KIND_RENDERERS` dict, dispatched by `_render_comms_entry`):
|
Kind-specific renderers (in `_KIND_RENDERERS` dict, dispatched by `_render_comms_entry`):
|
||||||
- `_render_payload_request` — shows `message` field via `_add_text_field`
|
- `_render_payload_request` — shows `message` field via `_add_text_field`
|
||||||
- `_render_payload_response` — shows round, stop_reason (orange), text, tool_calls list, usage block
|
- `_render_payload_response` — shows round, stop_reason (orange), text, tool_calls list, usage block
|
||||||
- `_render_payload_tool_call` — shows name, optional id, script via `_add_text_field`
|
- `_render_payload_tool_call` — shows name, optional id, script via `_add_text_field`
|
||||||
- `_render_payload_tool_result` — shows name, optional id, output via `_add_text_field`
|
- `_render_payload_tool_result` — shows name, optional id, output via `_add_text_field`
|
||||||
- `_render_payload_tool_result_send` — iterates results list, shows tool_use_id and content per result
|
- `_render_payload_tool_result_send` — iterates results list, shows tool_use_id and content per result
|
||||||
- `_render_payload_generic` — fallback for unknown kinds; renders all keys, using `_add_text_field` for keys in `_HEAVY_KEYS`, `_add_kv_row` for others; dicts/lists are JSON-serialised
|
- `_render_payload_generic` — fallback for unknown kinds; renders all keys, using `_add_text_field` for keys in `_HEAVY_KEYS`, `_add_kv_row` for others; dicts/lists are JSON-serialised
|
||||||
|
|
||||||
Entry layout: index + timestamp + direction + kind + provider/model header row, then payload rendered by the appropriate function, then a separator line.
|
Entry layout: index + timestamp + direction + kind + provider/model header row, then payload rendered by the appropriate function, then a separator line.
|
||||||
|
|
||||||
@@ -136,10 +141,14 @@ Entry layout: index + timestamp + direction + kind + provider/model header row,
|
|||||||
- `log_tool_call(script, result, script_path)` writes the script to `scripts/generated/<ts>_<seq:04d>.ps1` and appends a markdown record to the toolcalls log without the script body (just the file path + result); uses a `threading.Lock` for the sequence counter
|
- `log_tool_call(script, result, script_path)` writes the script to `scripts/generated/<ts>_<seq:04d>.ps1` and appends a markdown record to the toolcalls log without the script body (just the file path + result); uses a `threading.Lock` for the sequence counter
|
||||||
- `close_session()` flushes and closes both file handles; called just before `dpg.destroy_context()`
|
- `close_session()` flushes and closes both file handles; called just before `dpg.destroy_context()`
|
||||||
|
|
||||||
**Anthropic prompt caching:**
|
**Anthropic prompt caching & history management:**
|
||||||
- System prompt sent as an array with `cache_control: ephemeral` on the text block
|
- System prompt + context are combined into one string, chunked into <=120k char blocks, and sent as the `system=` parameter array. Only the LAST chunk gets `cache_control: ephemeral`, so the entire system prefix is cached as one unit.
|
||||||
- Last tool in `_ANTHROPIC_TOOLS` has `cache_control: ephemeral`; system + tools prefix is cached together after the first request
|
- Last tool in `_ANTHROPIC_TOOLS` (`run_powershell`) has `cache_control: ephemeral`; this means the tools prefix is cached together with the system prefix after the first request.
|
||||||
- First user message content[0] is the `<context>` block with `cache_control: ephemeral`; content[1] is the user question without cache control
|
- The user message is sent as a plain `[{"type": "text", "text": user_message}]` block with NO cache_control. The context lives in `system=`, not in the first user message.
|
||||||
|
- `_add_history_cache_breakpoint` places `cache_control:ephemeral` on the last content block of the second-to-last user message, using the 4th cache breakpoint to cache the conversation history prefix.
|
||||||
|
- `_trim_anthropic_history` uses token estimation (`_CHARS_PER_TOKEN = 3.5`) to keep the prompt under `_ANTHROPIC_MAX_PROMPT_TOKENS = 180_000`. It strips stale file refreshes from old turns, and drops oldest turn pairs if still over budget.
|
||||||
|
- The tools list is built once per session via `_get_anthropic_tools()` and reused across all API calls within the tool loop, avoiding redundant Python-side reconstruction.
|
||||||
|
- `_strip_cache_controls()` removes stale `cache_control` markers from all history entries before each API call, ensuring only the stable system/tools prefix consumes cache breakpoint slots.
|
||||||
- Cache stats (creation tokens, read tokens) are surfaced in the comms log usage dict and displayed in the Comms History panel
|
- Cache stats (creation tokens, read tokens) are surfaced in the comms log usage dict and displayed in the Comms History panel
|
||||||
|
|
||||||
**Data flow:**
|
**Data flow:**
|
||||||
@@ -153,8 +162,8 @@ Entry layout: index + timestamp + direction + kind + provider/model header row,
|
|||||||
8. Sessions are stateful within a run (chat history maintained), `Reset` clears them, the tool log, and the comms log
|
8. Sessions are stateful within a run (chat history maintained), `Reset` clears them, the tool log, and the comms log
|
||||||
|
|
||||||
**Config persistence:**
|
**Config persistence:**
|
||||||
- `config.toml` — global only: `[ai]` provider+model, `[theme]` palette+font+scale, `[projects]` paths array + active path
|
- `config.toml` — global only: `[ai]` provider+model, `[theme]` palette+font+scale, `[projects]` paths array + active path
|
||||||
- `<project>.toml` — per-project: output, files, screenshots, discussion (roles, active discussion name, all named discussions with their history+metadata)
|
- `<project>.toml` — per-project: output, files, screenshots, discussion (roles, active discussion name, all named discussions with their history+metadata)
|
||||||
- On every send and save, both files are written
|
- On every send and save, both files are written
|
||||||
- On clean exit, `run()` calls `_flush_to_project()`, `_save_active_project()`, `_flush_to_config()`, `save_config()` before destroying context
|
- On clean exit, `run()` calls `_flush_to_project()`, `_save_active_project()`, `_flush_to_config()`, `save_config()` before destroying context
|
||||||
|
|
||||||
@@ -170,10 +179,105 @@ Entry layout: index + timestamp + direction + kind + provider/model header row,
|
|||||||
- `_classify_anthropic_error` and `_classify_gemini_error` inspect exception types and status codes/message bodies to assign the kind
|
- `_classify_anthropic_error` and `_classify_gemini_error` inspect exception types and status codes/message bodies to assign the kind
|
||||||
- `ui_message()` returns a human-readable label for display in the Response panel
|
- `ui_message()` returns a human-readable label for display in the Response panel
|
||||||
|
|
||||||
|
**MCP file tools (mcp_client.py + ai_client.py):**
|
||||||
|
- Four read-only tools exposed to the AI as native function/tool declarations: `read_file`, `list_directory`, `search_files`, `get_file_summary`
|
||||||
|
- Access control: `mcp_client.configure(file_items, extra_base_dirs)` is called before each send; builds an allowlist of resolved absolute paths from the project's `file_items` plus the `base_dir`; any path that is not explicitly in the list or not under one of the allowed directories returns `ACCESS DENIED`
|
||||||
|
- `mcp_client.dispatch(tool_name, tool_input)` is the single dispatch entry point used by both Anthropic and Gemini tool-use loops; `TOOL_NAMES` set now includes all six tool names
|
||||||
|
- Anthropic: MCP tools appear before `run_powershell` in the tools list (no `cache_control` on them; only `run_powershell` carries `cache_control: ephemeral`)
|
||||||
|
- Gemini: MCP tools are included in the `FunctionDeclaration` list alongside `run_powershell`
|
||||||
|
- `get_file_summary` uses `summarize.summarise_file()` — same heuristic used for the initial `<context>` block, so the AI gets the same compact structural view it already knows
|
||||||
|
- `list_directory` sorts dirs before files; shows name, type, and size
|
||||||
|
- `search_files` uses `Path.glob()` with the caller-supplied pattern (supports `**/*.py` style)
|
||||||
|
- `read_file` returns raw UTF-8 text; errors (not found, access denied, decode error) are returned as error strings rather than exceptions, so the AI sees them as tool results
|
||||||
|
- `web_search(query)` queries DuckDuckGo HTML endpoint and returns the top 5 results (title, URL, snippet) as a formatted string; uses a custom `_DDGParser` (HTMLParser subclass)
|
||||||
|
- `fetch_url(url)` fetches a URL, strips HTML tags/scripts via `_TextExtractor` (HTMLParser subclass), collapses whitespace, and truncates to 40k chars to prevent context blowup; handles DuckDuckGo redirect links automatically
|
||||||
|
- `summarize.py` heuristics: `.py` → AST imports + ALL_CAPS constants + classes+methods + top-level functions; `.toml` → table headers + top-level keys; `.md` → h1–h3 headings with indentation; all others → line count + first 8 lines preview
|
||||||
|
- Comms log: MCP tool calls log `OUT/tool_call` with `{"name": ..., "args": {...}}` and `IN/tool_result` with `{"name": ..., "output": ...}`; rendered in the Comms History panel via `_render_payload_tool_call` (shows each arg key/value) and `_render_payload_tool_result` (shows output)
|
||||||
|
|
||||||
**Known extension points:**
|
**Known extension points:**
|
||||||
- Add more providers by adding a section to `credentials.toml`, a `_list_*` and `_send_*` function in `ai_client.py`, and the provider name to the `PROVIDERS` list in `gui.py`
|
- Add more providers by adding a section to `credentials.toml`, a `_list_*` and `_send_*` function in `ai_client.py`, and the provider name to the `PROVIDERS` list in `gui.py`
|
||||||
- System prompt support could be added as a field in the project `.toml` and passed in `ai_client.send()`
|
|
||||||
- Discussion history excerpts could be individually toggleable for inclusion in the generated md
|
- Discussion history excerpts could be individually toggleable for inclusion in the generated md
|
||||||
- `MAX_TOOL_ROUNDS` in `ai_client.py` caps agentic loops at 5 rounds; adjustable
|
- `MAX_TOOL_ROUNDS` in `ai_client.py` caps agentic loops at 10 rounds; adjustable
|
||||||
- `COMMS_CLAMP_CHARS` in `gui.py` controls the character threshold for clamping heavy payload fields in the Comms History panel
|
- `COMMS_CLAMP_CHARS` in `gui.py` controls the character threshold for clamping heavy payload fields in the Comms History panel
|
||||||
- Additional project metadata (description, tags, created date) could be added to `[project]` in the per-project toml
|
- Additional project metadata (description, tags, created date) could be added to `[project]` in the per-project toml
|
||||||
|
|
||||||
|
### Gemini Context Management
|
||||||
|
- Gemini uses explicit caching via `client.caches.create()` to store the `system_instruction` + tools as an immutable cached prefix with a 1-hour TTL. The cache is created once per chat session.
|
||||||
|
- Proactively rebuilds cache at 90% of `_GEMINI_CACHE_TTL = 3600` to avoid stale-reference errors.
|
||||||
|
- When context changes (detected via `md_content` hash), the old cache is deleted, a new cache is created, and chat history is migrated to a fresh chat session pointing at the new cache.
|
||||||
|
- Trims history by dropping oldest pairs if input tokens exceed `_GEMINI_MAX_INPUT_TOKENS = 900_000`.
|
||||||
|
- If cache creation fails (e.g., content is under the minimum token threshold — 1024 for Flash, 4096 for Pro), the system falls back to inline `system_instruction` in the chat config. Implicit caching may still provide cost savings in this case.
|
||||||
|
- The `<context>` block lives inside `system_instruction`, NOT in user messages, preventing history bloat across turns.
|
||||||
|
- On cleanup/exit, active caches are deleted via `ai_client.cleanup()` to prevent orphaned billing.
|
||||||
|
|
||||||
|
### Latest Changes
|
||||||
|
- Removed `Config` panel from the GUI to streamline per-project configuration.
|
||||||
|
- `output_dir` was moved into the Projects panel.
|
||||||
|
- `auto_add_history` was moved to the Discussion History panel.
|
||||||
|
- `namespace` is no longer a configurable field; `aggregate.py` automatically uses the active project's `name` property.
|
||||||
|
|
||||||
|
### UI / Visual Updates
|
||||||
|
- The success blink notification on the response text box is now dimmer and more transparent to be less visually jarring.
|
||||||
|
- Added a new floating **Last Script Output** popup window. This window automatically displays and blinks blue whenever the AI executes a PowerShell tool, showing both the executed script and its result in real-time.
|
||||||
|
|
||||||
|
|
||||||
|
## Recent Changes (Text Viewer Maximization)
|
||||||
|
- **Global Text Viewer (gui.py)**: Added a dedicated, large popup window (win_text_viewer) to allow reading and scrolling through large, dense text blocks without feeling cramped.
|
||||||
|
- **Comms History**: Every multi-line text field in the comms log now has a [+] button next to its label that opens the text in the Global Text Viewer.
|
||||||
|
- **Tool Log History**: Added [+ Script] and [+ Output] buttons next to each logged tool call to easily maximize and read the full executed scripts and raw tool outputs.
|
||||||
|
- **Last Script Output Popup**: Expanded the default size of the popup (now 800x600) and gave the input script panel more vertical space to prevent it from feeling 'scrunched'. Added [+ Maximize] buttons for both the script and the output sections to inspect them in full detail.
|
||||||
|
- **Confirm Dialog**: The script confirmation modal now has a [+ Maximize] button so you can read large generated scripts in full-screen before approving them.
|
||||||
|
|
||||||
|
## UI Enhancements (2026-02-21)
|
||||||
|
|
||||||
|
### Global Word-Wrap
|
||||||
|
|
||||||
|
A new **Word-Wrap** checkbox has been added to the **Projects** panel. This setting is saved per-project in its .toml file.
|
||||||
|
|
||||||
|
- When **enabled** (default), long text in read-only panels (like the main Response window, Tool Call outputs, and Comms History) will wrap to fit the panel width.
|
||||||
|
- When **disabled**, text will not wrap, and a horizontal scrollbar will appear for oversized content.
|
||||||
|
|
||||||
|
This allows you to choose the best viewing mode for either prose or wide code blocks.
|
||||||
|
|
||||||
|
### Maximizable Discussion Entries
|
||||||
|
|
||||||
|
Each entry in the **Discussion History** now features a [+ Max] button. Clicking this button opens the full text of that entry in the large **Text Viewer** popup, making it easy to read or copy large blocks of text from the conversation history without being constrained by the small input box.
|
||||||
|
\n\n## Multi-Viewport & Docking\nThe application now supports Dear PyGui Viewport Docking. Windows can be dragged outside the main application area or docked together. A global 'Windows' menu in the viewport menu bar allows you to reopen any closed panels.
|
||||||
|
|
||||||
|
## Extensive Documentation (2026-02-22)
|
||||||
|
|
||||||
|
Documentation has been completely rewritten matching the strict, structural format of `VEFontCache-Odin`.
|
||||||
|
- `docs/guide_architecture.md`: Details the Python implementation algorithms, queue management for UI rendering, the specific AST heuristics used for context aggregation, and the distinct algorithms for trimming Anthropic history vs Gemini state caching.
|
||||||
|
- `docs/Readme.md`: The core interface manual.
|
||||||
|
- `docs/guide_tools.md`: Security architecture for `_is_allowed` paths and definitions of the read-only vs destructive tool pipeline.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Updates (2026-02-22 — ai_client.py & aggregate.py)
|
||||||
|
|
||||||
|
### mcp_client.py — Web Tools Added
|
||||||
|
- `web_search(query)` and `fetch_url(url)` added as two new MCP tools alongside the existing four file tools.
|
||||||
|
- `TOOL_NAMES` set updated to include all six tool names for dispatch routing.
|
||||||
|
- `MCP_TOOL_SPECS` list extended with full JSON schema definitions for both web tools.
|
||||||
|
- Both tools are declared in `_build_anthropic_tools()` and `_gemini_tool_declaration()` so they are available to both providers.
|
||||||
|
- Web tools bypass the `_is_allowed` path check (no filesystem access); file tools retain the allowlist enforcement.
|
||||||
|
|
||||||
|
### aggregate.py — run() double-I/O elimination
|
||||||
|
- `run()` now calls `build_file_items()` once, then passes the result to `build_markdown_from_items()` instead of calling `build_files_section()` separately. This avoids reading every file twice per send.
|
||||||
|
- `build_markdown_from_items()` accepts a `summary_only` flag (default `False`); when `False` it inlines full file content; when `True` it delegates to `summarize.build_summary_markdown()` for compact structural summaries.
|
||||||
|
- `run()` returns a 3-tuple `(markdown_str, output_path, file_items)` — the `file_items` list is passed through to `gui.py` as `self.last_file_items` for dynamic context refresh after tool calls.
|
||||||
|
|
||||||
|
|
||||||
|
## Updates (2026-02-22 — gui.py [+ Maximize] bug fix)
|
||||||
|
|
||||||
|
### Problem
|
||||||
|
Three `[+ Maximize]` buttons were reading their text content via `dpg.get_value(tag)` at click time:
|
||||||
|
1. `ConfirmDialog.show()` — passed `f"{self._tag}_script"` as `user_data` and called `dpg.get_value(u)` in the lambda. If the dialog was dismissed before the viewer opened, the item no longer existed and the call would fail silently or crash.
|
||||||
|
2. `win_script_output` Script `[+ Maximize]` — used `user_data="last_script_text"` and `dpg.get_value(u)`. When word-wrap is ON, `last_script_text` is hidden (`show=False`); in some DPG versions `dpg.get_value` on a hidden `input_text` returns `""`.
|
||||||
|
3. `win_script_output` Output `[+ Maximize]` — same issue with `"last_script_output"`.
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
- `ConfirmDialog.show()`: changed `user_data` to `self._script` (the actual text string captured at button-creation time) and the callback to `lambda s, a, u: _show_text_viewer("Confirm Script", u)`. The text is now baked in at dialog construction, not read from a potentially-deleted widget.
|
||||||
|
- `App._append_tool_log()`: added `self._last_script = script` and `self._last_output = result` assignments so the latest values are always available as instance state.
|
||||||
|
- `win_script_output` buttons: both `[+ Maximize]` buttons now use `lambda s, a, u: _show_text_viewer("...", self._last_script/output)` directly, bypassing DPG widget state entirely.
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Manual Slop
|
||||||
|
|
||||||
|
Vibe coding.. but more manual
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
This tool is designed to work as an auxiliary assistant that natively interacts with your codebase via PowerShell and MCP-like file tools, supporting both Anthropic and Gemini APIs.
|
||||||
|
|
||||||
|
Features:
|
||||||
|
|
||||||
|
* Multi-provider support (Anthropic & Gemini).
|
||||||
|
* Multi-project workspace management via TOML configuration.
|
||||||
|
* Rich discussion history with branching and timestamps.
|
||||||
|
* Real-time file context aggregation and summarization.
|
||||||
|
* Integrated tool execution:
|
||||||
|
* PowerShell scripting for file modifications.
|
||||||
|
* MCP-like filesystem tools (read, list, search, summarize).
|
||||||
|
* Web search and URL fetching.
|
||||||
|
* Extensive UI features:
|
||||||
|
* Word-wrap toggles.
|
||||||
|
* Popup text viewers for large script/output inspection.
|
||||||
|
* Color theming and UI scaling.
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
* [docs/Readme.md](docs/Readme.md) for the interface and usage guide
|
||||||
|
* [docs/guide_tools.md](docs/guide_tools.md) for information on the AI tooling capabilities
|
||||||
|
* [docs/guide_architecture.md](docs/guide_architecture.md) for an in-depth breakdown of the codebase architecture
|
||||||
|
|
||||||
|
## Instructions
|
||||||
|
|
||||||
|
1. Make a credentials.toml in the immediate directory of your clone:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[gemini]
|
||||||
|
api_key = "****"
|
||||||
|
[anthropic]
|
||||||
|
api_key = "****"
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Have fun. This is experiemntal slop.
|
||||||
|
|
||||||
|
```ps1
|
||||||
|
uv run .\gui.py
|
||||||
|
```
|
||||||
+80
-13
@@ -1,8 +1,21 @@
|
|||||||
# aggregate.py
|
# aggregate.py
|
||||||
|
"""
|
||||||
|
Note(Gemini):
|
||||||
|
This module orchestrates the construction of the final Markdown context string.
|
||||||
|
Instead of sending every file to the AI raw (which blows up tokens), this uses a pipeline:
|
||||||
|
1. Resolve paths (handles globs and absolute paths).
|
||||||
|
2. Build file items (raw content).
|
||||||
|
3. If 'summary_only' is true (which is the default behavior now), it pipes the files through
|
||||||
|
summarize.py to generate a compacted view.
|
||||||
|
|
||||||
|
This is essential for keeping prompt tokens low while giving the AI enough structural info
|
||||||
|
to use the MCP tools to fetch only what it needs.
|
||||||
|
"""
|
||||||
import tomllib
|
import tomllib
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
from pathlib import Path, PureWindowsPath
|
from pathlib import Path, PureWindowsPath
|
||||||
|
import summarize
|
||||||
|
|
||||||
def find_next_increment(output_dir: Path, namespace: str) -> int:
|
def find_next_increment(output_dir: Path, namespace: str) -> int:
|
||||||
pattern = re.compile(rf"^{re.escape(namespace)}_(\d+)\.md$")
|
pattern = re.compile(rf"^{re.escape(namespace)}_(\d+)\.md$")
|
||||||
@@ -85,37 +98,91 @@ def build_file_items(base_dir: Path, files: list[str]) -> list[dict]:
|
|||||||
entry : str (original config entry string)
|
entry : str (original config entry string)
|
||||||
content : str (file text, or error string)
|
content : str (file text, or error string)
|
||||||
error : bool
|
error : bool
|
||||||
|
mtime : float (last modification time, for skip-if-unchanged optimization)
|
||||||
"""
|
"""
|
||||||
items = []
|
items = []
|
||||||
for entry in files:
|
for entry in files:
|
||||||
paths = resolve_paths(base_dir, entry)
|
paths = resolve_paths(base_dir, entry)
|
||||||
if not paths:
|
if not paths:
|
||||||
items.append({"path": None, "entry": entry, "content": f"ERROR: no files matched: {entry}", "error": True})
|
items.append({"path": None, "entry": entry, "content": f"ERROR: no files matched: {entry}", "error": True, "mtime": 0.0})
|
||||||
continue
|
continue
|
||||||
for path in paths:
|
for path in paths:
|
||||||
try:
|
try:
|
||||||
content = path.read_text(encoding="utf-8")
|
content = path.read_text(encoding="utf-8")
|
||||||
|
mtime = path.stat().st_mtime
|
||||||
error = False
|
error = False
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
content = f"ERROR: file not found: {path}"
|
content = f"ERROR: file not found: {path}"
|
||||||
|
mtime = 0.0
|
||||||
error = True
|
error = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
content = f"ERROR: {e}"
|
content = f"ERROR: {e}"
|
||||||
|
mtime = 0.0
|
||||||
error = True
|
error = True
|
||||||
items.append({"path": path, "entry": entry, "content": content, "error": error})
|
items.append({"path": path, "entry": entry, "content": content, "error": error, "mtime": mtime})
|
||||||
return items
|
return items
|
||||||
def build_markdown(base_dir: Path, files: list[str], screenshot_base_dir: Path, screenshots: list[str], history: list[str]) -> str:
|
|
||||||
|
def build_summary_section(base_dir: Path, files: list[str]) -> str:
|
||||||
|
"""
|
||||||
|
Build a compact summary section using summarize.py — one short block per file.
|
||||||
|
Used as the initial <context> block instead of full file contents.
|
||||||
|
"""
|
||||||
|
items = build_file_items(base_dir, files)
|
||||||
|
return summarize.build_summary_markdown(items)
|
||||||
|
|
||||||
|
def _build_files_section_from_items(file_items: list[dict]) -> str:
|
||||||
|
"""Build the files markdown section from pre-read file items (avoids double I/O)."""
|
||||||
|
sections = []
|
||||||
|
for item in file_items:
|
||||||
|
path = item.get("path")
|
||||||
|
entry = item.get("entry", "unknown")
|
||||||
|
content = item.get("content", "")
|
||||||
|
if path is None:
|
||||||
|
sections.append(f"### `{entry}`\n\n```text\n{content}\n```")
|
||||||
|
continue
|
||||||
|
suffix = path.suffix.lstrip(".") if hasattr(path, "suffix") else "text"
|
||||||
|
lang = suffix if suffix else "text"
|
||||||
|
original = entry if "*" not in entry else str(path)
|
||||||
|
sections.append(f"### `{original}`\n\n```{lang}\n{content}\n```")
|
||||||
|
return "\n\n---\n\n".join(sections)
|
||||||
|
|
||||||
|
|
||||||
|
def build_markdown_from_items(file_items: list[dict], screenshot_base_dir: Path, screenshots: list[str], history: list[str], summary_only: bool = False) -> str:
|
||||||
|
"""Build markdown from pre-read file items instead of re-reading from disk."""
|
||||||
parts = []
|
parts = []
|
||||||
if history:
|
# STATIC PREFIX: Files and Screenshots must go first to maximize Cache Hits
|
||||||
parts.append("## Discussion History\n\n" + build_discussion_section(history))
|
if file_items:
|
||||||
if files:
|
if summary_only:
|
||||||
parts.append("## Files\n\n" + build_files_section(base_dir, files))
|
parts.append("## Files (Summary)\n\n" + summarize.build_summary_markdown(file_items))
|
||||||
|
else:
|
||||||
|
parts.append("## Files\n\n" + _build_files_section_from_items(file_items))
|
||||||
if screenshots:
|
if screenshots:
|
||||||
parts.append("## Screenshots\n\n" + build_screenshots_section(screenshot_base_dir, screenshots))
|
parts.append("## Screenshots\n\n" + build_screenshots_section(screenshot_base_dir, screenshots))
|
||||||
|
# DYNAMIC SUFFIX: History changes every turn, must go last
|
||||||
|
if history:
|
||||||
|
parts.append("## Discussion History\n\n" + build_discussion_section(history))
|
||||||
return "\n\n---\n\n".join(parts)
|
return "\n\n---\n\n".join(parts)
|
||||||
|
|
||||||
def run(config: dict) -> tuple[str, Path]:
|
|
||||||
namespace = config["output"]["namespace"]
|
def build_markdown(base_dir: Path, files: list[str], screenshot_base_dir: Path, screenshots: list[str], history: list[str], summary_only: bool = False) -> str:
|
||||||
|
parts = []
|
||||||
|
# STATIC PREFIX: Files and Screenshots must go first to maximize Cache Hits
|
||||||
|
if files:
|
||||||
|
if summary_only:
|
||||||
|
parts.append("## Files (Summary)\n\n" + build_summary_section(base_dir, files))
|
||||||
|
else:
|
||||||
|
parts.append("## Files\n\n" + build_files_section(base_dir, files))
|
||||||
|
if screenshots:
|
||||||
|
parts.append("## Screenshots\n\n" + build_screenshots_section(screenshot_base_dir, screenshots))
|
||||||
|
# DYNAMIC SUFFIX: History changes every turn, must go last
|
||||||
|
if history:
|
||||||
|
parts.append("## Discussion History\n\n" + build_discussion_section(history))
|
||||||
|
return "\n\n---\n\n".join(parts)
|
||||||
|
|
||||||
|
def run(config: dict) -> tuple[str, Path, list[dict]]:
|
||||||
|
namespace = config.get("project", {}).get("name")
|
||||||
|
if not namespace:
|
||||||
|
namespace = config.get("output", {}).get("namespace", "project")
|
||||||
output_dir = Path(config["output"]["output_dir"])
|
output_dir = Path(config["output"]["output_dir"])
|
||||||
base_dir = Path(config["files"]["base_dir"])
|
base_dir = Path(config["files"]["base_dir"])
|
||||||
files = config["files"].get("paths", [])
|
files = config["files"].get("paths", [])
|
||||||
@@ -126,9 +193,11 @@ def run(config: dict) -> tuple[str, Path]:
|
|||||||
output_dir.mkdir(parents=True, exist_ok=True)
|
output_dir.mkdir(parents=True, exist_ok=True)
|
||||||
increment = find_next_increment(output_dir, namespace)
|
increment = find_next_increment(output_dir, namespace)
|
||||||
output_file = output_dir / f"{namespace}_{increment:03d}.md"
|
output_file = output_dir / f"{namespace}_{increment:03d}.md"
|
||||||
markdown = build_markdown(base_dir, files, screenshot_base_dir, screenshots, history)
|
# Build file items once, then construct markdown from them (avoids double I/O)
|
||||||
output_file.write_text(markdown, encoding="utf-8")
|
|
||||||
file_items = build_file_items(base_dir, files)
|
file_items = build_file_items(base_dir, files)
|
||||||
|
markdown = build_markdown_from_items(file_items, screenshot_base_dir, screenshots, history,
|
||||||
|
summary_only=False)
|
||||||
|
output_file.write_text(markdown, encoding="utf-8")
|
||||||
return markdown, output_file, file_items
|
return markdown, output_file, file_items
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -140,5 +209,3 @@ def main():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+778
-169
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,135 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
|
class ApiHookClient:
|
||||||
|
def __init__(self, base_url="http://127.0.0.1:8999", max_retries=5, retry_delay=2):
|
||||||
|
self.base_url = base_url
|
||||||
|
self.max_retries = max_retries
|
||||||
|
self.retry_delay = retry_delay
|
||||||
|
|
||||||
|
def wait_for_server(self, timeout=10):
|
||||||
|
"""
|
||||||
|
Polls the /status endpoint until the server is ready or timeout is reached.
|
||||||
|
"""
|
||||||
|
start_time = time.time()
|
||||||
|
while time.time() - start_time < timeout:
|
||||||
|
try:
|
||||||
|
if self.get_status().get('status') == 'ok':
|
||||||
|
return True
|
||||||
|
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
|
||||||
|
time.sleep(0.5)
|
||||||
|
return False
|
||||||
|
|
||||||
|
def _make_request(self, method, endpoint, data=None):
|
||||||
|
url = f"{self.base_url}{endpoint}"
|
||||||
|
headers = {'Content-Type': 'application/json'}
|
||||||
|
|
||||||
|
last_exception = None
|
||||||
|
for attempt in range(self.max_retries + 1):
|
||||||
|
try:
|
||||||
|
if method == 'GET':
|
||||||
|
response = requests.get(url, timeout=5)
|
||||||
|
elif method == 'POST':
|
||||||
|
response = requests.post(url, json=data, headers=headers, timeout=5)
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unsupported HTTP method: {method}")
|
||||||
|
|
||||||
|
response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx)
|
||||||
|
return response.json()
|
||||||
|
except (requests.exceptions.Timeout, requests.exceptions.ConnectionError) as e:
|
||||||
|
last_exception = e
|
||||||
|
if attempt < self.max_retries:
|
||||||
|
time.sleep(self.retry_delay)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if isinstance(e, requests.exceptions.Timeout):
|
||||||
|
raise requests.exceptions.Timeout(f"Request to {endpoint} timed out after {self.max_retries} retries.") from e
|
||||||
|
else:
|
||||||
|
raise requests.exceptions.ConnectionError(f"Could not connect to API hook server at {self.base_url} after {self.max_retries} retries.") from e
|
||||||
|
except requests.exceptions.HTTPError as e:
|
||||||
|
raise requests.exceptions.HTTPError(f"HTTP error {e.response.status_code} for {endpoint}: {e.response.text}") from e
|
||||||
|
except json.JSONDecodeError as e:
|
||||||
|
raise ValueError(f"Failed to decode JSON from response for {endpoint}: {response.text}") from e
|
||||||
|
|
||||||
|
if last_exception:
|
||||||
|
raise last_exception
|
||||||
|
|
||||||
|
def get_status(self):
|
||||||
|
"""Checks the health of the hook server."""
|
||||||
|
url = f"{self.base_url}/status"
|
||||||
|
try:
|
||||||
|
response = requests.get(url, timeout=1)
|
||||||
|
response.raise_for_status()
|
||||||
|
return response.json()
|
||||||
|
except Exception:
|
||||||
|
raise requests.exceptions.ConnectionError(f"Could not reach /status at {self.base_url}")
|
||||||
|
|
||||||
|
def get_project(self):
|
||||||
|
return self._make_request('GET', '/api/project')
|
||||||
|
|
||||||
|
def post_project(self, project_data):
|
||||||
|
return self._make_request('POST', '/api/project', data={'project': project_data})
|
||||||
|
|
||||||
|
def get_session(self):
|
||||||
|
return self._make_request('GET', '/api/session')
|
||||||
|
|
||||||
|
def get_performance(self):
|
||||||
|
"""Retrieves UI performance metrics."""
|
||||||
|
return self._make_request('GET', '/api/performance')
|
||||||
|
|
||||||
|
def post_session(self, session_entries):
|
||||||
|
return self._make_request('POST', '/api/session', data={'session': {'entries': session_entries}})
|
||||||
|
|
||||||
|
def post_gui(self, gui_data):
|
||||||
|
return self._make_request('POST', '/api/gui', data=gui_data)
|
||||||
|
|
||||||
|
def select_tab(self, tab_bar, tab):
|
||||||
|
"""Tells the GUI to switch to a specific tab in a tab bar."""
|
||||||
|
return self.post_gui({
|
||||||
|
"action": "select_tab",
|
||||||
|
"tab_bar": tab_bar,
|
||||||
|
"tab": tab
|
||||||
|
})
|
||||||
|
|
||||||
|
def select_list_item(self, listbox, item_value):
|
||||||
|
"""Tells the GUI to select an item in a listbox by its value."""
|
||||||
|
return self.post_gui({
|
||||||
|
"action": "select_list_item",
|
||||||
|
"listbox": listbox,
|
||||||
|
"item_value": item_value
|
||||||
|
})
|
||||||
|
|
||||||
|
def set_value(self, item, value):
|
||||||
|
"""Sets the value of a GUI item."""
|
||||||
|
return self.post_gui({
|
||||||
|
"action": "set_value",
|
||||||
|
"item": item,
|
||||||
|
"value": value
|
||||||
|
})
|
||||||
|
|
||||||
|
def click(self, item, *args, **kwargs):
|
||||||
|
"""Simulates a click on a GUI button or item."""
|
||||||
|
user_data = kwargs.pop('user_data', None)
|
||||||
|
return self.post_gui({
|
||||||
|
"action": "click",
|
||||||
|
"item": item,
|
||||||
|
"args": args,
|
||||||
|
"kwargs": kwargs,
|
||||||
|
"user_data": user_data
|
||||||
|
})
|
||||||
|
|
||||||
|
def get_indicator_state(self, tag):
|
||||||
|
"""Checks if an indicator is shown using the diagnostics endpoint."""
|
||||||
|
# Mapping tag to the keys used in diagnostics endpoint
|
||||||
|
mapping = {
|
||||||
|
"thinking_indicator": "thinking",
|
||||||
|
"operations_live_indicator": "live",
|
||||||
|
"prior_session_indicator": "prior"
|
||||||
|
}
|
||||||
|
key = mapping.get(tag, tag)
|
||||||
|
try:
|
||||||
|
diag = self._make_request('GET', '/api/gui/diagnostics')
|
||||||
|
return {"tag": tag, "shown": diag.get(key, False)}
|
||||||
|
except Exception as e:
|
||||||
|
return {"tag": tag, "shown": False, "error": str(e)}
|
||||||
+151
@@ -0,0 +1,151 @@
|
|||||||
|
import json
|
||||||
|
import threading
|
||||||
|
from http.server import HTTPServer, BaseHTTPRequestHandler
|
||||||
|
import logging
|
||||||
|
import session_logger
|
||||||
|
|
||||||
|
class HookServerInstance(HTTPServer):
|
||||||
|
"""Custom HTTPServer that carries a reference to the main App instance."""
|
||||||
|
def __init__(self, server_address, RequestHandlerClass, app):
|
||||||
|
super().__init__(server_address, RequestHandlerClass)
|
||||||
|
self.app = app
|
||||||
|
|
||||||
|
class HookHandler(BaseHTTPRequestHandler):
|
||||||
|
"""Handles incoming HTTP requests for the API hooks."""
|
||||||
|
def do_GET(self):
|
||||||
|
app = self.server.app
|
||||||
|
session_logger.log_api_hook("GET", self.path, "")
|
||||||
|
if self.path == '/status':
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(json.dumps({'status': 'ok'}).encode('utf-8'))
|
||||||
|
elif self.path == '/api/project':
|
||||||
|
import project_manager
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
flat = project_manager.flat_config(app.project)
|
||||||
|
self.wfile.write(json.dumps({'project': flat}).encode('utf-8'))
|
||||||
|
elif self.path == '/api/session':
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(
|
||||||
|
json.dumps({'session': {'entries': app.disc_entries}}).
|
||||||
|
encode('utf-8'))
|
||||||
|
elif self.path == '/api/performance':
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
metrics = {}
|
||||||
|
if hasattr(app, 'perf_monitor'):
|
||||||
|
metrics = app.perf_monitor.get_metrics()
|
||||||
|
self.wfile.write(json.dumps({'performance': metrics}).encode('utf-8'))
|
||||||
|
elif self.path == '/api/gui/diagnostics':
|
||||||
|
# Safe way to query multiple states at once via the main thread queue
|
||||||
|
event = threading.Event()
|
||||||
|
result = {}
|
||||||
|
|
||||||
|
def check_all():
|
||||||
|
import dearpygui.dearpygui as dpg
|
||||||
|
try:
|
||||||
|
result["thinking"] = dpg.is_item_shown("thinking_indicator") if dpg.does_item_exist("thinking_indicator") else False
|
||||||
|
result["live"] = dpg.is_item_shown("operations_live_indicator") if dpg.does_item_exist("operations_live_indicator") else False
|
||||||
|
result["prior"] = dpg.is_item_shown("prior_session_indicator") if dpg.does_item_exist("prior_session_indicator") else False
|
||||||
|
finally:
|
||||||
|
event.set()
|
||||||
|
|
||||||
|
with app._pending_gui_tasks_lock:
|
||||||
|
app._pending_gui_tasks.append({
|
||||||
|
"action": "custom_callback",
|
||||||
|
"callback": check_all
|
||||||
|
})
|
||||||
|
|
||||||
|
if event.wait(timeout=2):
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(json.dumps(result).encode('utf-8'))
|
||||||
|
else:
|
||||||
|
self.send_response(504)
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(json.dumps({'error': 'timeout'}).encode('utf-8'))
|
||||||
|
else:
|
||||||
|
self.send_response(404)
|
||||||
|
self.end_headers()
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
app = self.server.app
|
||||||
|
content_length = int(self.headers.get('Content-Length', 0))
|
||||||
|
body = self.rfile.read(content_length)
|
||||||
|
body_str = body.decode('utf-8') if body else ""
|
||||||
|
session_logger.log_api_hook("POST", self.path, body_str)
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = json.loads(body_str) if body_str else {}
|
||||||
|
if self.path == '/api/project':
|
||||||
|
app.project = data.get('project', app.project)
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(
|
||||||
|
json.dumps({'status': 'updated'}).encode('utf-8'))
|
||||||
|
elif self.path == '/api/session':
|
||||||
|
app.disc_entries = data.get('session', {}).get(
|
||||||
|
'entries', app.disc_entries)
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(
|
||||||
|
json.dumps({'status': 'updated'}).encode('utf-8'))
|
||||||
|
elif self.path == '/api/gui':
|
||||||
|
with app._pending_gui_tasks_lock:
|
||||||
|
app._pending_gui_tasks.append(data)
|
||||||
|
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(
|
||||||
|
json.dumps({'status': 'queued'}).encode('utf-8'))
|
||||||
|
else:
|
||||||
|
self.send_response(404)
|
||||||
|
self.end_headers()
|
||||||
|
except Exception as e:
|
||||||
|
self.send_response(500)
|
||||||
|
self.send_header('Content-Type', 'application/json')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(json.dumps({'error': str(e)}).encode('utf-8'))
|
||||||
|
|
||||||
|
def log_message(self, format, *args):
|
||||||
|
logging.info("Hook API: " + format % args)
|
||||||
|
|
||||||
|
class HookServer:
|
||||||
|
def __init__(self, app, port=8999):
|
||||||
|
self.app = app
|
||||||
|
self.port = port
|
||||||
|
self.server = None
|
||||||
|
self.thread = None
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
if not getattr(self.app, 'test_hooks_enabled', False):
|
||||||
|
return
|
||||||
|
|
||||||
|
# Ensure the app has the task queue and lock initialized
|
||||||
|
if not hasattr(self.app, '_pending_gui_tasks'):
|
||||||
|
self.app._pending_gui_tasks = []
|
||||||
|
if not hasattr(self.app, '_pending_gui_tasks_lock'):
|
||||||
|
self.app._pending_gui_tasks_lock = threading.Lock()
|
||||||
|
|
||||||
|
self.server = HookServerInstance(('127.0.0.1', self.port), HookHandler, self.app)
|
||||||
|
self.thread = threading.Thread(target=self.server.serve_forever, daemon=True)
|
||||||
|
self.thread.start()
|
||||||
|
logging.info(f"Hook server started on port {self.port}")
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
if self.server:
|
||||||
|
self.server.shutdown()
|
||||||
|
self.server.server_close()
|
||||||
|
if self.thread:
|
||||||
|
self.thread.join()
|
||||||
|
logging.info("Hook server stopped")
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track api_hooks_verification_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "api_hooks_verification_20260223",
|
||||||
|
"type": "feature",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T17:46:51Z",
|
||||||
|
"updated_at": "2026-02-23T17:46:51Z",
|
||||||
|
"description": "Update conductor to properly utilize the new api hooks for automated testing & verification of track implementation features without the need of user intervention."
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Implementation Plan: Integrate API Hooks for Automated Track Verification
|
||||||
|
|
||||||
|
## Phase 1: Update Workflow Definition [checkpoint: f17c9e3]
|
||||||
|
- [x] Task: Modify `conductor/workflow.md` to reflect the new automated verification process. [2ec1ecf]
|
||||||
|
- [ ] Sub-task: Update the "Phase Completion Verification and Checkpointing Protocol" section to replace manual verification steps with a description of the automated API hook process.
|
||||||
|
- [ ] Sub-task: Ensure the updated workflow clearly states that the agent will announce the automated test, execute it, and then present the results (success or failure) to the user.
|
||||||
|
- [ ] Task: Conductor - User Manual Verification 'Phase 1: Update Workflow Definition' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: Implement Automated Verification Logic [checkpoint: b575dcd]
|
||||||
|
- [x] Task: Develop the client-side logic for communicating with the API hook server. [f4a9ff8]
|
||||||
|
- [ ] Sub-task: Write failing unit tests for a new `ApiHookClient` that can send requests to the IPC server.
|
||||||
|
- [ ] Sub-task: Implement the `ApiHookClient` to make the tests pass.
|
||||||
|
- [x] Task: Integrate the `ApiHookClient` into the Conductor agent's workflow. [c7c8b89]
|
||||||
|
- [ ] Sub-task: Write failing integration tests to ensure the Conductor's phase completion logic calls the `ApiHookClient`.
|
||||||
|
- [ ] Sub-task: Modify the workflow implementation to use the `ApiHookClient` for verification.
|
||||||
|
- [x] Task: Implement result handling and user feedback. [94b4f38]
|
||||||
|
- [ ] Sub-task: Write failing tests for handling success, failure, and server-unavailable scenarios.
|
||||||
|
- [ ] Sub-task: Implement the logic to log results, present them to the user, and halt the workflow on failure.
|
||||||
|
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Implement Automated Verification Logic' (Protocol in workflow.md)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Specification: Integrate API Hooks for Automated Track Verification
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track focuses on integrating the existing, previously implemented API hooks (from track `test_hooks_20260223`) into the Conductor workflow. The primary goal is to automate the verification steps within the "Phase Completion Verification and Checkpointing Protocol", reducing the need for manual user intervention and enabling a more streamlined, automated development process.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- **Workflow Integration:** The `workflow.md` document, specifically the "Phase Completion Verification and Checkpointing Protocol," must be updated to replace manual verification steps with automated checks using the API hooks.
|
||||||
|
- **IPC Communication:** The updated workflow will communicate with the application's backend via the established IPC server to trigger verification tasks.
|
||||||
|
- **Result Handling:**
|
||||||
|
- All results from the API hook verifications must be logged for auditing and debugging purposes.
|
||||||
|
- Upon successful verification, the Conductor agent will proceed with the workflow as it currently does after a successful manual check.
|
||||||
|
- Upon failure, the agent will halt, present the failure logs to the user, and await further instructions.
|
||||||
|
- **User Interaction Model:** The system will transition from asking the user to perform a manual test to informing the user that an automated test is running, and then presenting the results.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Resilience:** The Conductor agent must handle cases where the API hook server is unavailable or a hook call fails unexpectedly, without crashing or entering an unrecoverable state.
|
||||||
|
- **Transparency:** All interactions with the API hooks must be clearly logged, making the automated process easy to monitor and debug.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- **Modifying API Hooks:** This track will not alter the existing API hooks, the IPC server, or the backend implementation. The focus is solely on the client-side integration within the Conductor agent's workflow.
|
||||||
|
- **Changes to Manual Overrides:** Users will retain the ability to manually intervene or bypass automated checks if necessary.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track api_metrics_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "api_metrics_20260223",
|
||||||
|
"type": "feature",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T10:00:00Z",
|
||||||
|
"updated_at": "2026-02-23T10:00:00Z",
|
||||||
|
"description": "Review vendor api usage in regards to conservative context handling"
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
## Phase 1: Metric Extraction and Logic Review [checkpoint: 2668f88]
|
||||||
|
- [x] Task: Extract explicit cache counts and lifecycle states from Gemini SDK
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Review and expose 'history bleed' (token limit proximity) flags
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Metric Extraction and Logic Review' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: GUI Telemetry and Plotting [checkpoint: 76582c8]
|
||||||
|
- [x] Task: Implement token budget visualizer (e.g., Progress bars for limits) in Dear PyGui
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Implement active caches data display in Provider/Comms panel
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: GUI Telemetry and Plotting' (Protocol in workflow.md)
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Specification: Review vendor api usage in regards to conservative context handling
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track aims to optimize token efficiency and transparency by reviewing and improving how vendor APIs (Gemini and Anthropic) handle conservative context pruning. The primary focus is on extracting, plotting, and exposing deep metrics to the GUI so developers can intuit how close they are to API limits (e.g., token caps, cache counts, history bleed).
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
- **Gemini Hooks:** Review explicit context caching, cache invalidation, and tools declaration.
|
||||||
|
- **Global Orchestration:** Review global context boundaries within the main prompt lifecycle.
|
||||||
|
- **GUI Metrics:** Expose as much metric data as possible to the user interface (e.g., plotting token usage, visual indicators for when "history bleed" occurs, displaying the number of active caches).
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- Implement extensive token and cache metric extraction from both Gemini and Anthropic API responses.
|
||||||
|
- Expose these metrics to the Dear PyGui frontend, potentially utilizing visual plots or progress bars to indicate token budget consumption.
|
||||||
|
- Implement tests to explicitly verify context rules, ensuring history pruning acts conservatively and predictable without data loss.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- Ensure GUI rendering of new plots or dense metrics does not block the main thread.
|
||||||
|
- Adhere to the "Strict State Management" product guideline.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Major feature additions unrelated to context token management or telemetry.
|
||||||
|
- Expanding the AI's agentic capabilities (e.g., new tools).
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track api_vendor_alignment_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "api_vendor_alignment_20260223",
|
||||||
|
"type": "chore",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T12:00:00Z",
|
||||||
|
"updated_at": "2026-02-23T12:00:00Z",
|
||||||
|
"description": "Review project codebase, documentation related to project, and make sure agenti vendor apis are being used as properly stated by offical documentation from google for gemini and anthropic for claude."
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Implementation Plan: API Usage Audit and Alignment
|
||||||
|
|
||||||
|
## Phase 1: Research and Comprehensive Audit [checkpoint: 5ec4283]
|
||||||
|
Identify all points of interaction with AI SDKs and compare them with latest official documentation.
|
||||||
|
|
||||||
|
- [x] Task: List and categorize all AI SDK usage in the project.
|
||||||
|
- [x] Search for all imports of `google.genai` and `anthropic`.
|
||||||
|
- [x] Document specific functions and methods being called.
|
||||||
|
- [x] Task: Research latest official documentation for `google-genai` and `anthropic` Python SDKs.
|
||||||
|
- [x] Verify latest patterns for Client initialization.
|
||||||
|
- [x] Verify latest patterns for Context/Prompt caching.
|
||||||
|
- [x] Verify latest patterns for Tool/Function calling.
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Research and Comprehensive Audit' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: Gemini (google-genai) Alignment [checkpoint: 842bfc4]
|
||||||
|
Align Gemini integration with documented best practices.
|
||||||
|
|
||||||
|
- [x] Task: Refactor Gemini Client and Chat initialization if needed.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Optimize Gemini Context Caching.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Align Gemini Tool Declaration and handling.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Gemini (google-genai) Alignment' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 3: Anthropic Alignment [checkpoint: f0eb538]
|
||||||
|
Align Anthropic integration with documented best practices.
|
||||||
|
|
||||||
|
- [x] Task: Refactor Anthropic Client and Message creation if needed.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Optimize Anthropic Prompt Caching (`cache_control`).
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Align Anthropic Tool Declaration and handling.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: Anthropic Alignment' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 4: History and Token Management [checkpoint: 0f9f235]
|
||||||
|
Ensure accurate token estimation and robust history handling.
|
||||||
|
|
||||||
|
- [x] Task: Review and align token estimation logic for both providers.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Audit message history truncation and context window management.
|
||||||
|
- [x] Write Tests
|
||||||
|
- [x] Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 4: History and Token Management' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 5: Final Validation and Cleanup [checkpoint: e9126b4]
|
||||||
|
- [x] Task: Perform a full test run using `run_tests.py` to ensure 100% pass rate.
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 5: Final Validation and Cleanup' (Protocol in workflow.md)
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Specification: API Usage Audit and Alignment
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track involves a comprehensive audit of the "Manual Slop" codebase to ensure that the integration with Google Gemini (`google-genai`) and Anthropic Claude (`anthropic`) SDKs aligns perfectly with their latest official documentation and best practices. The goal is to identify discrepancies, performance bottlenecks, or deprecated patterns and implement the necessary fixes.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
- **Target:** Full codebase audit, with primary focus on `ai_client.py`, `mcp_client.py`, and any other modules interacting with AI SDKs.
|
||||||
|
- **Key Areas:**
|
||||||
|
- **Caching Mechanisms:** Verify Gemini context caching and Anthropic prompt caching implementation.
|
||||||
|
- **Tool Calling:** Audit function declarations, parameter schemas, and result handling.
|
||||||
|
- **History & Tokens:** Review message history management, token estimation accuracy, and context window handling.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
1. **SDK Audit:** Compare existing code patterns against the latest official Python SDK documentation for Gemini and Anthropic.
|
||||||
|
2. **Feature Validation:**
|
||||||
|
- Ensure `google-genai` usage follows the latest `Client` and `types` patterns.
|
||||||
|
- Ensure `anthropic` usage utilizes `cache_control` correctly for optimal performance.
|
||||||
|
3. **Discrepancy Remediation:** Implement code changes to align the implementation with documented standards.
|
||||||
|
4. **Validation:** Execute tests to ensure that API interactions remain functional and improved.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- Full audit completed for all AI SDK interactions.
|
||||||
|
- Identified discrepancies are documented and fixed.
|
||||||
|
- Caching, tool calling, and history management logic are verified against latest SDK standards.
|
||||||
|
- All existing and new tests pass successfully.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Adding support for new AI providers not already in the project.
|
||||||
|
- Major UI refactoring unless directly required by API changes.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track context_management_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "context_management_20260223",
|
||||||
|
"type": "feature",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T10:00:00Z",
|
||||||
|
"updated_at": "2026-02-23T10:00:00Z",
|
||||||
|
"description": "Implement context visualization and memory management improvements"
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
## Phase 1: Context Memory and Token Visualization [checkpoint: a88311b]
|
||||||
|
- [x] Task: Implement token usage summary widget e34ff7e
|
||||||
|
- [ ] Sub-task: Write Tests
|
||||||
|
- [ ] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Expose history truncation controls in the Discussion panel 94fe904
|
||||||
|
- [ ] Sub-task: Write Tests
|
||||||
|
- [ ] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Context Memory and Token Visualization' (Protocol in workflow.md) a88311b
|
||||||
|
|
||||||
|
## Phase 2: Agent Capability Configuration [checkpoint: 1ac6eb9]
|
||||||
|
- [x] Task: Add UI toggles for available tools per-project 1677d25
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Wire tool toggles to AI provider tool declaration payload 92aa33c
|
||||||
|
- [ ] Sub-task: Write Tests
|
||||||
|
- [ ] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Agent Capability Configuration' (Protocol in workflow.md) 1ac6eb9
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Specification: Context Visualization and Memory Management
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track implements UI improvements and structural changes to Manual Slop to provide explicit visualization of context memory usage and token consumption, fulfilling the "Expert systems level utility" and "Full control" product goals.
|
||||||
|
|
||||||
|
## Core Objectives
|
||||||
|
1. **Token Visualization:** Expose token usage metrics in real-time within the GUI (e.g., in a dedicated metrics panel or augmented Comms panel).
|
||||||
|
2. **Context Memory Management:** Provide tools to manually flush, persist, or truncate history to manage token budgets per-discussion.
|
||||||
|
3. **Agent Capability Toggles:** Expose explicit configuration options for agent capabilities (e.g., toggle MCP tools on/off) from the UI.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track event_driven_metrics_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "event_driven_metrics_20260223",
|
||||||
|
"type": "refactor",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T15:46:00Z",
|
||||||
|
"updated_at": "2026-02-23T15:46:00Z",
|
||||||
|
"description": "Fix client api metrics to use event driven updates, they shouldn't happen based on ui main thread graphical updates. Only when the program actually does significant client api calls or responses."
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Implementation Plan: Event-Driven API Metrics Updates
|
||||||
|
|
||||||
|
## Phase 1: Event Infrastructure & Test Setup [checkpoint: 776f4e4]
|
||||||
|
Define the event mechanism and create baseline tests to ensure we don't break data accuracy.
|
||||||
|
|
||||||
|
- [x] Task: Create `tests/test_api_events.py` to verify the new event emission logic in isolation. cd3f3c8
|
||||||
|
- [x] Task: Implement a simple `EventEmitter` or `Signal` class (if not already present) to handle decoupled communication. cd3f3c8
|
||||||
|
- [x] Task: Instrument `ai_client.py` with the event system, adding placeholders for the key lifecycle events. cd3f3c8
|
||||||
|
- [ ] Task: Conductor - User Manual Verification 'Phase 1: Event Infrastructure & Test Setup' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: Client Instrumentation (API Lifecycle) [checkpoint: e24664c]
|
||||||
|
Update the AI client to emit events during actual API interactions.
|
||||||
|
|
||||||
|
- [x] Task: Implement event emission for Gemini and Anthropic request/response cycles in `ai_client.py`. 20ebab5
|
||||||
|
- [x] Task: Implement event emission for tool/function calls and stream processing. 20ebab5
|
||||||
|
- [x] Task: Verify via tests that events carry the correct payload (token counts, session metadata). 20ebab5
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Client Instrumentation (API Lifecycle)' (Protocol in workflow.md) e24664c
|
||||||
|
|
||||||
|
## Phase 3: GUI Integration & Decoupling [checkpoint: 8caebbd]
|
||||||
|
Connect the UI to the event system and remove polling logic.
|
||||||
|
|
||||||
|
- [x] Task: Update `gui.py` to subscribe to API events and trigger metrics UI refreshes only upon event receipt. 2dd6145
|
||||||
|
- [x] Task: Audit the `gui.py` render loop and remove all per-frame metrics calculations or display updates. 2dd6145
|
||||||
|
- [x] Task: Verify that UI performance improves (reduced CPU/frame time) while metrics remain accurate. 2dd6145
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration & Decoupling' (Protocol in workflow.md) 8caebbd
|
||||||
|
|
||||||
|
## Phase: Review Fixes
|
||||||
|
- [x] Task: Apply review suggestions 66f728e
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Specification: Event-Driven API Metrics Updates
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
Refactor the API metrics update mechanism to be event-driven. Currently, the UI likely polls or recalculates metrics on every frame. This track will implement a signal/event system where `ai_client.py` broadcasts updates only when significant API activities (requests, responses, tool calls, or stream chunks) occur.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- **Event System:** Implement a robust event/signal mechanism (e.g., using a queue or a simple observer pattern) to communicate API lifecycle events.
|
||||||
|
- **Client Instrumentation:** Update `ai_client.py` to emit events at key points:
|
||||||
|
- **Request Start:** When a call is sent to the provider.
|
||||||
|
- **Response Received:** When a full or final response is received.
|
||||||
|
- **Tool Execution:** When a tool call is processed or a result is returned.
|
||||||
|
- **Stream Update:** When a chunk of a streaming response is processed.
|
||||||
|
- **UI Listener:** Update the GUI components (in `gui.py` or associated panels) to subscribe to these events and update metrics displays only when notified.
|
||||||
|
- **Decoupling:** Remove any metrics calculation or display logic that is triggered by the UI's main graphical update loop (per-frame).
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Efficiency:** Significant reduction in UI main thread CPU usage related to metrics.
|
||||||
|
- **Integrity:** Maintain 100% accuracy of token counts and usage data.
|
||||||
|
- **Responsiveness:** Metrics should update immediately following the corresponding API event.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- [ ] UI metrics for token usage, costs, and session state do NOT recalculate on every frame (can be verified by adding logging to the recalculation logic).
|
||||||
|
- [ ] Metrics update precisely when API calls are made or responses are received.
|
||||||
|
- [ ] Automated tests confirm that events are emitted correctly by the `ai_client`.
|
||||||
|
- [ ] The application remains stable and metrics accuracy is verified against the existing polling implementation.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Adding new metrics or visual components.
|
||||||
|
- Refactoring the core AI logic beyond the event/metrics hook.
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# GUI Layout Audit Report
|
||||||
|
|
||||||
|
## Current Panel Distribution
|
||||||
|
The GUI currently uses a multi-column layout with hardcoded initial positions:
|
||||||
|
|
||||||
|
1. **Column 1 (Left):** Projects (Top), Files (Mid), Diagnostics (Bottom).
|
||||||
|
2. **Column 2 (Center-Left):** Screenshots (Top), Theme (Mid), System Prompts (Bottom).
|
||||||
|
3. **Column 3 (Center-Right):** Discussion History (Full Height).
|
||||||
|
4. **Column 4 (Right):** Provider (Top), Message (Mid-Top), Response (Mid-Bottom), Tool Calls (Bottom).
|
||||||
|
5. **Column 5 (Far-Right):** Comms History (Full Height).
|
||||||
|
|
||||||
|
## Identified Issues
|
||||||
|
|
||||||
|
### 1. Context Fragmentation
|
||||||
|
- **Projects**, **Files**, and **Screenshots** are related to context gathering but are split across two different columns.
|
||||||
|
- **Base Dir** inputs are repeated for Files and Screenshots, taking up redundant vertical space.
|
||||||
|
|
||||||
|
### 2. Configuration Fragmentation
|
||||||
|
- **Provider** settings (API keys, models, temperature) are on the far right.
|
||||||
|
- **System Prompts** (Global and Project) are in the center-bottom.
|
||||||
|
- These should be unified into a single "AI Configuration" or "Settings" hub.
|
||||||
|
|
||||||
|
### 3. Workflow Disconnect (The "Chat Loop")
|
||||||
|
- The user composes in **Message**, views in **Response**, and then manually adds to **Discussion History**.
|
||||||
|
- These three panels are physically separated (Column 3 vs Column 4), causing unnecessary eye travel.
|
||||||
|
|
||||||
|
### 4. Visibility of Operations
|
||||||
|
- **Diagnostics** and **Comms History** are related to monitoring "under the hood" activity but are at opposite ends of the screen (Far Left vs Far Right).
|
||||||
|
- **Tool Calls** and **Last Script Output** are the primary way to see AI actions, but Tool Calls is small and Script Output is a popup that can be missed.
|
||||||
|
|
||||||
|
### 5. Tactical UI Density
|
||||||
|
- Heavy use of `dpg.add_separator()` and standard `dpg.add_text()` labels leads to "airy" panels that don't match the "Arcade" aesthetic of dense, information-rich displays.
|
||||||
|
- Lack of clear visual grouping for related fields.
|
||||||
|
|
||||||
|
## Recommendations for Phase 2
|
||||||
|
- **Unify Context:** Merge Projects, Files, and Screenshots into a tabbed "Context Manager" panel.
|
||||||
|
- **Unify AI Config:** Merge Provider and System Prompts into an "AI Settings" panel.
|
||||||
|
- **Streamline Chat:** Position Discussion History, Message, and Response in a logical vertical or horizontal flow.
|
||||||
|
- **Operations Hub:** Group Diagnostics, Comms History, and Tool Calls.
|
||||||
|
- **Arcade FX:** Implement better visual cues (blinking, color shifts) for state changes.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track gui_layout_refinement_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "gui_layout_refinement_20260223",
|
||||||
|
"type": "refactor",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T12:00:00Z",
|
||||||
|
"updated_at": "2026-02-23T12:00:00Z",
|
||||||
|
"description": "Review GUI design. Make sure placment of tunings, features, etc that the gui provides frontend visualization and manipulation for make sense and are in the right place (not in a weird panel or doesn't make sense holistically for its use. Make plan for adjustments and then make major changes to meet resolved goals."
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Implementation Plan: GUI Layout Audit and UX Refinement
|
||||||
|
|
||||||
|
## Phase 1: Audit and Structural Design [checkpoint: 6a35da1]
|
||||||
|
Perform a thorough review of the current GUI and define the target layout.
|
||||||
|
|
||||||
|
- [x] Task: Audit current GUI panels (AI Settings, Context, Diagnostics, History) and document placement issues. d177c0b
|
||||||
|
- [x] Task: Propose a reorganized layout structure that prioritizes dockable/floatable window flexibility. 8448c71
|
||||||
|
- [x] Task: Review proposal with user and finalize the structural plan. 8448c71
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Audit and Structural Design' (Protocol in workflow.md) 6a35da1
|
||||||
|
|
||||||
|
## Phase 2: Layout Reorganization [checkpoint: 97367fe]
|
||||||
|
Implement the structural changes to panel placements and window behaviors.
|
||||||
|
|
||||||
|
- [x] Task: Refactor `gui.py` panel definitions to align with the new structural plan. c341de5
|
||||||
|
- [x] Task: Optimize Dear PyGui window configuration for better multi-viewport handling. f8fb58d
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Layout Reorganization' (Protocol in workflow.md) 97367fe
|
||||||
|
|
||||||
|
## Phase 3: Visual and Tactile Enhancements [checkpoint: 4a4cf8c]
|
||||||
|
Implement Arcade FX and increase information density.
|
||||||
|
|
||||||
|
- [x] Task: Enhance Arcade FX (blinking, animations) for AI state changes and tool execution. c5d54cf
|
||||||
|
- [x] Task: Increase tactile density in diagnostic and context tables. c5d54cf
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: Visual and Tactile Enhancements' (Protocol in workflow.md) 4a4cf8c
|
||||||
|
|
||||||
|
## Phase 4: Iterative Refinement and Final Audit [checkpoint: 22f8943]
|
||||||
|
Fine-tune the UI based on live usage and verify against product guidelines.
|
||||||
|
|
||||||
|
- [x] Task: Perform a "live" walkthrough to identify friction points in the new layout. b3cf58a
|
||||||
|
- [x] Task: Final polish of widget spacing, colors, and tactile feedback based on walkthrough. ebd8158
|
||||||
|
- [x] Task: Revert Diagnostics to standalone panel and increase plot height. ebd8158
|
||||||
|
- [x] Task: Update Discussion Entries (collapsed by default, read-only mode toggle). ebd8158
|
||||||
|
- [x] Task: Reposition Maximize button (away from insert/delete). ebd8158
|
||||||
|
- [x] Task: Implement Message/Response as tabs. ebd8158
|
||||||
|
- [x] Task: Ensure all read-only text is selectable/copyable. ebd8158
|
||||||
|
- [x] Task: Implement "Prior Session Log" viewer with tinted UI mode. ebd8158
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 4: Iterative Refinement and Final Audit' (Protocol in workflow.md) 22f8943
|
||||||
|
|
||||||
|
## Phase: Review Fixes
|
||||||
|
- [x] Task: Apply review suggestions (Align diagnostics test) 0c5ac55
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# GUI Reorganization Proposal: The "Integrated Workspace"
|
||||||
|
|
||||||
|
## Vision
|
||||||
|
Transform the current scattered window layout into a cohesive, professional workspace that optimizes expert-level AI interaction. We will group functionality into four primary dockable "Hubs" while maintaining the flexibility of floating windows for secondary tasks.
|
||||||
|
|
||||||
|
## 1. Context Hub (The "Input" Panel)
|
||||||
|
**Goal:** Consolidate all files, projects, and assets.
|
||||||
|
- **Components:**
|
||||||
|
- Tab 1: **Projects** (Project switching, global settings).
|
||||||
|
- Tab 2: **Files** (Base directory, path list, wildcard tools).
|
||||||
|
- Tab 3: **Screenshots** (Base directory, path list, preview).
|
||||||
|
- **Benefits:** Reduces eye-scatter when gathering context; shared vertical space for lists.
|
||||||
|
|
||||||
|
## 2. AI Settings Hub (The "Brain" Panel)
|
||||||
|
**Goal:** Unified control over AI persona and parameters.
|
||||||
|
- **Components:**
|
||||||
|
- Section (Collapsing): **Provider & Models** (Provider selection, model fetcher, telemetry).
|
||||||
|
- Section (Collapsing): **Tunings** (Temperature, Max Tokens, Truncation Limit).
|
||||||
|
- Section (Collapsing): **System Prompts** (Global and Project-specific overrides).
|
||||||
|
- **Benefits:** All "static" AI configuration in one place, freeing up right-column space for the chat flow.
|
||||||
|
|
||||||
|
## 3. Discussion Hub (The "Interface" Panel)
|
||||||
|
**Goal:** A tight feedback loop for the core chat experience.
|
||||||
|
- **Layout:**
|
||||||
|
- **Top:** Discussion History (Scrollable region).
|
||||||
|
- **Middle:** Message Composer (Input box + "Gen + Send" buttons).
|
||||||
|
- **Bottom:** AI Response (Read-only output with "-> History" action).
|
||||||
|
- **Benefits:** Minimizes mouse travel between input, output, and history archival. Supports a natural top-to-bottom reading flow.
|
||||||
|
|
||||||
|
## 4. Operations Hub (The "Diagnostics" Panel)
|
||||||
|
**Goal:** High-density monitoring of background activity.
|
||||||
|
- **Components:**
|
||||||
|
- Tab 1: **Comms History** (The low-level request/response log).
|
||||||
|
- Tab 2: **Tool Log** (Specific record of executed tools and scripts).
|
||||||
|
- Tab 3: **Diagnostics** (Performance telemetry, FPS/CPU plots).
|
||||||
|
- **Benefits:** Keeps "noisy" technical data out of the primary workspace while making it easily accessible for troubleshooting.
|
||||||
|
|
||||||
|
## Visual & Tactile Enhancements (Arcade FX)
|
||||||
|
- **State-Based Blinking:** Unified blinking logic for when the AI is "Thinking" vs "Ready".
|
||||||
|
- **Density:** Transition from simple separators to titled grouping boxes and compact tables for token usage.
|
||||||
|
- **Color Coding:** Standardized color palette for different tool types (Files = Blue, Shell = Yellow, Web = Green).
|
||||||
|
|
||||||
|
## Implementation Strategy
|
||||||
|
1. **Docking Defaults:** Define a default docking layout in `gui.py` that arranges these four Hubs in a 4-quadrant or 2x2 grid.
|
||||||
|
2. **Refactor:** Modify `gui.py` to wrap current window contents into these new Hub functions.
|
||||||
|
3. **Persistence:** Ensure `dpg_layout.ini` continues to respect user overrides for this new structure.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Specification: GUI Layout Audit and UX Refinement
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track focuses on a holistic review and reorganization of the Manual Slop GUI. The goal is to ensure that AI tunings, diagnostic features, context management, and discussion history are logically placed to support an expert-level "Multi-Viewport" workflow. We will strengthen the "Arcade Aesthetics" and "Tactile Density" values while ensuring the layout remains intuitive for power users.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
- **Review Areas:** AI Configuration, Diagnostics & Logs, Context Management, and Discussion History panels.
|
||||||
|
- **Paradigm:** Multi-Viewport Focus (optimizing floatable/dockable windows).
|
||||||
|
- **Aesthetics:** Enhancement of Arcade-style visual feedback and tactile UI density.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
1. **Layout Audit:** Analyze current widget placement against holistic use cases. Identify "weirdly placed" features that don't fit the expert-focus workflow.
|
||||||
|
2. **Multi-Viewport Optimization:** Refine dockable panel behaviors to ensure flexible multi-monitor setups are seamless.
|
||||||
|
3. **Visual Feedback Overhaul:** Implement or enhance blinking notifications and state-change animations (Arcade FX) for tool execution and AI status.
|
||||||
|
4. **Information Density Enhancement:** Increase tactile feedback and data density in diagnostic and context panels.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Performance:** Ensure layout updates do not introduce lag or violate strict state management principles.
|
||||||
|
- **Consistency:** Maintain "USA Graphics Company" tactile interaction values.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- A comprehensive audit report/plan for adjustments is created.
|
||||||
|
- GUI layout is reorganized based on the audit results.
|
||||||
|
- Arcade FX and tactile density enhancements are implemented and verified.
|
||||||
|
- The redesign is refined iteratively based on user feedback.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Modifying underlying AI SDK integration logic.
|
||||||
|
- Implementing new core MCP tools.
|
||||||
|
- Backend project management logic.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track gui_performance_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "gui_performance_20260223",
|
||||||
|
"type": "bug",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T15:10:00Z",
|
||||||
|
"updated_at": "2026-02-23T15:10:00Z",
|
||||||
|
"description": "investigate and fix heavy frametime performance issues with the gui"
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Implementation Plan: GUI Performance Fix
|
||||||
|
|
||||||
|
## Phase 1: Instrumented Profiling and Regression Analysis
|
||||||
|
- [x] Task: Baseline Profiling Run
|
||||||
|
- [x] Sub-task: Launch app with `--enable-test-hooks` and capture `get_ui_performance` snapshot on idle startup.
|
||||||
|
- [x] Sub-task: Identify which component (Dialogs, History, GUI_Tasks, Blinking, Comms, Telemetry) exceeds 1ms.
|
||||||
|
- [x] Task: Regression Analysis (Commit `8aa70e2` to HEAD)
|
||||||
|
- [x] Sub-task: Review `git diff` for `gui.py` and `ai_client.py` across the suspected range.
|
||||||
|
- [x] Sub-task: Identify any code added to the `while dpg.is_dearpygui_running()` loop that lacks throttling.
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Instrumented Profiling and Regression Analysis' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: Bottleneck Remediation
|
||||||
|
- [x] Task: Implement Performance Fixes
|
||||||
|
- [x] Sub-task: Write Tests (Performance regression test - verify no new heavy loops introduced)
|
||||||
|
- [x] Sub-task: Implement Feature (Refactor/Throttle identified bottlenecks)
|
||||||
|
- [x] Task: Verify Idle FPS Stability
|
||||||
|
- [x] Sub-task: Write Tests (Verify frametimes are < 16.6ms via API hooks)
|
||||||
|
- [x] Sub-task: Implement Feature (Final tuning of update frequencies)
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Bottleneck Remediation' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 3: Final Validation
|
||||||
|
- [x] Task: Stress Test Verification
|
||||||
|
- [x] Sub-task: Write Tests (Simulate high volume of comms entries and verify FPS remains stable)
|
||||||
|
- [x] Sub-task: Implement Feature (Ensure optimizations scale with history size)
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: Final Validation' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase: Review Fixes
|
||||||
|
- [x] Task: Apply review suggestions 4628813
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Specification: GUI Performance Investigation and Fix
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track focuses on identifying and resolving severe frametime performance issues in the Manual Slop GUI. Current observations indicate massive frametime bloat even on idle startup, with performance significantly regressing (target 60 FPS / <16.6ms) since commit `8aa70e287fbf93e669276f9757965d5a56e89b10`.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- **Deep Profiling:**
|
||||||
|
- Use the high-resolution component timing (implemented in previous tracks) to pinpoint the exact main loop component causing bloat.
|
||||||
|
- Verify if the issue is in DPG rendering, theme binding, telemetry gathering, or thread synchronization.
|
||||||
|
- **Regression Analysis:**
|
||||||
|
- Examine changes since commit `8aa70e287fbf93e669276f9757965d5a56e89b10` to identify potentially expensive operations introduced to the main loop.
|
||||||
|
- **Optimization:**
|
||||||
|
- Refactor or throttle any identified bottlenecks.
|
||||||
|
- Ensure that UI initialization or data aggregation does not block the main thread unnecessarily.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Target Performance:** Consistent 60 FPS (<16.6ms per frame) during idle operation.
|
||||||
|
- **Stability:** Zero frames exceeding 33ms (spike threshold) during normal idle use.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- [ ] Manual Slop GUI launches and maintains a stable <16.6ms frametime on idle.
|
||||||
|
- [ ] Performance Diagnostics panel confirms the absence of >16.6ms spikes on idle.
|
||||||
|
- [ ] The root cause of the regression is identified and verified through empirical testing.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Optimizing AI response times (latency of the provider API).
|
||||||
|
- GPU-side optimizations (shaders/VRAM management).
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track live_gui_testing_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "live_gui_testing_20260223",
|
||||||
|
"type": "chore",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T15:43:00Z",
|
||||||
|
"updated_at": "2026-02-23T15:43:00Z",
|
||||||
|
"description": "Update all tests to use a live running gui.py with --enable-test-hooks for real-time state and metrics verification."
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Implementation Plan: Live GUI Testing Infrastructure
|
||||||
|
|
||||||
|
## Phase 1: Infrastructure & Core Utilities [checkpoint: db251a1]
|
||||||
|
Establish the mechanism for managing the live GUI process and providing it to tests.
|
||||||
|
|
||||||
|
- [x] Task: Create `tests/conftest.py` with a session-scoped fixture to manage the `gui.py --enable-test-hooks` process.
|
||||||
|
- [x] Task: Enhance `api_hook_client.py` with robust connection retries and health checks to handle GUI startup time.
|
||||||
|
- [x] Task: Update `conductor/workflow.md` to formally document the "Live GUI Testing" requirement and the use of the `--enable-test-hooks` flag.
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Infrastructure & Core Utilities' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: Test Suite Migration [checkpoint: 6677a6e]
|
||||||
|
Migrate existing tests to use the live GUI fixture and API hooks.
|
||||||
|
|
||||||
|
- [x] Task: Refactor `tests/test_api_hook_client.py` and `tests/test_conductor_api_hook_integration.py` to use the live GUI fixture.
|
||||||
|
- [x] Task: Refactor GUI performance tests (`tests/test_gui_performance_requirements.py`, `tests/test_gui_stress_performance.py`) to verify real metrics (FPS, memory) via hooks.
|
||||||
|
- [x] Task: Audit and update all remaining tests in `tests/` to ensure they either use the live server or are explicitly marked as pure unit tests.
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Test Suite Migration' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 3: Conductor Integration & Validation [checkpoint: 637946b]
|
||||||
|
Ensure the Conductor framework itself supports and enforces this new testing paradigm.
|
||||||
|
|
||||||
|
- [x] Task: Verify that new track creation generates plans that include specific API hook verification tasks.
|
||||||
|
- [x] Task: Perform a full test run using `run_tests.py` (or equivalent) to ensure 100% pass rate in the new environment.
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: Conductor Integration & Validation' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase: Review Fixes
|
||||||
|
- [x] Task: Apply review suggestions 075d760
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Specification: Live GUI Testing Infrastructure
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
Update the testing suite to ensure all tests (especially GUI-related and integration tests) communicate with a live running instance of `gui.py` started with the `--enable-test-hooks` argument. This ensures that tests can verify the actual application state and metrics via the built-in API hooks.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- **Server-Based Testing:** All tests must be updated to interact with the application through its REST API hooks rather than mocking internal components where live verification is possible.
|
||||||
|
- **Automated GUI Management:** Implement a robust mechanism (preferably a pytest fixture) to start `gui.py --enable-test-hooks` before test execution and ensure it is cleanly terminated after tests complete.
|
||||||
|
- **Hook Client Integration:** Ensure `api_hook_client.py` is the primary interface for tests to communicate with the running GUI.
|
||||||
|
- **Documentation Alignment:** Update `conductor/workflow.md` to reflect the requirement for live testing and API hook verification.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Reliability:** The process of starting and stopping the GUI must be stable and not leave orphaned processes.
|
||||||
|
- **Speed:** The setup/teardown of the live GUI should be optimized to minimize test suite overhead.
|
||||||
|
- **Observability:** Tests should log communication with the API hooks for easier debugging.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- [ ] All tests in the `tests/` directory pass when executed against a live `gui.py` instance.
|
||||||
|
- [ ] New track creation (e.g., via `/conductor:newTrack`) generates plans that include specific API hook verification tasks.
|
||||||
|
- [ ] `conductor/workflow.md` accurately describes the live testing protocol.
|
||||||
|
- [ ] Real-time UI metrics (FPS, CPU, etc.) are successfully retrieved and verified in at least one performance test.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Rewriting the entire GUI framework.
|
||||||
|
- Implementing new API hooks not required for existing test verification.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track test_hooks_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "test_hooks_20260223",
|
||||||
|
"type": "feature",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T10:00:00Z",
|
||||||
|
"updated_at": "2026-02-23T10:00:00Z",
|
||||||
|
"description": "Add full api/hooks so that gemini cli can test, interact, and manipulate the state of the gui & program backend for automated testing."
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Implementation Plan
|
||||||
|
|
||||||
|
## Phase 1: Foundation and Opt-in Mechanisms [checkpoint: 2bc7a3f]
|
||||||
|
- [x] Task: Implement CLI flag/env-var to enable the hook system [1306163]
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Set up lightweight local IPC server (e.g., standard library socket/HTTP) for receiving hook commands [44c2585]
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Foundation and Opt-in Mechanisms' (Protocol in workflow.md) [2bc7a3f]
|
||||||
|
|
||||||
|
## Phase 2: Hook Implementations and Logging [checkpoint: eaf229e]
|
||||||
|
- [x] Task: Implement project and AI session state manipulation hooks [d9d056c]
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Implement GUI state manipulation hooks with thread-safe queueing [5f9bc19]
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Integrate aggressive logging for all hook invocations [ef29902]
|
||||||
|
- [x] Sub-task: Write Tests
|
||||||
|
- [x] Sub-task: Implement Feature
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Hook Implementations and Logging' (Protocol in workflow.md) [eaf229e]
|
||||||
|
|
||||||
|
## Phase: Review Fixes
|
||||||
|
- [x] Task: Apply review suggestions [dc64493]
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Specification: Add full api/hooks so that gemini cli can test, interact, and manipulate the state of the gui & program backend for automated testing
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track introduces a comprehensive suite of API hooks designed specifically for the Gemini CLI and the Conductor framework. These hooks will allow automated agents to manipulate and test the internal state of the application without requiring manual GUI interaction, enabling automated test-driven development and track progression validation.
|
||||||
|
|
||||||
|
## Use Cases
|
||||||
|
- **Automated Testing & Progression:** Expose low-level state manipulation hooks so that the Gemini CLI + Conductor can autonomously verify track completion, test UI logic, and validate backend states.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- **Comprehensive Access:** The hooks must provide full, unrestricted access to the entire program, including:
|
||||||
|
- GUI state (Dear PyGui nodes, values, layout data).
|
||||||
|
- AI session state (history, active caches, tool configurations).
|
||||||
|
- Project configurations and discussion state.
|
||||||
|
- **Security & Logging:** The hook system MUST be strictly opt-in (e.g., enabled via a specific command-line argument like `--enable-test-hooks` or an environment variable). When enabled, any invocation of these hooks MUST be aggressively logged to ensure transparency.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Thread Safety:** Hooks interacting with the GUI state must respect the main render loop locks and threading model defined in the architecture guidelines.
|
||||||
|
- **Dependency Minimalism:** The hook interface should utilize built-in mechanisms (like sockets, a lightweight local HTTP server, or standard inter-process communication) without introducing heavy external web frameworks.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Building the actual Gemini CLI or Conductor automation logic itself; this track only builds the *hooks* within Manual Slop that those external agents will consume.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track ui_performance_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "ui_performance_20260223",
|
||||||
|
"type": "feature",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T14:45:00Z",
|
||||||
|
"updated_at": "2026-02-23T14:45:00Z",
|
||||||
|
"description": "Add new metrics to track ui performance (frametimings, fps, input lag, etc). And api hooks so that ai may engage with them."
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Implementation Plan: UI Performance Metrics and AI Diagnostics
|
||||||
|
|
||||||
|
## Phase 1: High-Resolution Telemetry Engine [checkpoint: f5c9596]
|
||||||
|
- [x] Task: Implement core performance collector (FrameTime, CPU usage) 7fe117d
|
||||||
|
- [x] Sub-task: Write Tests (validate metric collection accuracy)
|
||||||
|
- [x] Sub-task: Implement Feature (create `PerformanceMonitor` class)
|
||||||
|
- [x] Task: Integrate collector with Dear PyGui main loop 5c7fd39
|
||||||
|
- [x] Sub-task: Write Tests (verify integration doesn't crash loop)
|
||||||
|
- [x] Sub-task: Implement Feature (hooks in `gui.py` or `gui_2.py`)
|
||||||
|
- [x] Task: Implement Input Lag estimation logic cdd06d4
|
||||||
|
- [x] Sub-task: Write Tests (simulated input vs. response timing)
|
||||||
|
- [x] Sub-task: Implement Feature (event-based timing in GUI)
|
||||||
|
- [ ] Task: Conductor - User Manual Verification 'Phase 1: High-Resolution Telemetry Engine' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 2: AI Tooling and Alert System [checkpoint: b92f2f3]
|
||||||
|
- [x] Task: Create `get_ui_performance` AI tool 9ec5ff3
|
||||||
|
- [x] Sub-task: Write Tests (verify tool returns correct JSON schema)
|
||||||
|
- [x] Sub-task: Implement Feature (add tool to `mcp_client.py`)
|
||||||
|
- [x] Task: Implement performance threshold alert system 3e9d362
|
||||||
|
- [x] Sub-task: Write Tests (verify alerts trigger at correct thresholds)
|
||||||
|
- [x] Sub-task: Implement Feature (logic to inject messages into `ai_client.py` context)
|
||||||
|
- [ ] Task: Conductor - User Manual Verification 'Phase 2: AI Tooling and Alert System' (Protocol in workflow.md)
|
||||||
|
|
||||||
|
## Phase 3: Diagnostics UI and Optimization [checkpoint: 7aa9fe6]
|
||||||
|
- [x] Task: Build the Diagnostics Panel in Dear PyGui 30d838c
|
||||||
|
- [x] Sub-task: Write Tests (verify panel components render)
|
||||||
|
- [x] Sub-task: Implement Feature (plots, stat readouts in `gui.py`)
|
||||||
|
- [x] Task: Identify and fix main thread performance bottlenecks c2f4b16
|
||||||
|
- [x] Sub-task: Write Tests (reproducible "heavy" load test)
|
||||||
|
- [x] Sub-task: Implement Feature (refactor heavy logic to workers)
|
||||||
|
- [ ] Task: Conductor - User Manual Verification 'Phase 3: Diagnostics UI and Optimization' (Protocol in workflow.md)
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Specification: UI Performance Metrics and AI Diagnostics
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track aims to resolve subpar UI performance (currently perceived below 60 FPS) by implementing a robust performance monitoring system. This system will collect high-resolution telemetry (Frame Time, Input Lag, Thread Usage) and expose it to both the user (via a Diagnostics Panel) and the AI (via API hooks). This ensures that performance degradation is caught early during development and testing.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
- **Metric Collection Engine:**
|
||||||
|
- Track **Frame Time** (ms) for every frame rendered by Dear PyGui.
|
||||||
|
- Measure **Input Lag** (estimated delay between input events and UI state updates).
|
||||||
|
- Monitor **CPU/Thread Usage**, specifically identifying blocks in the main UI thread.
|
||||||
|
- **Diagnostics Panel:**
|
||||||
|
- A new dedicated panel in the GUI to display real-time performance graphs and stats.
|
||||||
|
- Historical trend visualization for frame times to identify spikes.
|
||||||
|
- **AI API Hooks:**
|
||||||
|
- **Polling Tool:** A tool (e.g., `get_ui_performance`) that allows the AI to request a snapshot of current telemetry.
|
||||||
|
- **Event-Driven Alerts:** A mechanism to notify the AI (or append to history) when performance metrics cross a "degradation" threshold (e.g., frame time > 33ms).
|
||||||
|
- **Performance Optimization:**
|
||||||
|
- Identify the "heavy" process currently running in the main UI thread loop.
|
||||||
|
- Refactor identified bottlenecks to utilize background workers or optimized logic.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Low Overhead:** The monitoring system itself must not significantly impact UI performance (target <1% CPU overhead).
|
||||||
|
- **Accuracy:** Frame timings must be accurate to sub-millisecond resolution.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- [ ] UI consistently maintains "Smooth Frame Timing" (minimized spikes) under normal load.
|
||||||
|
- [ ] Main thread load is reduced, evidenced by metrics showing less than 50% busy time during idle/light use.
|
||||||
|
- [ ] AI can successfully retrieve performance data using the `get_ui_performance` tool.
|
||||||
|
- [ ] AI is alerted when a simulated performance drop occurs.
|
||||||
|
- [ ] The Diagnostics Panel displays live, accurate data.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- GPU-specific profiling (e.g., VRAM usage, shader timings).
|
||||||
|
- Remote telemetry/analytics (data stays local).
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Google Python Style Guide Summary
|
||||||
|
|
||||||
|
This document summarizes key rules and best practices from the Google Python Style Guide.
|
||||||
|
|
||||||
|
## 1. Python Language Rules
|
||||||
|
- **Linting:** Run `pylint` on your code to catch bugs and style issues.
|
||||||
|
- **Imports:** Use `import x` for packages/modules. Use `from x import y` only when `y` is a submodule.
|
||||||
|
- **Exceptions:** Use built-in exception classes. Do not use bare `except:` clauses.
|
||||||
|
- **Global State:** Avoid mutable global state. Module-level constants are okay and should be `ALL_CAPS_WITH_UNDERSCORES`.
|
||||||
|
- **Comprehensions:** Use for simple cases. Avoid for complex logic where a full loop is more readable.
|
||||||
|
- **Default Argument Values:** Do not use mutable objects (like `[]` or `{}`) as default values.
|
||||||
|
- **True/False Evaluations:** Use implicit false (e.g., `if not my_list:`). Use `if foo is None:` to check for `None`.
|
||||||
|
- **Type Annotations:** Strongly encouraged for all public APIs.
|
||||||
|
|
||||||
|
## 2. Python Style Rules
|
||||||
|
- **Line Length:** Maximum 80 characters.
|
||||||
|
- **Indentation:** 4 spaces per indentation level. Never use tabs.
|
||||||
|
- **Blank Lines:** Two blank lines between top-level definitions (classes, functions). One blank line between method definitions.
|
||||||
|
- **Whitespace:** Avoid extraneous whitespace. Surround binary operators with single spaces.
|
||||||
|
- **Docstrings:** Use `"""triple double quotes"""`. Every public module, function, class, and method must have a docstring.
|
||||||
|
- **Format:** Start with a one-line summary. Include `Args:`, `Returns:`, and `Raises:` sections.
|
||||||
|
- **Strings:** Use f-strings for formatting. Be consistent with single (`'`) or double (`"`) quotes.
|
||||||
|
- **`TODO` Comments:** Use `TODO(username): Fix this.` format.
|
||||||
|
- **Imports Formatting:** Imports should be on separate lines and grouped: standard library, third-party, and your own application's imports.
|
||||||
|
|
||||||
|
## 3. Naming
|
||||||
|
- **General:** `snake_case` for modules, functions, methods, and variables.
|
||||||
|
- **Classes:** `PascalCase`.
|
||||||
|
- **Constants:** `ALL_CAPS_WITH_UNDERSCORES`.
|
||||||
|
- **Internal Use:** Use a single leading underscore (`_internal_variable`) for internal module/class members.
|
||||||
|
|
||||||
|
## 4. Main
|
||||||
|
- All executable files should have a `main()` function that contains the main logic, called from a `if __name__ == '__main__':` block.
|
||||||
|
|
||||||
|
**BE CONSISTENT.** When editing code, match the existing style.
|
||||||
|
|
||||||
|
*Source: [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)*
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Project Context
|
||||||
|
|
||||||
|
## Definition
|
||||||
|
- [Product Definition](./product.md)
|
||||||
|
- [Product Guidelines](./product-guidelines.md)
|
||||||
|
- [Tech Stack](./tech-stack.md)
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
- [Workflow](./workflow.md)
|
||||||
|
- [Code Style Guides](./code_styleguides/)
|
||||||
|
|
||||||
|
## Management
|
||||||
|
- [Tracks Registry](./tracks.md)
|
||||||
|
- [Tracks Directory](./tracks/)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Product Guidelines: Manual Slop
|
||||||
|
|
||||||
|
## Documentation Style
|
||||||
|
- **Strict & In-Depth:** Documentation must follow an old-school, highly detailed technical breakdown style (similar to VEFontCache-Odin). Focus on architectural design, state management, algorithmic details, and structural formats rather than just surface-level usage.
|
||||||
|
|
||||||
|
## UX & UI Principles
|
||||||
|
- **USA Graphics Company Values:** Embrace high information density and tactile interactions.
|
||||||
|
- **Arcade Aesthetics:** Utilize arcade game-style visual feedback for state updates (e.g., blinking notifications for tool execution and AI responses) to make the experience fun, visceral, and engaging.
|
||||||
|
- **Explicit Control & Expert Focus:** The interface should not hold the user's hand. It must prioritize explicit manual confirmation for destructive actions while providing dense, unadulterated access to logs and context.
|
||||||
|
- **Multi-Viewport Capabilities:** Leverage dockable, floatable panels to allow users to build custom workspaces suitable for multi-monitor setups.
|
||||||
|
|
||||||
|
## Code Standards & Architecture
|
||||||
|
- **Strict State Management:** There must be a rigorous separation between the Main GUI rendering thread and daemon execution threads. The UI should *never* hang during AI communication or script execution. Use lock-protected queues and events for synchronization.
|
||||||
|
- **Comprehensive Logging:** Aggressively log all actions, API payloads, tool calls, and executed scripts. Maintain timestamped JSON-L and markdown logs to ensure total transparency and debuggability.
|
||||||
|
- **Dependency Minimalism:** Limit external dependencies where possible. For instance, prefer standard library modules (like `urllib` and `html.parser` for web tools) over heavy third-party packages.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Product Guide: Manual Slop
|
||||||
|
|
||||||
|
## Vision
|
||||||
|
To serve as an expert-level utility for personal developer use on small projects, providing full, manual control over vendor API metrics, agent capabilities, and context memory usage.
|
||||||
|
|
||||||
|
## Primary Use Cases
|
||||||
|
- **Full Control over Vendor APIs:** Exposing detailed API metrics and configuring deep agent capabilities directly within the GUI.
|
||||||
|
- **Context & Memory Management:** Better visualization and management of token usage and context memory, allowing developers to optimize prompt limits manually.
|
||||||
|
- **Manual "Vibe Coding" Assistant:** Serving as an auxiliary, multi-provider assistant that natively interacts with the codebase via sandboxed PowerShell scripts and MCP-like file tools, emphasizing manual developer oversight and explicit confirmation.
|
||||||
|
|
||||||
|
## Key Features
|
||||||
|
- **Multi-Provider Integration:** Supports both Gemini and Anthropic with seamless switching.
|
||||||
|
- **Explicit Execution Control:** All AI-generated PowerShell scripts require explicit human confirmation via interactive UI dialogs before execution.
|
||||||
|
- **Detailed History Management:** Rich discussion history with branching, timestamping, and specific git commit linkage per conversation.
|
||||||
|
- **In-Depth Toolset Access:** MCP-like file exploration, URL fetching, search, and dynamic context aggregation embedded within a multi-viewport Dear PyGui/ImGui interface.
|
||||||
|
- **Integrated Workspace:** A consolidated Hub-based layout (Context, AI Settings, Discussion, Operations) designed for expert multi-monitor workflows.
|
||||||
|
- **Session Analysis:** Ability to load and visualize historical session logs with a dedicated tinted "Prior Session" viewing mode.
|
||||||
|
- **Performance Diagnostics:** Built-in telemetry for FPS, Frame Time, and CPU usage, with a dedicated Diagnostics Panel and AI API hooks for performance analysis.
|
||||||
|
- **Automated UX Verification:** A robust IPC mechanism via API hooks allows for human-like simulation walkthroughs and automated regression testing of the full GUI lifecycle.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"last_successful_step": "3.3_initial_track_generated"}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Technology Stack: Manual Slop
|
||||||
|
|
||||||
|
## Core Language
|
||||||
|
- **Python 3.11+**
|
||||||
|
|
||||||
|
## GUI Frameworks
|
||||||
|
- **Dear PyGui:** For immediate/retained mode GUI rendering and node mapping.
|
||||||
|
- **ImGui Bundle (`imgui-bundle`):** To provide advanced multi-viewport and dockable panel capabilities on top of Dear ImGui.
|
||||||
|
|
||||||
|
## AI Integration SDKs
|
||||||
|
- **google-genai:** For Google Gemini API interaction and explicit context caching.
|
||||||
|
- **anthropic:** For Anthropic Claude API interaction, supporting ephemeral prompt caching.
|
||||||
|
|
||||||
|
## Configuration & Tooling
|
||||||
|
- **tomli-w:** For writing TOML configuration files.
|
||||||
|
- **psutil:** For system and process monitoring (CPU/Memory telemetry).
|
||||||
|
- **uv:** An extremely fast Python package and project manager.
|
||||||
|
- **pytest:** For unit and integration testing, leveraging custom fixtures for live GUI verification.
|
||||||
|
- **ApiHookClient:** A dedicated IPC client for automated GUI interaction and state inspection.
|
||||||
|
|
||||||
|
## Architectural Patterns
|
||||||
|
- **Event-Driven Metrics:** Uses a custom `EventEmitter` to decouple API lifecycle events from UI rendering, improving performance and responsiveness.
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Project Tracks
|
||||||
|
|
||||||
|
This file tracks all major tracks for the project. Each track has its own detailed plan in its respective folder.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] **Track: Implement context visualization and memory management improvements**
|
||||||
|
*Link: [./tracks/context_management_20260223/](./tracks/context_management_20260223/)*
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
- [x] **Track: Make a human-like test ux interaction where the AI creates a small python project, engages in a 5-turn discussion, and verifies history/session management features via API hooks.**
|
||||||
|
*Link: [./tracks/live_ux_test_20260223/](./tracks/live_ux_test_20260223/)*
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Track live_ux_test_20260223 Context
|
||||||
|
|
||||||
|
- [Specification](./spec.md)
|
||||||
|
- [Implementation Plan](./plan.md)
|
||||||
|
- [Metadata](./metadata.json)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"track_id": "live_ux_test_20260223",
|
||||||
|
"type": "feature",
|
||||||
|
"status": "new",
|
||||||
|
"created_at": "2026-02-23T19:14:00Z",
|
||||||
|
"updated_at": "2026-02-23T19:14:00Z",
|
||||||
|
"description": "Make a human-like test ux interaction where the AI creates a small python project, engages in a 5-turn discussion, and verifies history/session management features via API hooks."
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Implementation Plan: Human-Like UX Interaction Test
|
||||||
|
|
||||||
|
## Phase 1: Infrastructure & Automation Core [checkpoint: 7626531]
|
||||||
|
Establish the foundation for driving the GUI via API hooks and simulation logic.
|
||||||
|
|
||||||
|
- [x] Task: Extend `ApiHookClient` with methods for tab switching and listbox selection if missing. f36d539
|
||||||
|
- [x] Task: Implement `TestUserAgent` class to manage dynamic response generation and action delays. d326242
|
||||||
|
- [x] Task: Write Tests (Verify basic hook connectivity and simulated delays) f36d539
|
||||||
|
- [x] Task: Implement basic 'ping-pong' interaction via hooks. bfe9ef0
|
||||||
|
- [x] Task: Harden API hook thread-safety and simplify GUI state polling. 8bd280e
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 1: Infrastructure & Automation Core' (Protocol in workflow.md) 7626531
|
||||||
|
|
||||||
|
## Phase 2: Workflow Simulation [checkpoint: 9c4a72c]
|
||||||
|
Build the core interaction loop for project creation and AI discussion.
|
||||||
|
|
||||||
|
- [x] Task: Implement 'New Project' scaffolding script (creating a tiny console program). bd5dc16
|
||||||
|
- [x] Task: Implement 5-turn discussion loop logic with sub-agent responses. bd5dc16
|
||||||
|
- [x] Task: Write Tests (Verify state changes in Discussion Hub during simulated chat) 6d16438
|
||||||
|
- [x] Task: Implement 'Thinking' and 'Live' indicator verification logic. 6d16438
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 2: Workflow Simulation' (Protocol in workflow.md) 9c4a72c
|
||||||
|
|
||||||
|
## Phase 3: History & Session Verification [checkpoint: 0f04e06]
|
||||||
|
Simulate complex session management and historical audit features.
|
||||||
|
|
||||||
|
- [x] Task: Implement discussion switching logic (creating/switching between named discussions). 5e1b965
|
||||||
|
- [x] Task: Implement 'Load Prior Log' simulation and 'Tinted Mode' detection. 5e1b965
|
||||||
|
- [x] Task: Write Tests (Verify log loading and tab navigation consistency) 5e1b965
|
||||||
|
- [x] Task: Implement truncation limit verification (forcing a long history and checking bleed). 5e1b965
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 3: History & Session Verification' (Protocol in workflow.md) 0f04e06
|
||||||
|
|
||||||
|
## Phase 4: Final Integration & Regression [checkpoint: 8e63b31]
|
||||||
|
Consolidate the simulation into end-user artifacts and CI tests.
|
||||||
|
|
||||||
|
- [x] Task: Create `live_walkthrough.py` with full visual feedback and manual sign-off. 8bd280e
|
||||||
|
- [x] Task: Create `tests/test_live_workflow.py` for automated regression testing. 8bd280e
|
||||||
|
- [x] Task: Perform a full visual walkthrough and verify 'human-readable' pace. 8e63b31
|
||||||
|
- [x] Task: Conductor - User Manual Verification 'Phase 4: Final Integration & Regression' (Protocol in workflow.md) 8e63b31
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Specification: Human-Like UX Interaction Test
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
This track implements a robust, "human-like" interaction test suite for Manual Slop. The suite will simulate a real user's workflow—from project creation to complex AI discussions and history management—using the application's API hooks. It aims to verify the "Integrated Workspace" functionality, tool execution, and history persistence without requiring manual human input, while remaining slow enough for visual audit.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
- **Standalone Interactive Test**: A Python script (`live_walkthrough.py`) that drives the GUI through a full session, ending with an optional manual sign-off.
|
||||||
|
- **Automated Regression Test**: A pytest integration (`tests/test_live_workflow.py`) that executes the same logic in a headless or automated fashion for CI.
|
||||||
|
- **Target Model**: Google Gemini Flash 2.5.
|
||||||
|
|
||||||
|
## Functional Requirements
|
||||||
|
1. **User Simulation**:
|
||||||
|
- **Dynamic Messaging**: The test agent will generate responses based on the AI's output to simulate a multi-turn conversation.
|
||||||
|
- **Tactile Delays**: Short, random delays (minimum 0.5s) between actions to simulate reading and "typing" time.
|
||||||
|
- **Visual Feedback**: Automatic scrolling of the discussion history and comms logs to keep the "live" action in view.
|
||||||
|
2. **Workflow Scenarios**:
|
||||||
|
- **Project Scaffolding**: Create a new project and initialize a tiny console-based Python program.
|
||||||
|
- **Discussion Loop**: Engage in a ~5-turn conversation with the AI to refine the code.
|
||||||
|
- **Context Management**: Verify that tool calls (filesystem, shell) are reflected correctly in the Comms and Tool Log tabs.
|
||||||
|
- **History Depth**: Verify truncation limits and switching between named discussions.
|
||||||
|
3. **Session Management**:
|
||||||
|
- **Tab Interaction**: Programmatically switch between "Comms Log" and "Tool Log" tabs during operations.
|
||||||
|
- **Historical Audit**: Use the "Load Session Log" feature to load a prior log file and verify "Tinted Mode" visibility.
|
||||||
|
|
||||||
|
## Non-Functional Requirements
|
||||||
|
- **Efficiency**: Minimize token usage by using Gemini Flash and keeping the "User" prompts concise.
|
||||||
|
- **Observability**: The standalone test must be clearly visible to a human observer, with state changes occurring at a "human-readable" pace.
|
||||||
|
|
||||||
|
## Acceptance Criteria
|
||||||
|
- `live_walkthrough.py` successfully completes a 5-turn discussion and signs off.
|
||||||
|
- `tests/test_live_workflow.py` passes in CI environment.
|
||||||
|
- Prior session logs are loaded and visualized without crashing.
|
||||||
|
- Thinking and Live indicators trigger correctly during simulated API calls.
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
- Support for Anthropic API in this specific test track.
|
||||||
|
- Stress testing high-concurrency tool calls.
|
||||||
@@ -0,0 +1,343 @@
|
|||||||
|
# Project Workflow
|
||||||
|
|
||||||
|
## Guiding Principles
|
||||||
|
|
||||||
|
1. **The Plan is the Source of Truth:** All work must be tracked in `plan.md`
|
||||||
|
2. **The Tech Stack is Deliberate:** Changes to the tech stack must be documented in `tech-stack.md` *before* implementation
|
||||||
|
3. **Test-Driven Development:** Write unit tests before implementing functionality
|
||||||
|
4. **High Code Coverage:** Aim for >80% code coverage for all modules
|
||||||
|
5. **User Experience First:** Every decision should prioritize user experience
|
||||||
|
6. **Non-Interactive & CI-Aware:** Prefer non-interactive commands. Use `CI=true` for watch-mode tools (tests, linters) to ensure single execution.
|
||||||
|
|
||||||
|
## Task Workflow
|
||||||
|
|
||||||
|
All tasks follow a strict lifecycle:
|
||||||
|
|
||||||
|
### Standard Task Workflow
|
||||||
|
|
||||||
|
1. **Select Task:** Choose the next available task from `plan.md` in sequential order
|
||||||
|
|
||||||
|
2. **Mark In Progress:** Before beginning work, edit `plan.md` and change the task from `[ ]` to `[~]`
|
||||||
|
|
||||||
|
3. **Write Failing Tests (Red Phase):**
|
||||||
|
- Create a new test file for the feature or bug fix.
|
||||||
|
- Write one or more unit tests that clearly define the expected behavior and acceptance criteria for the task.
|
||||||
|
- **CRITICAL:** Run the tests and confirm that they fail as expected. This is the "Red" phase of TDD. Do not proceed until you have failing tests.
|
||||||
|
|
||||||
|
4. **Implement to Pass Tests (Green Phase):**
|
||||||
|
- Write the minimum amount of application code necessary to make the failing tests pass.
|
||||||
|
- Run the test suite again and confirm that all tests now pass. This is the "Green" phase.
|
||||||
|
|
||||||
|
5. **Refactor (Optional but Recommended):**
|
||||||
|
- With the safety of passing tests, refactor the implementation code and the test code to improve clarity, remove duplication, and enhance performance without changing the external behavior.
|
||||||
|
- Rerun tests to ensure they still pass after refactoring.
|
||||||
|
|
||||||
|
6. **Verify Coverage:** Run coverage reports using the project's chosen tools. For example, in a Python project, this might look like:
|
||||||
|
```bash
|
||||||
|
pytest --cov=app --cov-report=html
|
||||||
|
```
|
||||||
|
Target: >80% coverage for new code. The specific tools and commands will vary by language and framework.
|
||||||
|
|
||||||
|
7. **Document Deviations:** If implementation differs from tech stack:
|
||||||
|
- **STOP** implementation
|
||||||
|
- Update `tech-stack.md` with new design
|
||||||
|
- Add dated note explaining the change
|
||||||
|
- Resume implementation
|
||||||
|
|
||||||
|
8. **Commit Code Changes:**
|
||||||
|
- Stage all code changes related to the task.
|
||||||
|
- Propose a clear, concise commit message e.g, `feat(ui): Create basic HTML structure for calculator`.
|
||||||
|
- Perform the commit.
|
||||||
|
|
||||||
|
9. **Attach Task Summary with Git Notes:**
|
||||||
|
- **Step 9.1: Get Commit Hash:** Obtain the hash of the *just-completed commit* (`git log -1 --format="%H"`).
|
||||||
|
- **Step 9.2: Draft Note Content:** Create a detailed summary for the completed task. This should include the task name, a summary of changes, a list of all created/modified files, and the core "why" for the change.
|
||||||
|
- **Step 9.3: Attach Note:** Use the `git notes` command to attach the summary to the commit.
|
||||||
|
```bash
|
||||||
|
# The note content from the previous step is passed via the -m flag.
|
||||||
|
git notes add -m "<note content>" <commit_hash>
|
||||||
|
```
|
||||||
|
|
||||||
|
10. **Get and Record Task Commit SHA:**
|
||||||
|
- **Step 10.1: Update Plan:** Read `plan.md`, find the line for the completed task, update its status from `[~]` to `[x]`, and append the first 7 characters of the *just-completed commit's* commit hash.
|
||||||
|
- **Step 10.2: Write Plan:** Write the updated content back to `plan.md`.
|
||||||
|
|
||||||
|
11. **Commit Plan Update:**
|
||||||
|
- **Action:** Stage the modified `plan.md` file.
|
||||||
|
- **Action:** Commit this change with a descriptive message (e.g., `conductor(plan): Mark task 'Create user model' as complete`).
|
||||||
|
|
||||||
|
### Phase Completion Verification and Checkpointing Protocol
|
||||||
|
|
||||||
|
**Trigger:** This protocol is executed immediately after a task is completed that also concludes a phase in `plan.md`.
|
||||||
|
|
||||||
|
1. **Announce Protocol Start:** Inform the user that the phase is complete and the verification and checkpointing protocol has begun.
|
||||||
|
|
||||||
|
2. **Ensure Test Coverage for Phase Changes:**
|
||||||
|
- **Step 2.1: Determine Phase Scope:** To identify the files changed in this phase, you must first find the starting point. Read `plan.md` to find the Git commit SHA of the *previous* phase's checkpoint. If no previous checkpoint exists, the scope is all changes since the first commit.
|
||||||
|
- **Step 2.2: List Changed Files:** Execute `git diff --name-only <previous_checkpoint_sha> HEAD` to get a precise list of all files modified during this phase.
|
||||||
|
- **Step 2.3: Verify and Create Tests:** For each file in the list:
|
||||||
|
- **CRITICAL:** First, check its extension. Exclude non-code files (e.g., `.json`, `.md`, `.yaml`).
|
||||||
|
- For each remaining code file, verify a corresponding test file exists.
|
||||||
|
- If a test file is missing, you **must** create one. Before writing the test, **first, analyze other test files in the repository to determine the correct naming convention and testing style.** The new tests **must** validate the functionality described in this phase's tasks (`plan.md`).
|
||||||
|
|
||||||
|
3. **Execute Automated Tests with Proactive Debugging:**
|
||||||
|
- Before execution, you **must** announce the exact shell command you will use to run the tests.
|
||||||
|
- **Example Announcement:** "I will now run the automated test suite to verify the phase. **Command:** `CI=true npm test`"
|
||||||
|
- Execute the announced command.
|
||||||
|
- If tests fail, you **must** inform the user and begin debugging. You may attempt to propose a fix a **maximum of two times**. If the tests still fail after your second proposed fix, you **must stop**, report the persistent failure, and ask the user for guidance.
|
||||||
|
|
||||||
|
4. **Execute Automated API Hook Verification:**
|
||||||
|
- **CRITICAL:** The Conductor agent will now automatically execute verification tasks using the application's API hooks.
|
||||||
|
- The agent will announce the start of the automated verification to the user.
|
||||||
|
- It will then communicate with the application's IPC server to trigger the necessary verification functions.
|
||||||
|
- **Result Handling:**
|
||||||
|
- All results (successes and failures) from the API hook invocations will be logged.
|
||||||
|
- If all automated verifications pass, the agent will inform the user and proceed to the next step (Create Checkpoint Commit).
|
||||||
|
- If any automated verification fails, the agent will halt the workflow, present the detailed failure logs to the user, and await further instructions for debugging or remediation.
|
||||||
|
|
||||||
|
5. **Present Automated Verification Results and User Confirmation:**
|
||||||
|
- After executing automated verification, the Conductor agent will present the results to the user.
|
||||||
|
- If verification passed, the agent will state: "Automated verification completed successfully."
|
||||||
|
- If verification failed, the agent will state: "Automated verification failed. Please review the logs above for details. You may attempt to propose a fix a **maximum of two times**. If the tests still fail after your second proposed fix, you **must stop**, report the persistent failure, and ask the user for guidance."
|
||||||
|
- **PAUSE** and await the user's response. Do not proceed without an explicit yes or confirmation from the user to proceed if tests pass, or guidance if tests fail.
|
||||||
|
|
||||||
|
6. **Create Checkpoint Commit:**
|
||||||
|
- Stage all changes. If no changes occurred in this step, proceed with an empty commit.
|
||||||
|
- Perform the commit with a clear and concise message (e.g., `conductor(checkpoint): Checkpoint end of Phase X`).
|
||||||
|
|
||||||
|
7. **Attach Auditable Verification Report using Git Notes:**
|
||||||
|
- **Step 7.1: Draft Note Content:** Create a detailed verification report including the automated test command, the manual verification steps, and the user's confirmation.
|
||||||
|
- **Step 7.2: Attach Note:** Use the `git notes` command and the full commit hash from the previous step to attach the full report to the checkpoint commit.
|
||||||
|
|
||||||
|
8. **Get and Record Phase Checkpoint SHA:**
|
||||||
|
- **Step 8.1: Get Commit Hash:** Obtain the hash of the *just-created checkpoint commit* (`git log -1 --format="%H"`).
|
||||||
|
- **Step 8.2: Update Plan:** Read `plan.md`, find the heading for the completed phase, and append the first 7 characters of the commit hash in the format `[checkpoint: <sha>]`.
|
||||||
|
- **Step 8.3: Write Plan:** Write the updated content back to `plan.md`.
|
||||||
|
|
||||||
|
9. **Commit Plan Update:**
|
||||||
|
- **Action:** Stage the modified `plan.md` file.
|
||||||
|
- **Action:** Commit this change with a descriptive message following the format `conductor(plan): Mark phase '<PHASE NAME>' as complete`.
|
||||||
|
|
||||||
|
10. **Announce Completion:** Inform the user that the phase is complete and the checkpoint has been created, with the detailed verification report attached as a git note.
|
||||||
|
|
||||||
|
### Verification via API Hooks
|
||||||
|
|
||||||
|
For features involving the GUI or complex internal state, unit tests are often insufficient. You MUST use the application's built-in API hooks for empirical verification:
|
||||||
|
|
||||||
|
1. **Launch the App with Hooks:** Run the application in a separate shell with the `--enable-test-hooks` flag:
|
||||||
|
```powershell
|
||||||
|
uv run python gui.py --enable-test-hooks
|
||||||
|
```
|
||||||
|
This starts the hook server on port `8999`.
|
||||||
|
|
||||||
|
2. **Use the pytest `live_gui` Fixture:** For automated tests, use the session-scoped `live_gui` fixture defined in `tests/conftest.py`. This fixture handles the lifecycle (startup/shutdown) of the application with hooks enabled.
|
||||||
|
```python
|
||||||
|
def test_my_feature(live_gui):
|
||||||
|
# The GUI is now running on port 8999
|
||||||
|
...
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Verify via ApiHookClient:** Use the `ApiHookClient` in `api_hook_client.py` to interact with the running application. It includes robust retry logic and health checks.
|
||||||
|
|
||||||
|
4. **Verify via REST Commands:** Use PowerShell or `curl` to send commands to the application and verify the response. For example, to check health:
|
||||||
|
```powershell
|
||||||
|
Invoke-RestMethod -Uri "http://127.0.0.1:8999/status" -Method Get
|
||||||
|
```
|
||||||
|
|
||||||
|
### Quality Gates
|
||||||
|
|
||||||
|
Before marking any task complete, verify:
|
||||||
|
|
||||||
|
- [ ] All tests pass
|
||||||
|
- [ ] Code coverage meets requirements (>80%)
|
||||||
|
- [ ] Code follows project's code style guidelines (as defined in `code_styleguides/`)
|
||||||
|
- [ ] All public functions/methods are documented (e.g., docstrings, JSDoc, GoDoc)
|
||||||
|
- [ ] Type safety is enforced (e.g., type hints, TypeScript types, Go types)
|
||||||
|
- [ ] No linting or static analysis errors (using the project's configured tools)
|
||||||
|
- [ ] Works correctly on mobile (if applicable)
|
||||||
|
- [ ] Documentation updated if needed
|
||||||
|
- [ ] No security vulnerabilities introduced
|
||||||
|
|
||||||
|
## Development Commands
|
||||||
|
|
||||||
|
**AI AGENT INSTRUCTION: This section should be adapted to the project's specific language, framework, and build tools.**
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
```bash
|
||||||
|
# Example: Commands to set up the development environment (e.g., install dependencies, configure database)
|
||||||
|
# e.g., for a Node.js project: npm install
|
||||||
|
# e.g., for a Go project: go mod tidy
|
||||||
|
```
|
||||||
|
|
||||||
|
### Daily Development
|
||||||
|
```bash
|
||||||
|
# Example: Commands for common daily tasks (e.g., start dev server, run tests, lint, format)
|
||||||
|
# e.g., for a Node.js project: npm run dev, npm test, npm run lint
|
||||||
|
# e.g., for a Go project: go run main.go, go test ./..., go fmt ./...
|
||||||
|
```
|
||||||
|
|
||||||
|
### Before Committing
|
||||||
|
```bash
|
||||||
|
# Example: Commands to run all pre-commit checks (e.g., format, lint, type check, run tests)
|
||||||
|
# e.g., for a Node.js project: npm run check
|
||||||
|
# e.g., for a Go project: make check (if a Makefile exists)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing Requirements
|
||||||
|
|
||||||
|
### Unit Testing
|
||||||
|
- Every module must have corresponding tests.
|
||||||
|
- Use appropriate test setup/teardown mechanisms (e.g., fixtures, beforeEach/afterEach).
|
||||||
|
- Mock external dependencies.
|
||||||
|
- Test both success and failure cases.
|
||||||
|
|
||||||
|
### Integration Testing
|
||||||
|
- Test complete user flows
|
||||||
|
- Verify database transactions
|
||||||
|
- Test authentication and authorization
|
||||||
|
- Check form submissions
|
||||||
|
|
||||||
|
### Mobile Testing
|
||||||
|
- Test on actual iPhone when possible
|
||||||
|
- Use Safari developer tools
|
||||||
|
- Test touch interactions
|
||||||
|
- Verify responsive layouts
|
||||||
|
- Check performance on 3G/4G
|
||||||
|
|
||||||
|
## Code Review Process
|
||||||
|
|
||||||
|
### Self-Review Checklist
|
||||||
|
Before requesting review:
|
||||||
|
|
||||||
|
1. **Functionality**
|
||||||
|
- Feature works as specified
|
||||||
|
- Edge cases handled
|
||||||
|
- Error messages are user-friendly
|
||||||
|
|
||||||
|
2. **Code Quality**
|
||||||
|
- Follows style guide
|
||||||
|
- DRY principle applied
|
||||||
|
- Clear variable/function names
|
||||||
|
- Appropriate comments
|
||||||
|
|
||||||
|
3. **Testing**
|
||||||
|
- Unit tests comprehensive
|
||||||
|
- Integration tests pass
|
||||||
|
- Coverage adequate (>80%)
|
||||||
|
|
||||||
|
4. **Security**
|
||||||
|
- No hardcoded secrets
|
||||||
|
- Input validation present
|
||||||
|
- SQL injection prevented
|
||||||
|
- XSS protection in place
|
||||||
|
|
||||||
|
5. **Performance**
|
||||||
|
- Database queries optimized
|
||||||
|
- Images optimized
|
||||||
|
- Caching implemented where needed
|
||||||
|
|
||||||
|
6. **Mobile Experience**
|
||||||
|
- Touch targets adequate (44x44px)
|
||||||
|
- Text readable without zooming
|
||||||
|
- Performance acceptable on mobile
|
||||||
|
- Interactions feel native
|
||||||
|
|
||||||
|
## Commit Guidelines
|
||||||
|
|
||||||
|
### Message Format
|
||||||
|
```
|
||||||
|
<type>(<scope>): <description>
|
||||||
|
|
||||||
|
[optional body]
|
||||||
|
|
||||||
|
[optional footer]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Types
|
||||||
|
- `feat`: New feature
|
||||||
|
- `fix`: Bug fix
|
||||||
|
- `docs`: Documentation only
|
||||||
|
- `style`: Formatting, missing semicolons, etc.
|
||||||
|
- `refactor`: Code change that neither fixes a bug nor adds a feature
|
||||||
|
- `test`: Adding missing tests
|
||||||
|
- `chore`: Maintenance tasks
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
```bash
|
||||||
|
git commit -m "feat(auth): Add remember me functionality"
|
||||||
|
git commit -m "fix(posts): Correct excerpt generation for short posts"
|
||||||
|
git commit -m "test(comments): Add tests for emoji reaction limits"
|
||||||
|
git commit -m "style(mobile): Improve button touch targets"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Definition of Done
|
||||||
|
|
||||||
|
A task is complete when:
|
||||||
|
|
||||||
|
1. All code implemented to specification
|
||||||
|
2. Unit tests written and passing
|
||||||
|
3. Code coverage meets project requirements
|
||||||
|
4. Documentation complete (if applicable)
|
||||||
|
5. Code passes all configured linting and static analysis checks
|
||||||
|
6. Works beautifully on mobile (if applicable)
|
||||||
|
7. Implementation notes added to `plan.md`
|
||||||
|
8. Changes committed with proper message
|
||||||
|
9. Git note with task summary attached to the commit
|
||||||
|
|
||||||
|
## Emergency Procedures
|
||||||
|
|
||||||
|
### Critical Bug in Production
|
||||||
|
1. Create hotfix branch from main
|
||||||
|
2. Write failing test for bug
|
||||||
|
3. Implement minimal fix
|
||||||
|
4. Test thoroughly including mobile
|
||||||
|
5. Deploy immediately
|
||||||
|
6. Document in plan.md
|
||||||
|
|
||||||
|
### Data Loss
|
||||||
|
1. Stop all write operations
|
||||||
|
2. Restore from latest backup
|
||||||
|
3. Verify data integrity
|
||||||
|
4. Document incident
|
||||||
|
5. Update backup procedures
|
||||||
|
|
||||||
|
### Security Breach
|
||||||
|
1. Rotate all secrets immediately
|
||||||
|
2. Review access logs
|
||||||
|
3. Patch vulnerability
|
||||||
|
4. Notify affected users (if any)
|
||||||
|
5. Document and update security procedures
|
||||||
|
|
||||||
|
## Deployment Workflow
|
||||||
|
|
||||||
|
### Pre-Deployment Checklist
|
||||||
|
- [ ] All tests passing
|
||||||
|
- [ ] Coverage >80%
|
||||||
|
- [ ] No linting errors
|
||||||
|
- [ ] Mobile testing complete
|
||||||
|
- [ ] Environment variables configured
|
||||||
|
- [ ] Database migrations ready
|
||||||
|
- [ ] Backup created
|
||||||
|
|
||||||
|
### Deployment Steps
|
||||||
|
1. Merge feature branch to main
|
||||||
|
2. Tag release with version
|
||||||
|
3. Push to deployment service
|
||||||
|
4. Run database migrations
|
||||||
|
5. Verify deployment
|
||||||
|
6. Test critical paths
|
||||||
|
7. Monitor for errors
|
||||||
|
|
||||||
|
### Post-Deployment
|
||||||
|
1. Monitor analytics
|
||||||
|
2. Check error logs
|
||||||
|
3. Gather user feedback
|
||||||
|
4. Plan next iteration
|
||||||
|
|
||||||
|
## Continuous Improvement
|
||||||
|
|
||||||
|
- Review workflow weekly
|
||||||
|
- Update based on pain points
|
||||||
|
- Document lessons learned
|
||||||
|
- Optimize for user happiness
|
||||||
|
- Keep things simple and maintainable
|
||||||
+10
-4
@@ -1,15 +1,21 @@
|
|||||||
[ai]
|
[ai]
|
||||||
provider = "anthropic"
|
provider = "gemini"
|
||||||
model = "claude-opus-4-6"
|
model = "gemini-2.5-flash"
|
||||||
|
temperature = 0.6000000238418579
|
||||||
|
max_tokens = 12000
|
||||||
|
history_trunc_limit = 8000
|
||||||
|
system_prompt = "DO NOT EVER make a shell script unless told to. DO NOT EVER make a readme or a file describing your changes unless your are told to. If you have commands I should be entering into the command line or if you have something to explain to me, please just use code blocks or normal text output. DO NOT DO ANYTHING OTHER THAN WHAT YOU WERE TOLD TODO. DO NOT EVER, EVER DO ANYTHING OTHER THAN WHAT YOU WERE TOLD TO DO. IF YOU WANT TO DO OTHER THINGS, SIMPLY SUGGEST THEM, AND THEN I WILL REVIEW YOUR CHANGES, AND MAKE THE DECISION ON HOW TO PROCEED. WHEN WRITING SCRIPTS USE A 120-160 character limit per line. I don't want to see scrunched code.\n"
|
||||||
|
|
||||||
[theme]
|
[theme]
|
||||||
palette = "10x Dark"
|
palette = "10x Dark"
|
||||||
font_path = "C:/Users/Ed/AppData/Local/uv/cache/archive-v0/WSthkYsQ82b_ywV6DkiaJ/pygame_gui/data/FiraCode-Regular.ttf"
|
font_path = "C:/Users/Ed/AppData/Local/uv/cache/archive-v0/WSthkYsQ82b_ywV6DkiaJ/pygame_gui/data/FiraCode-Regular.ttf"
|
||||||
font_size = 18.0
|
font_size = 18.0
|
||||||
scale = 1.1
|
scale = 1.0
|
||||||
|
|
||||||
[projects]
|
[projects]
|
||||||
paths = [
|
paths = [
|
||||||
"manual_slop.toml",
|
"manual_slop.toml",
|
||||||
|
"C:/projects/forth/bootslop/bootslop.toml",
|
||||||
|
"C:\\projects\\manual_slop\\tests\\temp_project.toml",
|
||||||
]
|
]
|
||||||
active = "manual_slop.toml"
|
active = "C:\\projects\\manual_slop\\tests\\temp_project.toml"
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
[output]
|
|
||||||
namespace = "colorforth_bootslop"
|
|
||||||
output_dir = "."
|
|
||||||
|
|
||||||
[files]
|
|
||||||
base_dir = "C:/projects/forth/bootslop"
|
|
||||||
paths = [
|
|
||||||
"./attempt_1/*",
|
|
||||||
"./scripts/*",
|
|
||||||
"./references/Architectural_Consolidation.md",
|
|
||||||
"./references/neokineogfx_in-depth.md",
|
|
||||||
"./references/blog_in-depth.md",
|
|
||||||
"./references/kyra_in-depth.md",
|
|
||||||
".editorconfig",
|
|
||||||
"GEMINI.md",
|
|
||||||
"CONVENTIONS.md",
|
|
||||||
]
|
|
||||||
|
|
||||||
[screenshots]
|
|
||||||
base_dir = "C:/Users/Ed/scoop/apps/sharex/current/ShareX/Screenshots/2026-02"
|
|
||||||
paths = []
|
|
||||||
|
|
||||||
[discussion]
|
|
||||||
history = []
|
|
||||||
|
|
||||||
[ai]
|
|
||||||
provider = "anthropic"
|
|
||||||
model = "claude-sonnet-4-6"
|
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# Manual Slop
|
||||||
|
|
||||||
|
A GUI orchestrator for local LLM-driven coding sessions, built to prevent the AI from running wild and to provide total transparency into the context and execution state.
|
||||||
|
|
||||||
|
## Core Management Panels
|
||||||
|
|
||||||
|
### Projects Panel
|
||||||
|
|
||||||
|
The heart of context management.
|
||||||
|
|
||||||
|
> **Note:** The Config panel has been removed. Output directory and auto-add history settings are now integrated into the Projects and Discussion History panels respectively.
|
||||||
|
|
||||||
|
- **Configuration:** You specify the Git Directory (for commit tracking) and a Main Context File (the markdown file containing your project's notes and schema).
|
||||||
|
- **Word-Wrap Toggle:** Dynamically swaps text rendering in large read-only panels (Responses, Comms Log) between unwrapped (ideal for viewing precise code formatting) and wrapped (ideal for prose).
|
||||||
|
- **Project Switching:** Switch between different <project>.toml profiles to instantly swap out your entire active file list, discussion history, and settings.
|
||||||
|
|
||||||
|
### Discussion History
|
||||||
|
|
||||||
|
Manages your conversational branches, preventing context poisoning across different tasks.
|
||||||
|
|
||||||
|
- **Discussions Sub-Menu:** Allows you to create separate timelines for different tasks (e.g., "Refactoring Auth" vs. "Adding API Endpoints").
|
||||||
|
- **Git Commit Tracking:** Clicking "Update Commit" reads HEAD from your project's git directory and stamps the discussion.
|
||||||
|
- **Entry Management:** Each turn has a Role (User, AI, System). You can toggle entries between **Read** and **Edit** modes, collapse them, or hit [+ Max] to open them in the Global Text Viewer.
|
||||||
|
- **Auto-Add:** If toggled, anything sent from the "Message" panel and returned to the "Response" panel is automatically appended to the current discussion history.
|
||||||
|
|
||||||
|
### Files & Screenshots
|
||||||
|
|
||||||
|
Controls what is explicitly fed into the context compiler.
|
||||||
|
|
||||||
|
- **Base Dir:** Defines the root for path resolution and tool constraints.
|
||||||
|
- **Paths:** Explicit files or wildcard globs (e.g., src/**/*.rs).
|
||||||
|
- When generating a request, full file contents are inlined into the context by default (`summary_only=False`). The AI can also call `get_file_summary` via its MCP tools to get a compact structural view of any file on demand.
|
||||||
|
|
||||||
|
## Interaction Panels
|
||||||
|
|
||||||
|
### Provider
|
||||||
|
|
||||||
|
Switch between API backends (Gemini, Anthropic) on the fly. Clicking "Fetch Models" queries the active provider for the latest model list.
|
||||||
|
|
||||||
|
### Message & Response
|
||||||
|
|
||||||
|
- **Message:** Your input field.
|
||||||
|
- **Gen + Send:** Compiles the markdown context and dispatches the background thread to the AI.
|
||||||
|
- **MD Only:** Dry-runs the compiler so you can inspect the generated <project>_00N.md without triggering an API charge.
|
||||||
|
- **Response:** The read-only output. Flashes green when a new response arrives.
|
||||||
|
|
||||||
|
### Global Text Viewer & Script Outputs
|
||||||
|
|
||||||
|
- **Last Script Output:** Whenever the AI executes a background script, this window pops up, flashing blue. It contains both the executed script and the stdout/stderr. The `[+ Maximize]` buttons read directly from stored instance variables (`_last_script`, `_last_output`) rather than DPG widget tags, so they work correctly regardless of word-wrap state.
|
||||||
|
- **Text Viewer:** A large, resizable global popup invoked anytime you click a [+] or [+ Maximize] button in the UI. Used for deep-reading long logs, discussion entries, or script bodies.
|
||||||
|
- **Confirm Dialog:** The `[+ Maximize]` button in the script approval modal passes the script text directly as `user_data` at button-creation time, so it remains safe to click even after the dialog has been dismissed.
|
||||||
|
|
||||||
|
## System Prompts
|
||||||
|
|
||||||
|
Provides two text inputs for overriding default instructions:
|
||||||
|
|
||||||
|
1. **Global:** Applied across every project you load.
|
||||||
|
2. **Project:** Specific to the active workspace.
|
||||||
|
These are concatenated onto the strict tool-usage guidelines the agent is initialized with.
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
|||||||
|
# Guide: Architecture
|
||||||
|
|
||||||
|
Overview of the package design, state management, and code-path layout.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The purpose of this software is to alleviate the pain points of using AI as a local co-pilot by encapsulating the workflow into a resilient, strictly controlled state machine. It manages context generation, API throttling, human-in-the-loop tool execution, and session-long logging.
|
||||||
|
|
||||||
|
There are two primary state boundaries used:
|
||||||
|
|
||||||
|
* The GUI State (Main Thread, Retained-Mode via Dear PyGui)
|
||||||
|
* The AI State (Daemon Thread, stateless execution loop)
|
||||||
|
|
||||||
|
All synchronization between these boundaries is managed via lock-protected queues and events.
|
||||||
|
|
||||||
|
## Code Paths
|
||||||
|
|
||||||
|
### Lifetime & Application Boot
|
||||||
|
|
||||||
|
The application lifetime is localized within App.run in gui.py.
|
||||||
|
|
||||||
|
1. __init__ parses the global config.toml (which sets the active provider, theme, and project paths).
|
||||||
|
2. It immediately hands off to project_manager.py to deserialize the active <project>.toml which hydrates the session's files, discussion histories, and prompts.
|
||||||
|
3. Dear PyGui's dpg contexts are bootstrapped with docking_viewport=True, allowing individual GUI panels to exist as native OS windows.
|
||||||
|
4. The main thread enters a blocking while dpg.is_dearpygui_running() render loop.
|
||||||
|
5. On shutdown (clean exit), it performs a dual-flush: _flush_to_project() commits the UI state back to the <project>.toml, and _flush_to_config() commits the global state to config.toml. The viewport layout is automatically serialized to dpg_layout.ini.
|
||||||
|
|
||||||
|
### Context Shaping & Aggregation
|
||||||
|
|
||||||
|
Before making a call to an AI Provider, the current state of the workspace is resolved into a dense Markdown representation.
|
||||||
|
This occurs inside aggregate.run.
|
||||||
|
|
||||||
|
If using the default workflow, aggregate.py hashes through the following process:
|
||||||
|
|
||||||
|
1. **Glob Resolution:** Iterates through config["files"]["paths"] and unpacks any wildcards (e.g., src/**/*.rs) against the designated base_dir.
|
||||||
|
2. **File Item Build:** `build_file_items()` reads each resolved file once, storing path, content, and `mtime`. This list is returned alongside the markdown so `ai_client.py` can use it for dynamic context refresh after tool calls without re-reading from disk.
|
||||||
|
3. **Markdown Generation:** `build_markdown_from_items()` assembles the final `<project>_00N.md` string. By default (`summary_only=False`) it inlines full file contents. If `summary_only=True`, it delegates to `summarize.build_summary_markdown()` which uses AST-based heuristics to produce compact structural summaries instead.
|
||||||
|
4. The Markdown file is persisted to disk (`./md_gen/` by default) for auditing. `run()` returns a 3-tuple `(markdown_str, output_path, file_items)`.
|
||||||
|
|
||||||
|
### AI Communication & The Tool Loop
|
||||||
|
|
||||||
|
The communication model is unified under ai_client.py, which normalizes the Gemini and Anthropic SDKs into a singular interface send(md_content, user_message, base_dir, file_items).
|
||||||
|
|
||||||
|
The loop is defined as follows:
|
||||||
|
|
||||||
|
1. **Prompt Injection:** The aggregated Markdown context and system prompt are injected. For Gemini, the system_instruction and tools are stored in an explicit cache via `client.caches.create()` with a 1-hour TTL; if cache creation fails (under minimum token threshold), it falls back to inline system_instruction. When context changes mid-session, the old cache is deleted and a new one is created. For Anthropic, the system prompt + context are sent as `system=` blocks with `cache_control: ephemeral` on the last chunk, and tools carry `cache_control: ephemeral` on the last tool definition.
|
||||||
|
2. **Execution Loop:** A MAX_TOOL_ROUNDS (default 10) bounded loop begins. The tools list for Anthropic is built once per session and reused.
|
||||||
|
3. The AI provider is polled.
|
||||||
|
4. If the provider's stop_reason is tool_use:
|
||||||
|
1. The loop parses the requested tool (either a read-only MCP tool or the destructive PowerShell tool).
|
||||||
|
2. If PowerShell, it dispatches a blocking event to the Main Thread (see *On Tool Execution & Concurrency*).
|
||||||
|
3. Once the last tool result in the batch is retrieved, the loop executes a **Dynamic Refresh** (`_reread_file_items`). Any files currently tracked by the project are pulled from disk fresh. The `file_items` variable is reassigned so subsequent tool rounds see the updated content.
|
||||||
|
4. For Anthropic: the refreshed file contents are appended as a text block to the tool_results user message. For Gemini: the refreshed contents are appended to the last function response's output string. In both cases, the block is prefixed with `[FILES UPDATED]` / `[SYSTEM: FILES UPDATED]`.
|
||||||
|
5. On subsequent rounds, stale file-refresh blocks from previous turns are stripped from history to prevent token accumulation. For Gemini, old tool outputs exceeding `_history_trunc_limit` characters are also truncated.
|
||||||
|
5. Once the model outputs standard text, the loop terminates and yields the string back to the GUI callback.
|
||||||
|
|
||||||
|
### On Tool Execution & Concurrency
|
||||||
|
|
||||||
|
When the AI calls a safe MCP tool (like read_file or search_files), the daemon thread immediately executes it via mcp_client.py and returns the result.
|
||||||
|
|
||||||
|
However, when the AI requests run_powershell, the operation halts:
|
||||||
|
|
||||||
|
1. The Daemon Thread instantiates a ConfirmDialog object containing the payload and calls .wait(). This blocks the thread on a threading.Event().
|
||||||
|
2. The ConfirmDialog instance is safely placed in a _pending_dialog_lock.
|
||||||
|
3. The Main Thread, during its next frame cycle, pops the dialog from the lock and renders an OS-level modal window using dpg.window(modal=True).
|
||||||
|
4. The user can inspect the script, modify it in the text box, or reject it entirely.
|
||||||
|
5. Upon the user clicking "Approve & Run", the main thread triggers the threading.Event, unblocking the Daemon Thread.
|
||||||
|
6. The Daemon Thread passes the script to shell_runner.py, captures stdout, stderr, and exit_code, logs it to session_logger.py, and returns it to the LLM.
|
||||||
|
|
||||||
|
### On Context History Pruning (Anthropic)
|
||||||
|
|
||||||
|
Because the Anthropic API requires sending the entire conversation history on every request, long sessions will inevitably hit the invalid_request_error: prompt is too long.
|
||||||
|
|
||||||
|
To solve this, ai_client.py implements an aggressive pruning algorithm:
|
||||||
|
|
||||||
|
1. _strip_stale_file_refreshes: It recursively sweeps backward through the history dict and strips out large [FILES UPDATED] data blocks from old turns, preserving only the most recent snapshot.
|
||||||
|
2. _trim_anthropic_history: If the estimated token count still exceeds _ANTHROPIC_MAX_PROMPT_TOKENS (~180,000), it slices off the oldest user/assistant message pairs from the beginning of the history array.
|
||||||
|
3. The loop guarantees that at least the System prompt, Tool Definitions, and the final user prompt are preserved.
|
||||||
|
|
||||||
|
### Session Persistence
|
||||||
|
|
||||||
|
All I/O bound session data is recorded sequentially. session_logger.py hooks into the execution loops and records:
|
||||||
|
|
||||||
|
- logs/comms_<ts>.log: A JSON-L structured timeline of every raw payload sent/received.
|
||||||
|
- logs/toolcalls_<ts>.log: A sequential markdown record detailing every AI tool invocation and its exact stdout result.
|
||||||
|
- scripts/generated/: Every .ps1 script approved and executed by the shell runner is physically written to disk for version control transparency.
|
||||||
|
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
# Guide: Tooling
|
||||||
|
|
||||||
|
Overview of the tool dispatch and execution model.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
The agent is provided two classes of tools: Read-Only MCP Tools, and a Destructive Execution Loop.
|
||||||
|
|
||||||
|
## 1. Read-Only Context (MCP Tools)
|
||||||
|
|
||||||
|
Implemented in mcp_client.py. These tools allow the AI to selectively expand its knowledge of the codebase without requiring the user to dump entire 10,000-line files into the static context prefix.
|
||||||
|
|
||||||
|
### Security & Scope
|
||||||
|
|
||||||
|
Every **filesystem** MCP tool passes its arguments through `_resolve_and_check`. This function ensures that the requested path falls under one of the allowed directories defined in the GUI's Base Dir configurations.
|
||||||
|
If the AI attempts to read or search a path outside the project bounds, the tool safely catches the constraint violation and returns ACCESS DENIED.
|
||||||
|
|
||||||
|
The two **web tools** (`web_search`, `fetch_url`) bypass this check entirely — they have no filesystem access and are unrestricted.
|
||||||
|
|
||||||
|
### Supplied Tools:
|
||||||
|
|
||||||
|
**Filesystem tools** (access-controlled via `_resolve_and_check`):
|
||||||
|
* `read_file(path)`: Returns the raw UTF-8 text of a file.
|
||||||
|
* `list_directory(path)`: Returns a formatted table of a directory's contents, showing file vs dir and byte sizes.
|
||||||
|
* `search_files(path, pattern)`: Executes a glob search (e.g., `**/*.py`) within an allowed directory.
|
||||||
|
* `get_file_summary(path)`: Invokes the local `summarize.py` heuristic parser to get the AST structure of a file without reading the whole body.
|
||||||
|
|
||||||
|
**Web tools** (unrestricted — no filesystem access):
|
||||||
|
* `web_search(query)`: Queries DuckDuckGo's raw HTML endpoint and returns the top 5 results (title, URL, snippet) using a native `_DDGParser` (HTMLParser subclass) to avoid heavy dependencies.
|
||||||
|
* `fetch_url(url)`: Downloads a target webpage and strips out all scripts, styling, and structural HTML via `_TextExtractor`, returning only the raw prose content (clamped to 40,000 characters). Automatically resolves DuckDuckGo redirect links.
|
||||||
|
|
||||||
|
## 2. Destructive Execution (run_powershell)
|
||||||
|
|
||||||
|
The core manipulation mechanism. This is a single, heavily guarded tool.
|
||||||
|
|
||||||
|
### Flow
|
||||||
|
|
||||||
|
1. The AI generates a 'run_powershell' payload containing a PowerShell script.
|
||||||
|
2. The AI background thread calls confirm_and_run_callback (injected by gui.py).
|
||||||
|
3. The background thread blocks completely, creating a modal popup on the main GUI thread.
|
||||||
|
4. The user reads the script and chooses to Approve or Reject.
|
||||||
|
5. If Approved, shell_runner.py executes the script using -NoProfile -NonInteractive -Command within the specified base_dir.
|
||||||
|
6. The combined stdout, stderr, and EXIT CODE are captured and returned to the AI in the tool result block.
|
||||||
|
|
||||||
|
### AI Guidelines
|
||||||
|
|
||||||
|
The core system prompt explicitly guides the AI on how to use this tool safely:
|
||||||
|
|
||||||
|
* Prefer targeted replacements (using PowerShell's .Replace()) over full rewrites where possible.
|
||||||
|
* If a file is large and complex (requiring specific escape characters), do not attempt an inline python -c script. Instead, use a PowerShell here-string (@'...'@) to write a temporary python helper script to disk, execute the python script, and then delete it.
|
||||||
|
|
||||||
|
### Synthetic Context Refresh
|
||||||
|
|
||||||
|
After the **last** tool call in each round finishes (when multiple tools are called in a single round, the refresh happens once after all of them), ai_client runs `_reread_file_items`. It fetches the latest disk state of all files in the current project context. The `file_items` variable is reassigned so subsequent tool rounds within the same request use the fresh content.
|
||||||
|
|
||||||
|
For Anthropic, the refreshed contents are injected as a text block in the `tool_results` user message. For Gemini, they are appended to the last function response's output string. In both cases, the block is prefixed with `[FILES UPDATED]` / `[SYSTEM: FILES UPDATED]`.
|
||||||
|
|
||||||
|
On the next tool round, stale file-refresh blocks from previous rounds are stripped from history to prevent token accumulation. This means if the AI writes to a file, it instantly "sees" the modification in its next turn without having to waste a cycle calling `read_file`, and the cost of carrying the full file snapshot is limited to one round.
|
||||||
-1018
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
|||||||
|
"""
|
||||||
|
Decoupled event emission system for cross-module communication.
|
||||||
|
"""
|
||||||
|
from typing import Callable, Any, Dict, List
|
||||||
|
|
||||||
|
class EventEmitter:
|
||||||
|
"""
|
||||||
|
Simple event emitter for decoupled communication between modules.
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
"""Initializes the EventEmitter with an empty listener map."""
|
||||||
|
self._listeners: Dict[str, List[Callable]] = {}
|
||||||
|
|
||||||
|
def on(self, event_name: str, callback: Callable):
|
||||||
|
"""
|
||||||
|
Registers a callback for a specific event.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
event_name: The name of the event to listen for.
|
||||||
|
callback: The function to call when the event is emitted.
|
||||||
|
"""
|
||||||
|
if event_name not in self._listeners:
|
||||||
|
self._listeners[event_name] = []
|
||||||
|
self._listeners[event_name].append(callback)
|
||||||
|
|
||||||
|
def emit(self, event_name: str, *args: Any, **kwargs: Any):
|
||||||
|
"""
|
||||||
|
Emits an event, calling all registered callbacks.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
event_name: The name of the event to emit.
|
||||||
|
*args: Positional arguments to pass to callbacks.
|
||||||
|
**kwargs: Keyword arguments to pass to callbacks.
|
||||||
|
"""
|
||||||
|
if event_name in self._listeners:
|
||||||
|
for callback in self._listeners[event_name]:
|
||||||
|
callback(*args, **kwargs)
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
+206
-16
File diff suppressed because one or more lines are too long
@@ -0,0 +1,116 @@
|
|||||||
|
;;; !!! This configuration is handled by HelloImGui and stores several Ini Files, separated by markers like this:
|
||||||
|
;;;<<<INI_NAME>>>;;;
|
||||||
|
|
||||||
|
;;;<<<ImGui_655921752_Default>>>;;;
|
||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Projects]
|
||||||
|
Pos=209,396
|
||||||
|
Size=387,337
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000014,0
|
||||||
|
|
||||||
|
[Window][Files]
|
||||||
|
Pos=0,0
|
||||||
|
Size=207,1200
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000011,0
|
||||||
|
|
||||||
|
[Window][Screenshots]
|
||||||
|
Pos=209,0
|
||||||
|
Size=387,171
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000015,0
|
||||||
|
|
||||||
|
[Window][Discussion History]
|
||||||
|
Pos=598,128
|
||||||
|
Size=712,619
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000E,0
|
||||||
|
|
||||||
|
[Window][Provider]
|
||||||
|
Pos=209,913
|
||||||
|
Size=387,287
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000A,0
|
||||||
|
|
||||||
|
[Window][Message]
|
||||||
|
Pos=598,749
|
||||||
|
Size=712,451
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
|
[Window][Response]
|
||||||
|
Pos=209,735
|
||||||
|
Size=387,176
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000010,0
|
||||||
|
|
||||||
|
[Window][Tool Calls]
|
||||||
|
Pos=1312,733
|
||||||
|
Size=368,144
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000008,0
|
||||||
|
|
||||||
|
[Window][Comms History]
|
||||||
|
Pos=1312,879
|
||||||
|
Size=368,321
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][System Prompts]
|
||||||
|
Pos=1312,0
|
||||||
|
Size=368,731
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000007,0
|
||||||
|
|
||||||
|
[Window][Theme]
|
||||||
|
Pos=209,173
|
||||||
|
Size=387,221
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000016,0
|
||||||
|
|
||||||
|
[Window][Text Viewer - Entry #7]
|
||||||
|
Pos=379,324
|
||||||
|
Size=900,700
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Docking][Data]
|
||||||
|
DockSpace ID=0xAFC85805 Window=0x079D3A04 Pos=138,161 Size=1680,1200 Split=X
|
||||||
|
DockNode ID=0x00000011 Parent=0xAFC85805 SizeRef=207,1200 Selected=0x0469CA7A
|
||||||
|
DockNode ID=0x00000012 Parent=0xAFC85805 SizeRef=1559,1200 Split=X
|
||||||
|
DockNode ID=0x00000003 Parent=0x00000012 SizeRef=1189,1200 Split=X
|
||||||
|
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=387,1200 Split=Y Selected=0x8CA2375C
|
||||||
|
DockNode ID=0x00000009 Parent=0x00000001 SizeRef=405,911 Split=Y Selected=0x8CA2375C
|
||||||
|
DockNode ID=0x0000000F Parent=0x00000009 SizeRef=405,733 Split=Y Selected=0x8CA2375C
|
||||||
|
DockNode ID=0x00000013 Parent=0x0000000F SizeRef=405,394 Split=Y Selected=0x8CA2375C
|
||||||
|
DockNode ID=0x00000015 Parent=0x00000013 SizeRef=405,171 Selected=0xDF822E02
|
||||||
|
DockNode ID=0x00000016 Parent=0x00000013 SizeRef=405,221 Selected=0x8CA2375C
|
||||||
|
DockNode ID=0x00000014 Parent=0x0000000F SizeRef=405,337 Selected=0xDA22FEDA
|
||||||
|
DockNode ID=0x00000010 Parent=0x00000009 SizeRef=405,176 Selected=0x0D5A5273
|
||||||
|
DockNode ID=0x0000000A Parent=0x00000001 SizeRef=405,287 Selected=0xA07B5F14
|
||||||
|
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=800,1200 Split=Y
|
||||||
|
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1010,747 Split=Y
|
||||||
|
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=1010,126 CentralNode=1
|
||||||
|
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=1010,619 Selected=0x5D11106F
|
||||||
|
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1010,451 Selected=0x66CFB56E
|
||||||
|
DockNode ID=0x00000004 Parent=0x00000012 SizeRef=368,1200 Split=Y Selected=0xDD6419BC
|
||||||
|
DockNode ID=0x00000005 Parent=0x00000004 SizeRef=261,877 Split=Y Selected=0xDD6419BC
|
||||||
|
DockNode ID=0x00000007 Parent=0x00000005 SizeRef=261,731 Selected=0xDD6419BC
|
||||||
|
DockNode ID=0x00000008 Parent=0x00000005 SizeRef=261,144 Selected=0x1D56B311
|
||||||
|
DockNode ID=0x00000006 Parent=0x00000004 SizeRef=261,321 Selected=0x8B4EBFA6
|
||||||
|
|
||||||
|
;;;<<<Layout_655921752_Default>>>;;;
|
||||||
|
;;;<<<HelloImGui_Misc>>>;;;
|
||||||
|
[Layout]
|
||||||
|
Name=Default
|
||||||
|
[StatusBar]
|
||||||
|
Show=false
|
||||||
|
ShowFps=true
|
||||||
|
[Theme]
|
||||||
|
Name=DarculaDarker
|
||||||
|
;;;<<<SplitIds>>>;;;
|
||||||
|
{"gImGuiSplitIDs":{"MainDockSpace":2949142533}}
|
||||||
+451
@@ -0,0 +1,451 @@
|
|||||||
|
# mcp_client.py
|
||||||
|
"""
|
||||||
|
Note(Gemini):
|
||||||
|
MCP-style file context tools for manual_slop.
|
||||||
|
Exposes read-only filesystem tools the AI can call to selectively fetch file
|
||||||
|
content on demand, instead of having everything inlined into the context block.
|
||||||
|
|
||||||
|
All access is restricted to paths that are either:
|
||||||
|
- Explicitly listed in the project's allowed_paths set, OR
|
||||||
|
- Contained within an allowed base_dir (must resolve to a subpath of it)
|
||||||
|
|
||||||
|
This is heavily inspired by Claude's own tooling limits. We enforce safety here
|
||||||
|
so the AI doesn't wander outside the project workspace.
|
||||||
|
"""
|
||||||
|
# mcp_client.py
|
||||||
|
|
||||||
|
#MCP-style file context tools for manual_slop.
|
||||||
|
|
||||||
|
# Exposes read-only filesystem tools the AI can call to selectively fetch file
|
||||||
|
# content on demand, instead of having everything inlined into the context block.
|
||||||
|
# All access is restricted to paths that are either:
|
||||||
|
# - Explicitly listed in the project's allowed_paths set, OR
|
||||||
|
# - Contained within an allowed base_dir (must resolve to a subpath of it)
|
||||||
|
|
||||||
|
# Tools exposed:
|
||||||
|
# read_file(path) - return full UTF-8 content of a file
|
||||||
|
# list_directory(path) - list entries in a directory (names + type)
|
||||||
|
# search_files(path, pattern) - glob pattern search within an allowed dir
|
||||||
|
# get_file_summary(path) - return the summarize.py heuristic summary
|
||||||
|
#
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
import summarize
|
||||||
|
import urllib.request
|
||||||
|
import urllib.parse
|
||||||
|
from html.parser import HTMLParser
|
||||||
|
import re as _re
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ state
|
||||||
|
|
||||||
|
# Set by configure() before the AI send loop starts.
|
||||||
|
# allowed_paths : set of resolved absolute Path objects (files or dirs)
|
||||||
|
# base_dirs : set of resolved absolute Path dirs that act as roots
|
||||||
|
_allowed_paths: set[Path] = set()
|
||||||
|
_base_dirs: set[Path] = set()
|
||||||
|
_primary_base_dir: Path | None = None
|
||||||
|
|
||||||
|
# Injected by gui.py - returns a dict of performance metrics
|
||||||
|
perf_monitor_callback = None
|
||||||
|
|
||||||
|
|
||||||
|
def configure(file_items: list[dict], extra_base_dirs: list[str] | None = None):
|
||||||
|
"""
|
||||||
|
Build the allowlist from aggregate file_items.
|
||||||
|
Called by ai_client before each send so the list reflects the current project.
|
||||||
|
|
||||||
|
file_items : list of dicts from aggregate.build_file_items()
|
||||||
|
extra_base_dirs : additional directory roots to allow traversal of
|
||||||
|
"""
|
||||||
|
global _allowed_paths, _base_dirs, _primary_base_dir
|
||||||
|
_allowed_paths = set()
|
||||||
|
_base_dirs = set()
|
||||||
|
_primary_base_dir = Path(extra_base_dirs[0]).resolve() if extra_base_dirs else Path.cwd()
|
||||||
|
|
||||||
|
for item in file_items:
|
||||||
|
p = item.get("path")
|
||||||
|
if p is not None:
|
||||||
|
rp = Path(p).resolve()
|
||||||
|
_allowed_paths.add(rp)
|
||||||
|
_base_dirs.add(rp.parent)
|
||||||
|
|
||||||
|
if extra_base_dirs:
|
||||||
|
for d in extra_base_dirs:
|
||||||
|
dp = Path(d).resolve()
|
||||||
|
if dp.is_dir():
|
||||||
|
_base_dirs.add(dp)
|
||||||
|
|
||||||
|
|
||||||
|
def _is_allowed(path: Path) -> bool:
|
||||||
|
"""
|
||||||
|
Return True if `path` is within the allowlist.
|
||||||
|
A path is allowed if:
|
||||||
|
- it is explicitly in _allowed_paths, OR
|
||||||
|
- it is contained within (or equal to) one of the _base_dirs
|
||||||
|
"""
|
||||||
|
rp = path.resolve()
|
||||||
|
if rp in _allowed_paths:
|
||||||
|
return True
|
||||||
|
for bd in _base_dirs:
|
||||||
|
try:
|
||||||
|
rp.relative_to(bd)
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_and_check(raw_path: str) -> tuple[Path | None, str]:
|
||||||
|
"""
|
||||||
|
Resolve raw_path and verify it passes the allowlist check.
|
||||||
|
Returns (resolved_path, error_string). error_string is empty on success.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
p = Path(raw_path)
|
||||||
|
if not p.is_absolute() and _primary_base_dir:
|
||||||
|
p = _primary_base_dir / p
|
||||||
|
p = p.resolve()
|
||||||
|
except Exception as e:
|
||||||
|
return None, f"ERROR: invalid path '{raw_path}': {e}"
|
||||||
|
if not _is_allowed(p):
|
||||||
|
return None, (
|
||||||
|
f"ACCESS DENIED: '{raw_path}' is not within the allowed paths. "
|
||||||
|
f"Use list_directory or search_files on an allowed base directory first."
|
||||||
|
)
|
||||||
|
return p, ""
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ tool implementations
|
||||||
|
|
||||||
|
def read_file(path: str) -> str:
|
||||||
|
"""Return the UTF-8 content of a file, or an error string."""
|
||||||
|
p, err = _resolve_and_check(path)
|
||||||
|
if err:
|
||||||
|
return err
|
||||||
|
if not p.exists():
|
||||||
|
return f"ERROR: file not found: {path}"
|
||||||
|
if not p.is_file():
|
||||||
|
return f"ERROR: not a file: {path}"
|
||||||
|
try:
|
||||||
|
return p.read_text(encoding="utf-8")
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR reading '{path}': {e}"
|
||||||
|
|
||||||
|
|
||||||
|
def list_directory(path: str) -> str:
|
||||||
|
"""List entries in a directory. Returns a compact text table."""
|
||||||
|
p, err = _resolve_and_check(path)
|
||||||
|
if err:
|
||||||
|
return err
|
||||||
|
if not p.exists():
|
||||||
|
return f"ERROR: path not found: {path}"
|
||||||
|
if not p.is_dir():
|
||||||
|
return f"ERROR: not a directory: {path}"
|
||||||
|
try:
|
||||||
|
entries = sorted(p.iterdir(), key=lambda e: (e.is_file(), e.name.lower()))
|
||||||
|
lines = [f"Directory: {p}", ""]
|
||||||
|
for entry in entries:
|
||||||
|
kind = "file" if entry.is_file() else "dir "
|
||||||
|
size = f"{entry.stat().st_size:>10,} bytes" if entry.is_file() else ""
|
||||||
|
lines.append(f" [{kind}] {entry.name:<40} {size}")
|
||||||
|
lines.append(f" ({len(entries)} entries)")
|
||||||
|
return "\n".join(lines)
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR listing '{path}': {e}"
|
||||||
|
|
||||||
|
|
||||||
|
def search_files(path: str, pattern: str) -> str:
|
||||||
|
"""
|
||||||
|
Search for files matching a glob pattern within path.
|
||||||
|
pattern examples: '*.py', '**/*.toml', 'src/**/*.rs'
|
||||||
|
"""
|
||||||
|
p, err = _resolve_and_check(path)
|
||||||
|
if err:
|
||||||
|
return err
|
||||||
|
if not p.is_dir():
|
||||||
|
return f"ERROR: not a directory: {path}"
|
||||||
|
try:
|
||||||
|
matches = sorted(p.glob(pattern))
|
||||||
|
if not matches:
|
||||||
|
return f"No files matched '{pattern}' in {path}"
|
||||||
|
lines = [f"Search '{pattern}' in {p}:", ""]
|
||||||
|
for m in matches:
|
||||||
|
rel = m.relative_to(p)
|
||||||
|
kind = "file" if m.is_file() else "dir "
|
||||||
|
lines.append(f" [{kind}] {rel}")
|
||||||
|
lines.append(f" ({len(matches)} match(es))")
|
||||||
|
return "\n".join(lines)
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR searching '{path}': {e}"
|
||||||
|
|
||||||
|
|
||||||
|
def get_file_summary(path: str) -> str:
|
||||||
|
"""
|
||||||
|
Return the heuristic summary for a file (same as the initial context block).
|
||||||
|
For .py files: imports, classes, methods, functions, constants.
|
||||||
|
For .toml: table keys. For .md: headings. Others: line count + preview.
|
||||||
|
"""
|
||||||
|
p, err = _resolve_and_check(path)
|
||||||
|
if err:
|
||||||
|
return err
|
||||||
|
if not p.exists():
|
||||||
|
return f"ERROR: file not found: {path}"
|
||||||
|
if not p.is_file():
|
||||||
|
return f"ERROR: not a file: {path}"
|
||||||
|
try:
|
||||||
|
content = p.read_text(encoding="utf-8")
|
||||||
|
return summarize.summarise_file(p, content)
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR summarising '{path}': {e}"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ web tools
|
||||||
|
|
||||||
|
class _DDGParser(HTMLParser):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.results = []
|
||||||
|
self.in_result = False
|
||||||
|
self.in_title = False
|
||||||
|
self.in_snippet = False
|
||||||
|
self.current_link = ""
|
||||||
|
self.current_title = ""
|
||||||
|
self.current_snippet = ""
|
||||||
|
|
||||||
|
def handle_starttag(self, tag, attrs):
|
||||||
|
attrs = dict(attrs)
|
||||||
|
if tag == "a" and "result__url" in attrs.get("class", ""):
|
||||||
|
self.current_link = attrs.get("href", "")
|
||||||
|
if tag == "a" and "result__snippet" in attrs.get("class", ""):
|
||||||
|
self.in_snippet = True
|
||||||
|
if tag == "h2" and "result__title" in attrs.get("class", ""):
|
||||||
|
self.in_title = True
|
||||||
|
|
||||||
|
def handle_endtag(self, tag):
|
||||||
|
if tag == "a" and self.in_snippet:
|
||||||
|
self.in_snippet = False
|
||||||
|
if tag == "h2" and self.in_title:
|
||||||
|
self.in_title = False
|
||||||
|
if self.current_link:
|
||||||
|
self.results.append({
|
||||||
|
"title": self.current_title.strip(),
|
||||||
|
"link": self.current_link,
|
||||||
|
"snippet": self.current_snippet.strip()
|
||||||
|
})
|
||||||
|
self.current_title = ""
|
||||||
|
self.current_snippet = ""
|
||||||
|
self.current_link = ""
|
||||||
|
|
||||||
|
def handle_data(self, data):
|
||||||
|
if self.in_title:
|
||||||
|
self.current_title += data
|
||||||
|
if self.in_snippet:
|
||||||
|
self.current_snippet += data
|
||||||
|
|
||||||
|
class _TextExtractor(HTMLParser):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.text = []
|
||||||
|
self.hide = 0
|
||||||
|
self.ignore_tags = {'script', 'style', 'head', 'meta', 'nav', 'header', 'footer', 'noscript', 'svg'}
|
||||||
|
|
||||||
|
def handle_starttag(self, tag, attrs):
|
||||||
|
if tag in self.ignore_tags:
|
||||||
|
self.hide += 1
|
||||||
|
|
||||||
|
def handle_endtag(self, tag):
|
||||||
|
if tag in self.ignore_tags:
|
||||||
|
self.hide -= 1
|
||||||
|
|
||||||
|
def handle_data(self, data):
|
||||||
|
if self.hide == 0:
|
||||||
|
cleaned = data.strip()
|
||||||
|
if cleaned:
|
||||||
|
self.text.append(cleaned)
|
||||||
|
|
||||||
|
def web_search(query: str) -> str:
|
||||||
|
"""Search the web using DuckDuckGo HTML and return top results."""
|
||||||
|
url = "https://html.duckduckgo.com/html/?q=" + urllib.parse.quote(query)
|
||||||
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'})
|
||||||
|
try:
|
||||||
|
html = urllib.request.urlopen(req, timeout=10).read().decode('utf-8', errors='ignore')
|
||||||
|
parser = _DDGParser()
|
||||||
|
parser.feed(html)
|
||||||
|
if not parser.results:
|
||||||
|
return f"No results found for '{query}'"
|
||||||
|
lines = [f"Search Results for '{query}':"]
|
||||||
|
for i, r in enumerate(parser.results[:5], 1):
|
||||||
|
lines.append(f"{i}. {r['title']}\nURL: {r['link']}\nSnippet: {r['snippet']}\n")
|
||||||
|
return "\n".join(lines)
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR searching web for '{query}': {e}"
|
||||||
|
|
||||||
|
def fetch_url(url: str) -> str:
|
||||||
|
"""Fetch a URL and return its text content (stripped of HTML tags)."""
|
||||||
|
# Correct duckduckgo redirect links if passed
|
||||||
|
if url.startswith("//duckduckgo.com/l/?uddg="):
|
||||||
|
url = urllib.parse.unquote(url.split("uddg=")[1].split("&")[0])
|
||||||
|
|
||||||
|
if not url.startswith("http"):
|
||||||
|
url = "https://" + url
|
||||||
|
|
||||||
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'})
|
||||||
|
try:
|
||||||
|
html = urllib.request.urlopen(req, timeout=10).read().decode('utf-8', errors='ignore')
|
||||||
|
parser = _TextExtractor()
|
||||||
|
parser.feed(html)
|
||||||
|
full_text = " ".join(parser.text)
|
||||||
|
full_text = _re.sub(r'\s+', ' ', full_text)
|
||||||
|
# Limit to 40k chars to prevent context blowup
|
||||||
|
if len(full_text) > 40000:
|
||||||
|
return full_text[:40000] + "\n... (content truncated)"
|
||||||
|
return full_text
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR fetching URL '{url}': {e}"
|
||||||
|
|
||||||
|
|
||||||
|
def get_ui_performance() -> str:
|
||||||
|
"""Returns current UI performance metrics (FPS, Frame Time, CPU, Input Lag)."""
|
||||||
|
if perf_monitor_callback is None:
|
||||||
|
return "ERROR: Performance monitor callback not registered."
|
||||||
|
try:
|
||||||
|
metrics = perf_monitor_callback()
|
||||||
|
# Clean up the dict string for the AI
|
||||||
|
metric_str = str(metrics)
|
||||||
|
for char in "{}'":
|
||||||
|
metric_str = metric_str.replace(char, "")
|
||||||
|
return f"UI Performance Snapshot:\n{metric_str}"
|
||||||
|
except Exception as e:
|
||||||
|
return f"ERROR: Failed to retrieve UI performance: {str(e)}"
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ tool dispatch
|
||||||
|
|
||||||
|
|
||||||
|
TOOL_NAMES = {"read_file", "list_directory", "search_files", "get_file_summary", "web_search", "fetch_url", "get_ui_performance"}
|
||||||
|
|
||||||
|
|
||||||
|
def dispatch(tool_name: str, tool_input: dict) -> str:
|
||||||
|
"""
|
||||||
|
Dispatch an MCP tool call by name. Returns the result as a string.
|
||||||
|
"""
|
||||||
|
if tool_name == "read_file":
|
||||||
|
return read_file(tool_input.get("path", ""))
|
||||||
|
if tool_name == "list_directory":
|
||||||
|
return list_directory(tool_input.get("path", ""))
|
||||||
|
if tool_name == "search_files":
|
||||||
|
return search_files(tool_input.get("path", ""), tool_input.get("pattern", "*"))
|
||||||
|
if tool_name == "get_file_summary":
|
||||||
|
return get_file_summary(tool_input.get("path", ""))
|
||||||
|
if tool_name == "web_search":
|
||||||
|
return web_search(tool_input.get("query", ""))
|
||||||
|
if tool_name == "fetch_url":
|
||||||
|
return fetch_url(tool_input.get("url", ""))
|
||||||
|
if tool_name == "get_ui_performance":
|
||||||
|
return get_ui_performance()
|
||||||
|
return f"ERROR: unknown MCP tool '{tool_name}'"
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ tool schema helpers
|
||||||
|
# These are imported by ai_client.py to build provider-specific declarations.
|
||||||
|
|
||||||
|
MCP_TOOL_SPECS = [
|
||||||
|
{
|
||||||
|
"name": "read_file",
|
||||||
|
"description": (
|
||||||
|
"Read the full UTF-8 content of a file within the allowed project paths. "
|
||||||
|
"Use get_file_summary first to decide whether you need the full content."
|
||||||
|
),
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Absolute or relative path to the file to read.",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["path"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "list_directory",
|
||||||
|
"description": (
|
||||||
|
"List files and subdirectories within an allowed directory. "
|
||||||
|
"Shows name, type (file/dir), and size. Use this to explore the project structure."
|
||||||
|
),
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Absolute path to the directory to list.",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["path"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "search_files",
|
||||||
|
"description": (
|
||||||
|
"Search for files matching a glob pattern within an allowed directory. "
|
||||||
|
"Supports recursive patterns like '**/*.py'. "
|
||||||
|
"Use this to find files by extension or name pattern."
|
||||||
|
),
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Absolute path to the directory to search within.",
|
||||||
|
},
|
||||||
|
"pattern": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Glob pattern, e.g. '*.py', '**/*.toml', 'src/**/*.rs'.",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["path", "pattern"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_file_summary",
|
||||||
|
"description": (
|
||||||
|
"Get a compact heuristic summary of a file without reading its full content. "
|
||||||
|
"For Python: imports, classes, methods, functions, constants. "
|
||||||
|
"For TOML: table keys. For Markdown: headings. Others: line count + preview. "
|
||||||
|
"Use this before read_file to decide if you need the full content."
|
||||||
|
),
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"path": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Absolute or relative path to the file to summarise.",
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["path"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "web_search",
|
||||||
|
"description": "Search the web using DuckDuckGo. Returns the top 5 search results with titles, URLs, and snippets. Chain this with fetch_url to read specific pages.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"query": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "The search query."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["query"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "get_ui_performance",
|
||||||
|
"description": "Get a snapshot of the current UI performance metrics, including FPS, Frame Time (ms), CPU usage (%), and Input Lag (ms). Use this to diagnose UI slowness or verify that your changes haven't degraded the user experience.",
|
||||||
|
"parameters": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
# patch_gui.py — apply multi-project support to gui.py
|
|
||||||
import re
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
src = Path("C:/projects/manual_slop/gui.py").read_text(encoding="utf-8")
|
|
||||||
|
|
||||||
# ── 1. Add project_manager import after "import theme" ──────────────────────
|
|
||||||
src = src.replace(
|
|
||||||
"import theme\n",
|
|
||||||
"import theme\nimport project_manager\n",
|
|
||||||
1
|
|
||||||
)
|
|
||||||
|
|
||||||
# ── 2. Add PROJECT_TOML_PATH constant after CONFIG_PATH line ─────────────────
|
|
||||||
src = src.replace(
|
|
||||||
'CONFIG_PATH = Path("config.toml")\n',
|
|
||||||
'CONFIG_PATH = Path("config.toml")\nPROVIDERS = ["gemini", "anthropic"]\n',
|
|
||||||
1
|
|
||||||
)
|
|
||||||
# Remove the duplicate PROVIDERS = [...] that already exists two lines down
|
|
||||||
src = src.replace(
|
|
||||||
'PROVIDERS = ["gemini", "anthropic"]\nPROVIDERS = ["gemini", "anthropic"]\n',
|
|
||||||
'PROVIDERS = ["gemini", "anthropic"]\n',
|
|
||||||
1
|
|
||||||
)
|
|
||||||
|
|
||||||
print("Pass 1 done - imports & constants")
|
|
||||||
print(repr(src[:300]))
|
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
import time
|
||||||
|
import psutil
|
||||||
|
import threading
|
||||||
|
|
||||||
|
class PerformanceMonitor:
|
||||||
|
def __init__(self):
|
||||||
|
self._start_time = None
|
||||||
|
self._last_frame_time = 0.0
|
||||||
|
self._fps = 0.0
|
||||||
|
self._frame_count = 0
|
||||||
|
self._fps_last_time = time.time()
|
||||||
|
self._process = psutil.Process()
|
||||||
|
self._cpu_usage = 0.0
|
||||||
|
self._cpu_lock = threading.Lock()
|
||||||
|
|
||||||
|
# Input lag tracking
|
||||||
|
self._last_input_time = None
|
||||||
|
self._input_lag_ms = 0.0
|
||||||
|
|
||||||
|
# Alerts
|
||||||
|
self.alert_callback = None
|
||||||
|
self.thresholds = {
|
||||||
|
'frame_time_ms': 33.3, # < 30 FPS
|
||||||
|
'cpu_percent': 80.0,
|
||||||
|
'input_lag_ms': 100.0
|
||||||
|
}
|
||||||
|
self._last_alert_time = 0
|
||||||
|
self._alert_cooldown = 30 # seconds
|
||||||
|
|
||||||
|
# Detailed profiling
|
||||||
|
self._component_timings = {}
|
||||||
|
self._comp_start = {}
|
||||||
|
|
||||||
|
# Start CPU usage monitoring thread
|
||||||
|
self._stop_event = threading.Event()
|
||||||
|
self._cpu_thread = threading.Thread(target=self._monitor_cpu, daemon=True)
|
||||||
|
self._cpu_thread.start()
|
||||||
|
|
||||||
|
def _monitor_cpu(self):
|
||||||
|
while not self._stop_event.is_set():
|
||||||
|
# psutil.cpu_percent is better than process.cpu_percent for real-time
|
||||||
|
usage = self._process.cpu_percent(interval=1.0)
|
||||||
|
with self._cpu_lock:
|
||||||
|
self._cpu_usage = usage
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
def start_frame(self):
|
||||||
|
self._start_time = time.time()
|
||||||
|
|
||||||
|
def record_input_event(self):
|
||||||
|
self._last_input_time = time.time()
|
||||||
|
|
||||||
|
def start_component(self, name: str):
|
||||||
|
self._comp_start[name] = time.time()
|
||||||
|
|
||||||
|
def end_component(self, name: str):
|
||||||
|
if name in self._comp_start:
|
||||||
|
elapsed = (time.time() - self._comp_start[name]) * 1000.0
|
||||||
|
self._component_timings[name] = elapsed
|
||||||
|
|
||||||
|
def end_frame(self):
|
||||||
|
if self._start_time is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
end_time = time.time()
|
||||||
|
self._last_frame_time = (end_time - self._start_time) * 1000.0
|
||||||
|
self._frame_count += 1
|
||||||
|
|
||||||
|
# Calculate input lag if an input occurred during this frame
|
||||||
|
if self._last_input_time is not None:
|
||||||
|
self._input_lag_ms = (end_time - self._last_input_time) * 1000.0
|
||||||
|
self._last_input_time = None
|
||||||
|
|
||||||
|
self._check_alerts()
|
||||||
|
|
||||||
|
elapsed_since_fps = end_time - self._fps_last_time
|
||||||
|
if elapsed_since_fps >= 1.0:
|
||||||
|
self._fps = self._frame_count / elapsed_since_fps
|
||||||
|
self._frame_count = 0
|
||||||
|
self._fps_last_time = end_time
|
||||||
|
|
||||||
|
def _check_alerts(self):
|
||||||
|
if not self.alert_callback:
|
||||||
|
return
|
||||||
|
|
||||||
|
now = time.time()
|
||||||
|
if now - self._last_alert_time < self._alert_cooldown:
|
||||||
|
return
|
||||||
|
|
||||||
|
metrics = self.get_metrics()
|
||||||
|
alerts = []
|
||||||
|
if metrics['last_frame_time_ms'] > self.thresholds['frame_time_ms']:
|
||||||
|
alerts.append(f"Frame time high: {metrics['last_frame_time_ms']:.1f}ms")
|
||||||
|
if metrics['cpu_percent'] > self.thresholds['cpu_percent']:
|
||||||
|
alerts.append(f"CPU usage high: {metrics['cpu_percent']:.1f}%")
|
||||||
|
if metrics['input_lag_ms'] > self.thresholds['input_lag_ms']:
|
||||||
|
alerts.append(f"Input lag high: {metrics['input_lag_ms']:.1f}ms")
|
||||||
|
|
||||||
|
if alerts:
|
||||||
|
self._last_alert_time = now
|
||||||
|
self.alert_callback("; ".join(alerts))
|
||||||
|
|
||||||
|
def get_metrics(self):
|
||||||
|
with self._cpu_lock:
|
||||||
|
cpu_usage = self._cpu_usage
|
||||||
|
|
||||||
|
metrics = {
|
||||||
|
'last_frame_time_ms': self._last_frame_time,
|
||||||
|
'fps': self._fps,
|
||||||
|
'cpu_percent': cpu_usage,
|
||||||
|
'input_lag_ms': self._last_input_time if self._last_input_time else 0.0 # Wait, this should be the calculated lag
|
||||||
|
}
|
||||||
|
# Oops, fixed the input lag logic in previous turn, let's keep it consistent
|
||||||
|
metrics['input_lag_ms'] = self._input_lag_ms
|
||||||
|
|
||||||
|
# Add detailed timings
|
||||||
|
for name, elapsed in self._component_timings.items():
|
||||||
|
metrics[f'time_{name}_ms'] = elapsed
|
||||||
|
|
||||||
|
return metrics
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self._stop_event.set()
|
||||||
|
self._cpu_thread.join(timeout=2.0)
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
[project]
|
||||||
|
name = "project"
|
||||||
|
git_dir = ""
|
||||||
|
system_prompt = ""
|
||||||
|
main_context = ""
|
||||||
|
|
||||||
|
[output]
|
||||||
|
output_dir = "./md_gen"
|
||||||
|
|
||||||
|
[files]
|
||||||
|
base_dir = "."
|
||||||
|
paths = []
|
||||||
|
|
||||||
|
[screenshots]
|
||||||
|
base_dir = "."
|
||||||
|
paths = []
|
||||||
|
|
||||||
|
[agent.tools]
|
||||||
|
run_powershell = true
|
||||||
|
read_file = true
|
||||||
|
list_directory = true
|
||||||
|
search_files = true
|
||||||
|
get_file_summary = true
|
||||||
|
web_search = true
|
||||||
|
fetch_url = true
|
||||||
|
|
||||||
|
[discussion]
|
||||||
|
roles = [
|
||||||
|
"User",
|
||||||
|
"AI",
|
||||||
|
"Vendor API",
|
||||||
|
"System",
|
||||||
|
]
|
||||||
|
active = "main"
|
||||||
|
|
||||||
|
[discussion.discussions.main]
|
||||||
|
git_commit = ""
|
||||||
|
last_updated = "2026-02-23T19:01:39"
|
||||||
|
history = []
|
||||||
+20
-2
@@ -1,4 +1,10 @@
|
|||||||
# project_manager.py
|
# project_manager.py
|
||||||
|
"""
|
||||||
|
Note(Gemini):
|
||||||
|
Handles loading/saving of project .toml configurations.
|
||||||
|
Also handles serializing the discussion history into the TOML format using a special
|
||||||
|
@timestamp prefix to preserve the exact sequence of events.
|
||||||
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
import datetime
|
import datetime
|
||||||
import tomllib
|
import tomllib
|
||||||
@@ -90,10 +96,21 @@ def default_discussion() -> dict:
|
|||||||
|
|
||||||
def default_project(name: str = "unnamed") -> dict:
|
def default_project(name: str = "unnamed") -> dict:
|
||||||
return {
|
return {
|
||||||
"project": {"name": name, "git_dir": ""},
|
"project": {"name": name, "git_dir": "", "system_prompt": "", "main_context": ""},
|
||||||
"output": {"namespace": name, "output_dir": "./md_gen"},
|
"output": {"output_dir": "./md_gen"},
|
||||||
"files": {"base_dir": ".", "paths": []},
|
"files": {"base_dir": ".", "paths": []},
|
||||||
"screenshots": {"base_dir": ".", "paths": []},
|
"screenshots": {"base_dir": ".", "paths": []},
|
||||||
|
"agent": {
|
||||||
|
"tools": {
|
||||||
|
"run_powershell": True,
|
||||||
|
"read_file": True,
|
||||||
|
"list_directory": True,
|
||||||
|
"search_files": True,
|
||||||
|
"get_file_summary": True,
|
||||||
|
"web_search": True,
|
||||||
|
"fetch_url": True
|
||||||
|
}
|
||||||
|
},
|
||||||
"discussion": {
|
"discussion": {
|
||||||
"roles": ["User", "AI", "Vendor API", "System"],
|
"roles": ["User", "AI", "Vendor API", "System"],
|
||||||
"active": "main",
|
"active": "main",
|
||||||
@@ -139,6 +156,7 @@ def flat_config(proj: dict, disc_name: str | None = None) -> dict:
|
|||||||
name = disc_name or disc_sec.get("active", "main")
|
name = disc_name or disc_sec.get("active", "main")
|
||||||
disc_data = disc_sec.get("discussions", {}).get(name, {})
|
disc_data = disc_sec.get("discussions", {}).get(name, {})
|
||||||
return {
|
return {
|
||||||
|
"project": proj.get("project", {}),
|
||||||
"output": proj.get("output", {}),
|
"output": proj.get("output", {}),
|
||||||
"files": proj.get("files", {}),
|
"files": proj.get("files", {}),
|
||||||
"screenshots": proj.get("screenshots", {}),
|
"screenshots": proj.get("screenshots", {}),
|
||||||
|
|||||||
+8
-1
@@ -5,7 +5,14 @@ version = "0.1.0"
|
|||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dearpygui",
|
"dearpygui",
|
||||||
|
"imgui-bundle",
|
||||||
"google-genai",
|
"google-genai",
|
||||||
"anthropic",
|
"anthropic",
|
||||||
"tomli-w"
|
"tomli-w",
|
||||||
|
"psutil>=7.2.2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = [
|
||||||
|
"pytest>=9.0.2",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import time
|
||||||
|
from ai_client import get_gemini_cache_stats
|
||||||
|
|
||||||
|
def reproduce_delay():
|
||||||
|
print("Starting reproduction of Gemini cache list delay...")
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
try:
|
||||||
|
stats = get_gemini_cache_stats()
|
||||||
|
elapsed = (time.time() - start_time) * 1000.0
|
||||||
|
print(f"get_gemini_cache_stats() took {elapsed:.2f}ms")
|
||||||
|
print(f"Stats: {stats}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error calling get_gemini_cache_stats: {e}")
|
||||||
|
print("Note: This might fail if no valid credentials.toml exists or API key is invalid.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
reproduce_delay()
|
||||||
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(pytest.main(sys.argv[1:]))
|
||||||
+33
-5
@@ -1,4 +1,15 @@
|
|||||||
# session_logger.py
|
# session_logger.py
|
||||||
|
"""
|
||||||
|
Note(Gemini):
|
||||||
|
Opens timestamped log/script files at startup and keeps them open for the
|
||||||
|
lifetime of the process.
|
||||||
|
|
||||||
|
File layout:
|
||||||
|
logs/comms_<ts>.log - every comms entry (direction/kind/payload) as JSON-L
|
||||||
|
logs/toolcalls_<ts>.log - sequential record of every tool invocation
|
||||||
|
scripts/generated/<ts>_<seq:04d>.ps1 - each PowerShell script the AI generated
|
||||||
|
"""
|
||||||
|
# session_logger.py
|
||||||
"""
|
"""
|
||||||
Opens timestamped log/script files at startup and keeps them open for the
|
Opens timestamped log/script files at startup and keeps them open for the
|
||||||
lifetime of the process. The next run of the GUI creates new files; the
|
lifetime of the process. The next run of the GUI creates new files; the
|
||||||
@@ -29,6 +40,7 @@ _seq_lock = threading.Lock()
|
|||||||
|
|
||||||
_comms_fh = None # file handle: logs/comms_<ts>.log
|
_comms_fh = None # file handle: logs/comms_<ts>.log
|
||||||
_tool_fh = None # file handle: logs/toolcalls_<ts>.log
|
_tool_fh = None # file handle: logs/toolcalls_<ts>.log
|
||||||
|
_api_fh = None # file handle: logs/apihooks_<ts>.log - API hook calls
|
||||||
|
|
||||||
|
|
||||||
def _now_ts() -> str:
|
def _now_ts() -> str:
|
||||||
@@ -41,7 +53,7 @@ def open_session():
|
|||||||
opens the two log files for this session. Idempotent - a second call is
|
opens the two log files for this session. Idempotent - a second call is
|
||||||
ignored.
|
ignored.
|
||||||
"""
|
"""
|
||||||
global _ts, _comms_fh, _tool_fh, _seq
|
global _ts, _comms_fh, _tool_fh, _api_fh, _seq
|
||||||
|
|
||||||
if _comms_fh is not None:
|
if _comms_fh is not None:
|
||||||
return # already open
|
return # already open
|
||||||
@@ -54,6 +66,7 @@ def open_session():
|
|||||||
|
|
||||||
_comms_fh = open(_LOG_DIR / f"comms_{_ts}.log", "w", encoding="utf-8", buffering=1)
|
_comms_fh = open(_LOG_DIR / f"comms_{_ts}.log", "w", encoding="utf-8", buffering=1)
|
||||||
_tool_fh = open(_LOG_DIR / f"toolcalls_{_ts}.log", "w", encoding="utf-8", buffering=1)
|
_tool_fh = open(_LOG_DIR / f"toolcalls_{_ts}.log", "w", encoding="utf-8", buffering=1)
|
||||||
|
_api_fh = open(_LOG_DIR / f"apihooks_{_ts}.log", "w", encoding="utf-8", buffering=1)
|
||||||
|
|
||||||
_tool_fh.write(f"# Tool-call log — session {_ts}\n\n")
|
_tool_fh.write(f"# Tool-call log — session {_ts}\n\n")
|
||||||
_tool_fh.flush()
|
_tool_fh.flush()
|
||||||
@@ -61,13 +74,30 @@ def open_session():
|
|||||||
|
|
||||||
def close_session():
|
def close_session():
|
||||||
"""Flush and close both log files. Called on clean exit (optional)."""
|
"""Flush and close both log files. Called on clean exit (optional)."""
|
||||||
global _comms_fh, _tool_fh
|
global _comms_fh, _tool_fh, _api_fh
|
||||||
if _comms_fh:
|
if _comms_fh:
|
||||||
_comms_fh.close()
|
_comms_fh.close()
|
||||||
_comms_fh = None
|
_comms_fh = None
|
||||||
if _tool_fh:
|
if _tool_fh:
|
||||||
_tool_fh.close()
|
_tool_fh.close()
|
||||||
_tool_fh = None
|
_tool_fh = None
|
||||||
|
if _api_fh:
|
||||||
|
_api_fh.close()
|
||||||
|
_api_fh = None
|
||||||
|
|
||||||
|
|
||||||
|
def log_api_hook(method: str, path: str, payload: str):
|
||||||
|
"""
|
||||||
|
Log an API hook invocation.
|
||||||
|
"""
|
||||||
|
if _api_fh is None:
|
||||||
|
return
|
||||||
|
ts_entry = datetime.datetime.now().strftime("%H:%M:%S")
|
||||||
|
try:
|
||||||
|
_api_fh.write(f"[{ts_entry}] {method} {path} - Payload: {payload}\n")
|
||||||
|
_api_fh.flush()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def log_comms(entry: dict):
|
def log_comms(entry: dict):
|
||||||
@@ -122,5 +152,3 @@ def log_tool_call(script: str, result: str, script_path: str | None):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
return str(ps1_path) if ps1_path else None
|
return str(ps1_path) if ps1_path else None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Get-Content .env | ForEach-Object { $name, $value = $_.Split('=', 2); [Environment]::SetEnvironmentVariable($name, $value, "Process") }
|
||||||
+17
-23
@@ -1,5 +1,5 @@
|
|||||||
import subprocess
|
# shell_runner.py
|
||||||
import shlex
|
import subprocess, shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
TIMEOUT_SECONDS = 60
|
TIMEOUT_SECONDS = 60
|
||||||
@@ -10,27 +10,21 @@ def run_powershell(script: str, base_dir: str) -> str:
|
|||||||
Returns a string combining stdout, stderr, and exit code.
|
Returns a string combining stdout, stderr, and exit code.
|
||||||
Raises nothing - all errors are captured into the return string.
|
Raises nothing - all errors are captured into the return string.
|
||||||
"""
|
"""
|
||||||
# Prepend Set-Location so the AI doesn't need to worry about cwd
|
safe_dir = str(base_dir).replace("'", "''")
|
||||||
full_script = f"Set-Location -LiteralPath '{base_dir}'\n{script}"
|
full_script = f"Set-Location -LiteralPath '{safe_dir}'\n{script}"
|
||||||
|
# Try common executable names
|
||||||
|
exe = next((x for x in ["powershell.exe", "pwsh.exe", "powershell", "pwsh"] if shutil.which(x)), None)
|
||||||
|
if not exe: return "ERROR: Neither powershell nor pwsh found in PATH"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
r = subprocess.run(
|
||||||
["powershell", "-NoProfile", "-NonInteractive", "-Command", full_script],
|
[exe, "-NoProfile", "-NonInteractive", "-Command", full_script],
|
||||||
capture_output=True,
|
capture_output=True, text=True, timeout=TIMEOUT_SECONDS, cwd=base_dir
|
||||||
text=True,
|
|
||||||
timeout=TIMEOUT_SECONDS,
|
|
||||||
cwd=base_dir
|
|
||||||
)
|
)
|
||||||
parts = []
|
parts = []
|
||||||
if result.stdout.strip():
|
if r.stdout.strip(): parts.append(f"STDOUT:\n{r.stdout.strip()}")
|
||||||
parts.append(f"STDOUT:\n{result.stdout.strip()}")
|
if r.stderr.strip(): parts.append(f"STDERR:\n{r.stderr.strip()}")
|
||||||
if result.stderr.strip():
|
parts.append(f"EXIT CODE: {r.returncode}")
|
||||||
parts.append(f"STDERR:\n{result.stderr.strip()}")
|
return "\n".join(parts)
|
||||||
parts.append(f"EXIT CODE: {result.returncode}")
|
except subprocess.TimeoutExpired: return f"ERROR: timed out after {TIMEOUT_SECONDS}s"
|
||||||
return "\n".join(parts) if parts else f"EXIT CODE: {result.returncode}"
|
except Exception as e: return f"ERROR: {e}"
|
||||||
except subprocess.TimeoutExpired:
|
|
||||||
return f"ERROR: command timed out after {TIMEOUT_SECONDS}s"
|
|
||||||
except FileNotFoundError:
|
|
||||||
return "ERROR: powershell executable not found"
|
|
||||||
except Exception as e:
|
|
||||||
return f"ERROR: {e}"
|
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
import random
|
||||||
|
from api_hook_client import ApiHookClient
|
||||||
|
from simulation.workflow_sim import WorkflowSimulator
|
||||||
|
|
||||||
|
def main():
|
||||||
|
client = ApiHookClient()
|
||||||
|
print("=== Manual Slop: Live UX Walkthrough ===")
|
||||||
|
print("Connecting to GUI...")
|
||||||
|
if not client.wait_for_server(timeout=10):
|
||||||
|
print("Error: Could not connect to GUI. Ensure it is running with --enable-test-hooks")
|
||||||
|
return
|
||||||
|
|
||||||
|
sim = WorkflowSimulator(client)
|
||||||
|
|
||||||
|
# 1. Start Clean
|
||||||
|
print("\n[Action] Resetting Session...")
|
||||||
|
client.click("btn_reset")
|
||||||
|
time.sleep(2)
|
||||||
|
|
||||||
|
# 2. Project Scaffolding
|
||||||
|
project_name = f"LiveTest_{int(time.time())}"
|
||||||
|
# Use actual project dir for realism
|
||||||
|
git_dir = os.path.abspath(".")
|
||||||
|
|
||||||
|
print(f"\n[Action] Scaffolding Project: {project_name}")
|
||||||
|
sim.setup_new_project(project_name, git_dir)
|
||||||
|
|
||||||
|
# Enable auto-add so results appear in history automatically
|
||||||
|
client.set_value("auto_add_history", True)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# 3. Discussion Loop (3 turns for speed, but logic supports more)
|
||||||
|
turns = [
|
||||||
|
"Hi! I want to create a simple python script called 'hello.py' that prints the current date and time. Can you write it for me?",
|
||||||
|
"That looks great. Can you also add a feature to print the name of the operating system?",
|
||||||
|
"Excellent. Now, please create a requirements.txt file with 'requests' in it."
|
||||||
|
]
|
||||||
|
|
||||||
|
for i, msg in enumerate(turns):
|
||||||
|
print(f"\n--- Turn {i+1} ---")
|
||||||
|
|
||||||
|
# Switch to Comms Log to see the send
|
||||||
|
client.select_tab("operations_tabs", "tab_comms")
|
||||||
|
|
||||||
|
sim.run_discussion_turn(msg)
|
||||||
|
|
||||||
|
# Check thinking indicator
|
||||||
|
state = client.get_indicator_state("thinking_indicator")
|
||||||
|
if state.get('shown'):
|
||||||
|
print("[Status] Thinking indicator is visible.")
|
||||||
|
|
||||||
|
# Switch to Tool Log halfway through wait
|
||||||
|
time.sleep(2)
|
||||||
|
client.select_tab("operations_tabs", "tab_tool")
|
||||||
|
|
||||||
|
# Wait for AI response if not already finished
|
||||||
|
# (run_discussion_turn already waits, so we just observe)
|
||||||
|
|
||||||
|
# 4. History Management
|
||||||
|
print("\n[Action] Creating new discussion thread...")
|
||||||
|
sim.create_discussion("Refinement")
|
||||||
|
|
||||||
|
print("\n[Action] Switching back to Default...")
|
||||||
|
sim.switch_discussion("Default")
|
||||||
|
|
||||||
|
# 5. Manual Sign-off Simulation
|
||||||
|
print("\n=== Walkthrough Complete ===")
|
||||||
|
print("Please verify the following in the GUI:")
|
||||||
|
print("1. The project metadata reflects the new project.")
|
||||||
|
print("2. The discussion history contains the 3 turns.")
|
||||||
|
print("3. The 'Refinement' discussion exists in the list.")
|
||||||
|
print("\nWalkthrough finished successfully.")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
|
# Ensure project root is in path
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
|
|
||||||
|
from api_hook_client import ApiHookClient
|
||||||
|
from simulation.user_agent import UserSimAgent
|
||||||
|
|
||||||
|
def main():
|
||||||
|
client = ApiHookClient()
|
||||||
|
print("Waiting for hook server...")
|
||||||
|
if not client.wait_for_server(timeout=5):
|
||||||
|
print("Hook server not found. Start GUI with --enable-test-hooks")
|
||||||
|
return
|
||||||
|
|
||||||
|
sim_agent = UserSimAgent(client)
|
||||||
|
|
||||||
|
# 1. Reset session to start clean
|
||||||
|
print("Resetting session...")
|
||||||
|
client.click("btn_reset")
|
||||||
|
time.sleep(2) # Give it time to clear
|
||||||
|
|
||||||
|
# 2. Initial message
|
||||||
|
initial_msg = "Hello! I want to create a simple python script that prints 'Hello World'. Can you help me?"
|
||||||
|
print(f"
|
||||||
|
[USER]: {initial_msg}")
|
||||||
|
client.set_value("ai_input", initial_msg)
|
||||||
|
client.click("btn_gen_send")
|
||||||
|
|
||||||
|
# 3. Wait for AI response
|
||||||
|
print("Waiting for AI response...", end="", flush=True)
|
||||||
|
last_entry_count = 0
|
||||||
|
for _ in range(60): # 60 seconds max
|
||||||
|
time.sleep(1)
|
||||||
|
print(".", end="", flush=True)
|
||||||
|
session = client.get_session()
|
||||||
|
entries = session.get('session', {}).get('entries', [])
|
||||||
|
|
||||||
|
if len(entries) > last_entry_count:
|
||||||
|
# Something happened
|
||||||
|
last_entry = entries[-1]
|
||||||
|
if last_entry.get('role') == 'AI' and last_entry.get('content'):
|
||||||
|
print(f"
|
||||||
|
|
||||||
|
[AI]: {last_entry.get('content')[:100]}...")
|
||||||
|
print("
|
||||||
|
Ping-pong successful!")
|
||||||
|
return
|
||||||
|
last_entry_count = len(entries)
|
||||||
|
|
||||||
|
print("
|
||||||
|
Timeout waiting for AI response")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
import time
|
||||||
|
import random
|
||||||
|
import ai_client
|
||||||
|
|
||||||
|
class UserSimAgent:
|
||||||
|
def __init__(self, hook_client, model="gemini-2.0-flash"):
|
||||||
|
self.hook_client = hook_client
|
||||||
|
self.model = model
|
||||||
|
self.system_prompt = (
|
||||||
|
"You are a software engineer testing an AI coding assistant called 'Manual Slop'. "
|
||||||
|
"You want to build a small Python project and verify the assistant's capabilities. "
|
||||||
|
"Keep your responses concise and human-like. "
|
||||||
|
"Do not use markdown blocks for your main message unless you are providing code."
|
||||||
|
)
|
||||||
|
|
||||||
|
def generate_response(self, conversation_history):
|
||||||
|
"""
|
||||||
|
Generates a human-like response based on the conversation history.
|
||||||
|
conversation_history: list of dicts with 'role' and 'content'
|
||||||
|
"""
|
||||||
|
# Format history for ai_client
|
||||||
|
# ai_client expects md_content and user_message.
|
||||||
|
# It handles its own internal history.
|
||||||
|
# We want the 'User AI' to have context of what the 'Assistant AI' said.
|
||||||
|
|
||||||
|
# For now, let's just use the last message from Assistant as the prompt.
|
||||||
|
last_ai_msg = ""
|
||||||
|
for entry in reversed(conversation_history):
|
||||||
|
if entry.get('role') == 'AI':
|
||||||
|
last_ai_msg = entry.get('content', '')
|
||||||
|
break
|
||||||
|
|
||||||
|
# We need to set a custom system prompt for the User Simulator
|
||||||
|
ai_client.set_custom_system_prompt(self.system_prompt)
|
||||||
|
|
||||||
|
# We'll use a blank md_content for now as the 'User' doesn't need to read its own files
|
||||||
|
# via the same mechanism, but we could provide it if needed.
|
||||||
|
response = ai_client.send(md_content="", user_message=last_ai_msg)
|
||||||
|
return response
|
||||||
|
|
||||||
|
def perform_action_with_delay(self, action_func, *args, **kwargs):
|
||||||
|
"""
|
||||||
|
Executes an action with a human-like delay.
|
||||||
|
"""
|
||||||
|
delay = random.uniform(0.5, 2.0)
|
||||||
|
time.sleep(delay)
|
||||||
|
return action_func(*args, **kwargs)
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
import time
|
||||||
|
import os
|
||||||
|
from api_hook_client import ApiHookClient
|
||||||
|
from simulation.user_agent import UserSimAgent
|
||||||
|
|
||||||
|
class WorkflowSimulator:
|
||||||
|
def __init__(self, hook_client: ApiHookClient):
|
||||||
|
self.client = hook_client
|
||||||
|
self.user_agent = UserSimAgent(hook_client)
|
||||||
|
|
||||||
|
def setup_new_project(self, name, git_dir):
|
||||||
|
print(f"Setting up new project: {name}")
|
||||||
|
self.client.click("btn_project_new")
|
||||||
|
time.sleep(1)
|
||||||
|
self.client.set_value("project_git_dir", git_dir)
|
||||||
|
self.client.click("btn_project_save")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def create_discussion(self, name):
|
||||||
|
print(f"Creating discussion: {name}")
|
||||||
|
self.client.set_value("disc_new_name_input", name)
|
||||||
|
self.client.click("btn_disc_create")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def switch_discussion(self, name):
|
||||||
|
print(f"Switching to discussion: {name}")
|
||||||
|
self.client.select_list_item("disc_listbox", name)
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def load_prior_log(self):
|
||||||
|
print("Loading prior log")
|
||||||
|
self.client.click("btn_load_log")
|
||||||
|
# This usually opens a file dialog which we can't easily automate from here
|
||||||
|
# without more hooks, but we can verify the button click.
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def truncate_history(self, pairs):
|
||||||
|
print(f"Truncating history to {pairs} pairs")
|
||||||
|
self.client.set_value("disc_truncate_pairs", pairs)
|
||||||
|
self.client.click("btn_disc_truncate")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
def run_discussion_turn(self, user_message=None):
|
||||||
|
if user_message is None:
|
||||||
|
# Generate from AI history
|
||||||
|
session = self.client.get_session()
|
||||||
|
entries = session.get('session', {}).get('entries', [])
|
||||||
|
user_message = self.user_agent.generate_response(entries)
|
||||||
|
|
||||||
|
print(f"\n[USER]: {user_message}")
|
||||||
|
self.client.set_value("ai_input", user_message)
|
||||||
|
self.client.click("btn_gen_send")
|
||||||
|
|
||||||
|
# Wait for AI
|
||||||
|
return self.wait_for_ai_response()
|
||||||
|
|
||||||
|
def wait_for_ai_response(self, timeout=60):
|
||||||
|
print("Waiting for AI response...", end="", flush=True)
|
||||||
|
start_time = time.time()
|
||||||
|
last_count = len(self.client.get_session().get('session', {}).get('entries', []))
|
||||||
|
|
||||||
|
while time.time() - start_time < timeout:
|
||||||
|
time.sleep(1)
|
||||||
|
print(".", end="", flush=True)
|
||||||
|
entries = self.client.get_session().get('session', {}).get('entries', [])
|
||||||
|
if len(entries) > last_count:
|
||||||
|
last_entry = entries[-1]
|
||||||
|
if last_entry.get('role') == 'AI' and last_entry.get('content'):
|
||||||
|
print(f"\n[AI]: {last_entry.get('content')[:100]}...")
|
||||||
|
return last_entry
|
||||||
|
|
||||||
|
print("\nTimeout waiting for AI")
|
||||||
|
return None
|
||||||
+211
@@ -0,0 +1,211 @@
|
|||||||
|
# summarize.py
|
||||||
|
"""
|
||||||
|
Note(Gemini):
|
||||||
|
Local heuristic summariser. Doesn't use any AI or network.
|
||||||
|
Uses Python's AST to reliably pull out classes, methods, and functions.
|
||||||
|
Regex is used for TOML and Markdown.
|
||||||
|
|
||||||
|
The rationale here is simple: giving the AI the *structure* of a codebase is 90%
|
||||||
|
as good as giving it the full source, but costs 1% of the tokens.
|
||||||
|
If it needs the full source of a file after reading the summary, it can just call read_file.
|
||||||
|
"""
|
||||||
|
# summarize.py
|
||||||
|
"""
|
||||||
|
Local symbolic summariser — no AI calls, no network.
|
||||||
|
|
||||||
|
For each file, extracts structural information:
|
||||||
|
.py : imports, classes (with methods), top-level functions, global constants
|
||||||
|
.toml : top-level table keys + array lengths
|
||||||
|
.md : headings (h1-h3)
|
||||||
|
other : line count + first 8 lines as preview
|
||||||
|
|
||||||
|
Returns a compact markdown string per file, suitable for use as a low-token
|
||||||
|
context block that replaces full file contents in the initial <context> send.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import ast
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ per-type extractors
|
||||||
|
|
||||||
|
def _summarise_python(path: Path, content: str) -> str:
|
||||||
|
lines = content.splitlines()
|
||||||
|
line_count = len(lines)
|
||||||
|
parts = [f"**Python** — {line_count} lines"]
|
||||||
|
|
||||||
|
try:
|
||||||
|
tree = ast.parse(content.lstrip(chr(0xFEFF)), filename=str(path))
|
||||||
|
except SyntaxError as e:
|
||||||
|
parts.append(f"_Parse error: {e}_")
|
||||||
|
return "\n".join(parts)
|
||||||
|
|
||||||
|
# Imports
|
||||||
|
imports = []
|
||||||
|
for node in ast.walk(tree):
|
||||||
|
if isinstance(node, ast.Import):
|
||||||
|
for alias in node.names:
|
||||||
|
imports.append(alias.name.split(".")[0])
|
||||||
|
elif isinstance(node, ast.ImportFrom):
|
||||||
|
if node.module:
|
||||||
|
imports.append(node.module.split(".")[0])
|
||||||
|
if imports:
|
||||||
|
unique_imports = sorted(set(imports))
|
||||||
|
parts.append(f"imports: {', '.join(unique_imports)}")
|
||||||
|
|
||||||
|
# Top-level constants (ALL_CAPS assignments)
|
||||||
|
constants = []
|
||||||
|
for node in ast.iter_child_nodes(tree):
|
||||||
|
if isinstance(node, ast.Assign):
|
||||||
|
for t in node.targets:
|
||||||
|
if isinstance(t, ast.Name) and t.id.isupper():
|
||||||
|
constants.append(t.id)
|
||||||
|
elif isinstance(node, (ast.AnnAssign,)):
|
||||||
|
if isinstance(node.target, ast.Name) and node.target.id.isupper():
|
||||||
|
constants.append(node.target.id)
|
||||||
|
if constants:
|
||||||
|
parts.append(f"constants: {', '.join(constants)}")
|
||||||
|
|
||||||
|
# Classes + their methods
|
||||||
|
for node in ast.iter_child_nodes(tree):
|
||||||
|
if isinstance(node, ast.ClassDef):
|
||||||
|
methods = [
|
||||||
|
n.name for n in ast.iter_child_nodes(node)
|
||||||
|
if isinstance(n, (ast.FunctionDef, ast.AsyncFunctionDef))
|
||||||
|
]
|
||||||
|
if methods:
|
||||||
|
parts.append(f"class {node.name}: {', '.join(methods)}")
|
||||||
|
else:
|
||||||
|
parts.append(f"class {node.name}")
|
||||||
|
|
||||||
|
# Top-level functions
|
||||||
|
top_fns = [
|
||||||
|
node.name for node in ast.iter_child_nodes(tree)
|
||||||
|
if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))
|
||||||
|
]
|
||||||
|
if top_fns:
|
||||||
|
parts.append(f"functions: {', '.join(top_fns)}")
|
||||||
|
|
||||||
|
return "\n".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def _summarise_toml(path: Path, content: str) -> str:
|
||||||
|
lines = content.splitlines()
|
||||||
|
line_count = len(lines)
|
||||||
|
parts = [f"**TOML** — {line_count} lines"]
|
||||||
|
|
||||||
|
# Extract top-level table headers [key] and [[key]]
|
||||||
|
table_pat = re.compile(r"^\s*\[{1,2}([^\[\]]+)\]{1,2}")
|
||||||
|
tables = []
|
||||||
|
for line in lines:
|
||||||
|
m = table_pat.match(line)
|
||||||
|
if m:
|
||||||
|
tables.append(m.group(1).strip())
|
||||||
|
if tables:
|
||||||
|
parts.append(f"tables: {', '.join(tables)}")
|
||||||
|
|
||||||
|
# Top-level key = value (not inside a [table])
|
||||||
|
kv_pat = re.compile(r"^([a-zA-Z_][a-zA-Z0-9_]*)\s*=")
|
||||||
|
in_table = False
|
||||||
|
top_keys = []
|
||||||
|
for line in lines:
|
||||||
|
if table_pat.match(line):
|
||||||
|
in_table = True
|
||||||
|
continue
|
||||||
|
if not in_table:
|
||||||
|
m = kv_pat.match(line)
|
||||||
|
if m:
|
||||||
|
top_keys.append(m.group(1))
|
||||||
|
if top_keys:
|
||||||
|
parts.append(f"top-level keys: {', '.join(top_keys)}")
|
||||||
|
|
||||||
|
return "\n".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def _summarise_markdown(path: Path, content: str) -> str:
|
||||||
|
lines = content.splitlines()
|
||||||
|
line_count = len(lines)
|
||||||
|
parts = [f"**Markdown** — {line_count} lines"]
|
||||||
|
|
||||||
|
headings = []
|
||||||
|
for line in lines:
|
||||||
|
m = re.match(r"^(#{1,3})\s+(.+)", line)
|
||||||
|
if m:
|
||||||
|
level = len(m.group(1))
|
||||||
|
text = m.group(2).strip()
|
||||||
|
indent = " " * (level - 1)
|
||||||
|
headings.append(f"{indent}{text}")
|
||||||
|
if headings:
|
||||||
|
parts.append("headings:\n" + "\n".join(f" {h}" for h in headings))
|
||||||
|
|
||||||
|
return "\n".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def _summarise_generic(path: Path, content: str) -> str:
|
||||||
|
lines = content.splitlines()
|
||||||
|
line_count = len(lines)
|
||||||
|
suffix = path.suffix.lstrip(".").upper() or "TEXT"
|
||||||
|
parts = [f"**{suffix}** — {line_count} lines"]
|
||||||
|
preview = lines[:8]
|
||||||
|
if preview:
|
||||||
|
parts.append("preview:\n```\n" + "\n".join(preview) + "\n```")
|
||||||
|
return "\n".join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ dispatch
|
||||||
|
|
||||||
|
_SUMMARISERS = {
|
||||||
|
".py": _summarise_python,
|
||||||
|
".toml": _summarise_toml,
|
||||||
|
".md": _summarise_markdown,
|
||||||
|
".ini": _summarise_generic,
|
||||||
|
".txt": _summarise_generic,
|
||||||
|
".ps1": _summarise_generic,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def summarise_file(path: Path, content: str) -> str:
|
||||||
|
"""
|
||||||
|
Return a compact markdown summary string for a single file.
|
||||||
|
`content` is the already-read file text (or an error string).
|
||||||
|
"""
|
||||||
|
suffix = path.suffix.lower() if hasattr(path, "suffix") else ""
|
||||||
|
fn = _SUMMARISERS.get(suffix, _summarise_generic)
|
||||||
|
try:
|
||||||
|
return fn(path, content)
|
||||||
|
except Exception as e:
|
||||||
|
return f"_Summariser error: {e}_"
|
||||||
|
|
||||||
|
|
||||||
|
def summarise_items(file_items: list[dict]) -> list[dict]:
|
||||||
|
"""
|
||||||
|
Given a list of file_item dicts (as returned by aggregate.build_file_items),
|
||||||
|
return a parallel list of dicts with an added `summary` key.
|
||||||
|
"""
|
||||||
|
result = []
|
||||||
|
for item in file_items:
|
||||||
|
path = item.get("path")
|
||||||
|
content = item.get("content", "")
|
||||||
|
error = item.get("error", False)
|
||||||
|
if error or path is None:
|
||||||
|
summary = f"_Error reading file_"
|
||||||
|
else:
|
||||||
|
p = Path(path) if not isinstance(path, Path) else path
|
||||||
|
summary = summarise_file(p, content)
|
||||||
|
result.append({**item, "summary": summary})
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def build_summary_markdown(file_items: list[dict]) -> str:
|
||||||
|
"""
|
||||||
|
Build a compact markdown string of file summaries, suitable for the
|
||||||
|
initial <context> block instead of full file contents.
|
||||||
|
"""
|
||||||
|
summarised = summarise_items(file_items)
|
||||||
|
parts = []
|
||||||
|
for item in summarised:
|
||||||
|
path = item.get("path") or item.get("entry", "unknown")
|
||||||
|
summary = item.get("summary", "")
|
||||||
|
parts.append(f"### `{path}`\n\n{summary}")
|
||||||
|
return "\n\n---\n\n".join(parts)
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import pytest
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
import os
|
||||||
|
import signal
|
||||||
|
|
||||||
|
def kill_process_tree(pid):
|
||||||
|
"""Robustly kills a process and all its children."""
|
||||||
|
if pid is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
print(f"[Fixture] Attempting to kill process tree for PID {pid}...")
|
||||||
|
if os.name == 'nt':
|
||||||
|
# /F is force, /T is tree (includes children)
|
||||||
|
subprocess.run(["taskkill", "/F", "/T", "/PID", str(pid)],
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
check=False)
|
||||||
|
else:
|
||||||
|
# On Unix, kill the process group
|
||||||
|
os.killpg(os.getpgid(pid), signal.SIGKILL)
|
||||||
|
print(f"[Fixture] Process tree {pid} killed.")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[Fixture] Error killing process tree {pid}: {e}")
|
||||||
|
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def live_gui():
|
||||||
|
"""
|
||||||
|
Session-scoped fixture that starts gui.py with --enable-test-hooks.
|
||||||
|
Ensures the GUI is running before tests start and shuts it down after.
|
||||||
|
"""
|
||||||
|
print("\n[Fixture] Starting gui.py --enable-test-hooks...")
|
||||||
|
|
||||||
|
# Ensure logs directory exists
|
||||||
|
os.makedirs("logs", exist_ok=True)
|
||||||
|
log_file = open("logs/gui_test.log", "w", encoding="utf-8")
|
||||||
|
|
||||||
|
# Start gui.py as a subprocess.
|
||||||
|
process = subprocess.Popen(
|
||||||
|
["uv", "run", "python", "gui.py", "--enable-test-hooks"],
|
||||||
|
stdout=log_file,
|
||||||
|
stderr=log_file,
|
||||||
|
text=True,
|
||||||
|
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP if os.name == 'nt' else 0
|
||||||
|
)
|
||||||
|
|
||||||
|
# Wait for the hook server to be ready (Port 8999 per api_hooks.py)
|
||||||
|
max_retries = 5
|
||||||
|
ready = False
|
||||||
|
print(f"[Fixture] Waiting up to {max_retries}s for Hook Server on port 8999...")
|
||||||
|
|
||||||
|
start_time = time.time()
|
||||||
|
while time.time() - start_time < max_retries:
|
||||||
|
try:
|
||||||
|
# Using /status endpoint defined in HookHandler
|
||||||
|
response = requests.get("http://127.0.0.1:8999/status", timeout=0.5)
|
||||||
|
if response.status_code == 200:
|
||||||
|
ready = True
|
||||||
|
print(f"[Fixture] GUI Hook Server is ready after {round(time.time() - start_time, 2)}s.")
|
||||||
|
break
|
||||||
|
except (requests.exceptions.ConnectionError, requests.exceptions.Timeout):
|
||||||
|
if process.poll() is not None:
|
||||||
|
print("[Fixture] Process died unexpectedly during startup.")
|
||||||
|
break
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
if not ready:
|
||||||
|
print("[Fixture] TIMEOUT/FAILURE: Hook server failed to respond on port 8999 within 5s. Cleaning up...")
|
||||||
|
kill_process_tree(process.pid)
|
||||||
|
pytest.fail("Failed to start gui.py with test hooks within 5 seconds.")
|
||||||
|
|
||||||
|
try:
|
||||||
|
yield process
|
||||||
|
finally:
|
||||||
|
print("\n[Fixture] Finally block triggered: Shutting down gui.py...")
|
||||||
|
kill_process_tree(process.pid)
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
[project]
|
||||||
|
name = "temp_project"
|
||||||
|
git_dir = "C:\\projects\\manual_slop"
|
||||||
|
system_prompt = ""
|
||||||
|
main_context = ""
|
||||||
|
word_wrap = true
|
||||||
|
|
||||||
|
[output]
|
||||||
|
output_dir = "./md_gen"
|
||||||
|
|
||||||
|
[files]
|
||||||
|
base_dir = "."
|
||||||
|
paths = []
|
||||||
|
|
||||||
|
[screenshots]
|
||||||
|
base_dir = "."
|
||||||
|
paths = []
|
||||||
|
|
||||||
|
[agent.tools]
|
||||||
|
run_powershell = true
|
||||||
|
read_file = true
|
||||||
|
list_directory = true
|
||||||
|
search_files = true
|
||||||
|
get_file_summary = true
|
||||||
|
web_search = true
|
||||||
|
fetch_url = true
|
||||||
|
|
||||||
|
[discussion]
|
||||||
|
roles = [
|
||||||
|
"User",
|
||||||
|
"AI",
|
||||||
|
"Vendor API",
|
||||||
|
"System",
|
||||||
|
]
|
||||||
|
active = "main"
|
||||||
|
auto_add = true
|
||||||
|
|
||||||
|
[discussion.discussions.main]
|
||||||
|
git_commit = ""
|
||||||
|
last_updated = "2026-02-23T19:53:17"
|
||||||
|
history = []
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Ensure project root is in path
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
|
|
||||||
|
import ai_client
|
||||||
|
|
||||||
|
def test_agent_capabilities_listing():
|
||||||
|
# Verify that the agent exposes its available tools correctly
|
||||||
|
pass
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import pytest
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
# Ensure project root is in path
|
||||||
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
|
||||||
|
|
||||||
|
from ai_client import set_agent_tools, _build_anthropic_tools
|
||||||
|
|
||||||
|
def test_set_agent_tools():
|
||||||
|
# Correct usage: pass a dict
|
||||||
|
agent_tools = {"read_file": True, "list_directory": False}
|
||||||
|
set_agent_tools(agent_tools)
|
||||||
|
|
||||||
|
def test_build_anthropic_tools_conversion():
|
||||||
|
# _build_anthropic_tools takes no arguments and uses the global _agent_tools
|
||||||
|
# We set a tool to True and check if it appears in the output
|
||||||
|
set_agent_tools({"read_file": True})
|
||||||
|
anthropic_tools = _build_anthropic_tools()
|
||||||
|
tool_names = [t["name"] for t in anthropic_tools]
|
||||||
|
assert "read_file" in tool_names
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user