Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ final class AgentRuntimeBridge: AgentRuntimeSupporting {
"""#
}

/// Claude wrapper that injects top-level start and stop hooks for the current surface.
/// Claude wrapper that injects managed activity hooks for the current surface.
private var claudeWrapperContents: String {
#"""
#!/bin/sh
Expand Down Expand Up @@ -252,6 +252,37 @@ final class AgentRuntimeBridge: AgentRuntimeSupporting {
}
]
}
],
"PermissionRequest": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "\"$SHELLRAISER_HELPER_PATH\" claudeCode \"$SHELLRAISER_SURFACE_ID\" completed"
}
]
}
],
"Notification": [
{
"matcher": "permission_prompt",
"hooks": [
{
"type": "command",
"command": "\"$SHELLRAISER_HELPER_PATH\" claudeCode \"$SHELLRAISER_SURFACE_ID\" completed"
}
]
},
{
"matcher": "elicitation_dialog",
"hooks": [
{
"type": "command",
"command": "\"$SHELLRAISER_HELPER_PATH\" claudeCode \"$SHELLRAISER_SURFACE_ID\" completed"
}
]
}
]
}
}
Expand Down
9 changes: 7 additions & 2 deletions Tests/ShellraiserTests/AgentRuntimeBridgeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import XCTest
/// Covers managed-agent wrapper generation for runtime integration.
@MainActor
final class AgentRuntimeBridgeTests: XCTestCase {
/// Verifies the Claude wrapper emits top-level start/stop hooks without subagent hooks.
func testPrepareRuntimeSupportWritesClaudeWrapperWithoutSubagentStopHook() throws {
/// Verifies the Claude wrapper emits start, stop, permission-request, and selected notification hooks.
func testPrepareRuntimeSupportWritesClaudeWrapperWithMappedNotificationHooks() throws {
let bridge = AgentRuntimeBridge.shared
let wrapperURL = bridge.binDirectory.appendingPathComponent("claude")

Expand All @@ -17,6 +17,11 @@ final class AgentRuntimeBridgeTests: XCTestCase {

XCTAssertTrue(wrapperContents.contains("\"UserPromptSubmit\""))
XCTAssertTrue(wrapperContents.contains("\"Stop\""))
XCTAssertTrue(wrapperContents.contains("\"PermissionRequest\""))
XCTAssertTrue(wrapperContents.contains("\"matcher\": \"*\""))
XCTAssertTrue(wrapperContents.contains("\"Notification\""))
XCTAssertTrue(wrapperContents.contains("\"matcher\": \"permission_prompt\""))
XCTAssertTrue(wrapperContents.contains("\"matcher\": \"elicitation_dialog\""))
Comment on lines +20 to +24
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Assert the new hooks still map to completed.

These checks only prove the sections and matchers exist. A regression where one of the new hooks emitted started or pointed at a different command would still pass, which misses the PR’s actual behavior change.

🔍 Tighten the assertion
         XCTAssertTrue(wrapperContents.contains("\"Notification\""))
         XCTAssertTrue(wrapperContents.contains("\"matcher\": \"permission_prompt\""))
         XCTAssertTrue(wrapperContents.contains("\"matcher\": \"elicitation_dialog\""))
+        XCTAssertEqual(
+            wrapperContents.components(
+                separatedBy: #"claudeCode \"$SHELLRAISER_SURFACE_ID\" completed"#
+            ).count - 1,
+            4
+        )
         XCTAssertFalse(wrapperContents.contains("\"SubagentStop\""))
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Tests/ShellraiserTests/AgentRuntimeBridgeTests.swift` around lines 20 - 24,
The test currently only checks wrapperContents contains entries for
"PermissionRequest", "Notification", and matchers but not that those hooks map
to the completed lifecycle; update the assertions in AgentRuntimeBridgeTests
(e.g., the expectations referencing wrapperContents) to also assert the specific
mapping value is "\"state\": \"completed\"" (or the exact completed mapping used
by the product) for the new hooks—ensure you check that the PermissionRequest,
Notification, and matcher entries include the completed state rather than
started or another command so a regression will fail if they do not map to
completed.

XCTAssertFalse(wrapperContents.contains("\"SubagentStop\""))
}

Expand Down