Add Semantic Block Protocol (DEC Mode 2034) with SBQUERY#1900
Merged
christianparpart merged 1 commit intomasterfrom Feb 26, 2026
Merged
Add Semantic Block Protocol (DEC Mode 2034) with SBQUERY#1900christianparpart merged 1 commit intomasterfrom
christianparpart merged 1 commit intomasterfrom
Conversation
3e1c5c5 to
1906f4b
Compare
1906f4b to
a89ca63
Compare
There was a problem hiding this comment.
Pull request overview
This pull request introduces the Semantic Block Protocol (DEC Mode 2034) that enables programmatic querying of shell command history through structured JSON responses. The implementation tracks OSC 133 shell integration sequences and provides a query mechanism via the new SBQUERY sequence (CSI > Ps ; Pn b) to retrieve command metadata including command line, exit code, prompt text, and output text.
Changes:
- Added DEC Private Mode 2034 to enable/disable semantic block tracking with line flags (
OutputStart,CommandEnd) stored in the grid buffer alongside command metadata - Implemented SBQUERY sequence supporting three query types: last completed command, last N completed commands, and current in-progress command, with DCS-formatted JSON responses
- Included comprehensive test suite (8 test cases, 27 assertions) covering mode toggling, metadata tracking, DECRQM reporting, and all query types
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/vtbackend/primitives.h | Added DECMode::SemanticBlockProtocol (2034) enum value and bidirectional conversion functions |
| src/vtbackend/Terminal.h | Added SemanticBlockTracker member and accessor methods to Terminal class |
| src/vtbackend/Terminal.cpp | Integrated mode 2034 handling in setMode() and added string conversion for the new mode |
| src/vtbackend/SemanticBlockTracker.h | New header defining CommandBlockInfo, SBQueryType constants, and SemanticBlockTracker class |
| src/vtbackend/SemanticBlockTracker.cpp | Implementation of semantic block tracking with state management for completed and in-progress commands |
| src/vtbackend/Screen.h | Added handleSemanticBlockQuery() method declaration |
| src/vtbackend/Screen.cpp | Implemented handleSemanticBlockQuery() with backward grid scanning, JSON generation, and integrated tracker calls into processShellIntegration() |
| src/vtbackend/Line.h | Added OutputStart and CommandEnd line flags for semantic block boundaries |
| src/vtbackend/Functions.h | Added SBQUERY function definition with proper CSI parameters |
| src/vtbackend/ShellIntegration_test.cpp | Added 8 test cases covering line flags, metadata tracking, DECRQM, and all query scenarios |
| src/vtbackend/CMakeLists.txt | Added SemanticBlockTracker source and header files to build |
| docs/vt-extensions/semantic-block-query.md | Complete protocol specification with syntax, response format, JSON schema, and examples |
| mkdocs.yml | Added documentation page to navigation |
| .github/actions/spelling/expect.txt | Added expected spelling exceptions for new terminology |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dc324b6 to
7e30bb5
Compare
Add token-based authentication to SBQUERY: DECSET 2034 now generates a 64-bit session token (4 x uint16) and replies via DCS. Every SBQUERY must include the token as CSI parameters 2..5. Missing token returns status 2, wrong token returns status 3. Token is invalidated on DECRST and regenerated on re-enable. Signed-off-by: Christian Parpart <christian@parpart.family>
7e30bb5 to
987cd24
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OutputStart,CommandEnd) in the grid ring buffer.CSI > Ps ; Pn b) that returns structured JSON via DCS responses, supporting three query types: last completed command (Ps=1), last N completed commands (Ps=2), and current in-progress command (Ps=3). Query type values use namedSBQueryTypeconstants to avoid magic numbers.SemanticBlockTrackerclass, full test coverage (8 test cases / 27 assertions), and a protocol specification document atdocs/vt-extensions/semantic-block-query.md.@Yaraslaut Background story: I need that for endo to be able to let the shell agent read the output of the last executed command.