claw-code/.guardrails/docs/agentmcp/Sentinel IDE Integration.txt

6 lines
4.2 KiB
Plaintext

Project Sentinel: IDE Integration ProtocolVersion: 3.0.0-EnterpriseModule: 41-Integration-IDEMaps to: extensions/ (VS Code, JetBrains)Scope: Architecture for integrating Sentinel into Integrated Development Environments via MCP and LSP.1. The Integration StrategySentinel does not require a custom extension for every IDE. Instead, it leverages standard protocols—Model Context Protocol (MCP) and Language Server Protocol (LSP)—to provide a native experience with minimal glue code.1.1 The "Universal Server" ModeWhen running in IDE mode, Sentinel operates as a long-lived process:sentinel serve --transport=stdio --mode=ideIt multiplexes two protocols over the same transport or distinct pipes:MCP (for Agents): Providing tool definitions and resource limits to the AI Assistant (e.g., GitHub Copilot Chat, Cursor).LSP (for Humans): Providing diagnostics (squiggles), code actions (quick fixes), and status bar metrics to the human developer.2. VS Code IntegrationSentinel connects to VS Code primarily through the Sentinel VS Code Extension (or via generic MCP clients).2.1 The Diagnostic Provider (Linter)Sentinel acts as a "Policy Linter" for the editor.Workflow:User types code in src/auth.go.VS Code sends textDocument/didChange notification to Sentinel.Sentinel runs its internal policies (Regex, AST analysis).Detection: Sentinel spots a hardcoded secret.Action: Sentinel sends textDocument/publishDiagnostics:range: Line 42, Col 10-25.severity: Error.message: "Security Policy Violation: Hardcoded secret detected."source: "Sentinel".Result: The user sees a red squiggle immediately, even if the AI Agent isn't currently active.2.2 Code Actions (Quick Fixes)Sentinel offers automatic remediation.Scenario: Missing strict types declaration in PHP.Action:User hovers over the error.Sentinel provides CodeAction: "Add strict_types declaration".User clicks "Fix".Sentinel applies WorkspaceEdit to inject declare(strict_types=1);.2.3 The "Sentinel Panel" (Webview)The extension registers a custom view container in the sidebar.Content: Renders the "Sprint Status" from the local SQLite DB.Active Task: T-101Time Remaining: 2h 15mBlocked By: T-099Mechanism: The extension polls http://localhost:port/v1/sprint (see Module 42) or uses LSP custom commands to fetch state.3. JetBrains Integration (IntelliJ / PyCharm)For the JVM/Python ecosystem, Sentinel runs as a configured External Tool and Inspection Plugin.3.1 The Inspection ProfileMapping: Sentinel maps its "Audit Levels" to JetBrains "Inspection Severity".Sentinel L1 -> IntelliJ Weak Warning.Sentinel L2 -> IntelliJ Error.Execution:Sentinel runs in headless mode via sentinel check --format=xml.The plugin parses the XML output and highlights lines in the editor.3.2 "Check with Sentinel" ActionContext Menu: Right-click on any file -> Sentinel > Verify Compliance.Function:Locks the file.Runs the full Sentinel Guardrail suite (Lint, Test coverage, Policy check).Opens a tool window with the specific results.4. Neovim / Vim IntegrationFor terminal power users, Sentinel integrates via nvim-lspconfig and null-ls.4.1 LSP ConfigurationIn init.lua:require'lspconfig'.sentinel.setup{
cmd = { "sentinel", "serve", "--transport=stdio" },
filetypes = { "go", "python", "javascript", "rust" },
root_dir = util.root_pattern(".sentinel", ".git"),
}
4.2 Telescope IntegrationCommand: :Telescope sentinel tasksFunction:Calls Sentinel API to fetch active tasks.Displays them in a fuzzy finder window.Selection triggers sentinel start_task <id>.5. Agent-IDE SymbiosisSentinel bridges the gap between the "Chat Window" (Agent) and the "Editor Window" (Human).5.1 Context SynchronizationProblem: Agent creates a file, but the User doesn't see it open.Solution:When Agent calls write_file("new_feature.go"), Sentinel sends a window/showDocument request to the IDE.Result: The file instantly opens in the user's tab, allowing for real-time visual verification of the Agent's work.5.2 Terminal SharingMechanism: Sentinel can request to spawn a standard IDE terminal.Usage:Agent: run_command("npm start").Sentinel: Tells IDE to open a generic terminal named "Sentinel Executor" and run the command there.Benefit: The user can see the server output, interact with it (Ctrl+C), and debugging becomes shared.