capture: add editor and terminal S1 field extraction - #13
Conversation
Parse VS Code / Cursor / Windsurf window titles for editor_file, editor_project, and editor_git_branch. Parse terminal window titles (iTerm2, Terminal.app, Alacritty, Warp, etc.) for terminal_cwd. New fields are injected into the capture JSON by s1_parser.enrich(), exposed to MCP clients via read_recent_capture response, and rendered in timeline block prompts for downstream reducer/classifier consumption. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request introduces the extraction of app-specific metadata—such as file names, project names, git branches, and working directories—from the window titles of supported editors and terminals. These fields are now integrated into the capture enrichment process, MCP tool responses, and timeline aggregation. The review feedback identifies a logic error in the editor title parser where file and project parts were inverted, suggests improvements to terminal path resolution to avoid incorrect context and blocking I/O, recommends simplifying the field initialization logic, and points out a missing case for home-relative paths in SSH titles.
- Swap file/project order in ASCII-dash fallback (was inverted) - Support ~/ home-relative paths in SSH terminal titles - Remove ./ relative path support (meaningless outside terminal CWD) - Replace Path.resolve() with os.path.normpath() (no disk I/O) - Remove now-unused pathlib.Path import - Simplify field initialisation in enrich() Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Note on relationship with #15 This PR was implemented first, as a direct extension of So I opened #15 to introduce a lightweight app parser registry with a baseline-plus-patches model. That infrastructure PR intentionally contains no editor/terminal behaviour — it only migrates the existing browser URL extraction into My plan going forward:
Happy to go either direction depending on what the maintainer prefers. |
Summary
Add S1-level context extraction for editor apps (VS Code, Cursor, Windsurf) and terminal apps (Terminal.app, iTerm2, Alacritty, Warp, Kitty, Hyper).
What changes
capture/s1_parser.py: extracteditor_file,editor_project,editor_git_branchfrom editor window titles,terminal_cwdfrom terminal window titles. New fields are injected into the capture JSON byenrich().mcp/captures.py: expose new fields inread_recent_captureresponse so external agents can consume them.timeline/aggregator.py: render new fields as compact hints in timeline block prompts for downstream reducer/classifier consumption.How it works
Editor title parsing
Handles VS Code / Cursor / Windsurf window title patterns:
Terminal title parsing
Handles common terminal emulator window titles:
Why
These fields tell downstream agents what file/project the user is editing and what directory they're working in — information that is already in the window title but was not being extracted into the structured capture dict.
Test plan
enrich()path for VS Code and iTerm2)read_recent_capture()