Skip to content

Commit e8c144b

Browse files
Merge pull request #28 from jamesrochabrun/fix/expose-debug-info-and-working-directory
Fix debug information and runtime working directory updates
2 parents 24509eb + 4914a98 commit e8c144b

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

Sources/ClaudeCodeSDK/Backend/AgentSDKBackend.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,4 +614,12 @@ internal final class AgentSDKBackend: ClaudeCodeBackend, @unchecked Sendable {
614614
logger?.error("Error parsing SDK JSON: \(error.localizedDescription)")
615615
}
616616
}
617+
618+
// MARK: - Debug Information
619+
620+
/// Debug information about the last command executed
621+
/// Note: AgentSDKBackend does not currently track command execution details
622+
var lastExecutedCommandInfo: ExecutedCommandInfo? {
623+
return nil
624+
}
617625
}

Sources/ClaudeCodeSDK/Backend/ClaudeCodeBackend.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,8 @@ internal protocol ClaudeCodeBackend: Sendable {
8181
/// Validates if the backend is properly configured and available
8282
/// - Returns: true if the backend is ready to use
8383
func validateSetup() async throws -> Bool
84+
85+
/// Debug information about the last command executed
86+
/// - Returns: Information about the last executed command, or nil if no commands have been executed
87+
var lastExecutedCommandInfo: ExecutedCommandInfo? { get }
8488
}

Sources/ClaudeCodeSDK/Backend/HeadlessBackend.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,4 +828,11 @@ internal final class HeadlessBackend: ClaudeCodeBackend, @unchecked Sendable {
828828
}
829829
logger?.error("Error details: \(error)")
830830
}
831+
832+
// MARK: - Debug Information
833+
834+
/// Debug information about the last command executed
835+
var lastExecutedCommandInfo: ExecutedCommandInfo? {
836+
return _lastExecutedCommandInfo
837+
}
831838
}

Sources/ClaudeCodeSDK/Client/ClaudeCodeClient.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ public final class ClaudeCodeClient: ClaudeCode, @unchecked Sendable {
1515
/// Configuration for the client - can be updated at any time
1616
public var configuration: ClaudeCodeConfiguration {
1717
didSet {
18-
// Recreate backend if type changed
19-
if oldValue.backend != self.configuration.backend {
18+
// Recreate backend if type or working directory changed
19+
if oldValue.backend != self.configuration.backend ||
20+
oldValue.workingDirectory != self.configuration.workingDirectory {
2021
do {
2122
backend = try BackendFactory.createBackend(for: self.configuration)
22-
logger?.info("Backend switched to: \(self.configuration.backend.rawValue)")
23+
logger?.info("Backend recreated - type: \(self.configuration.backend.rawValue), workingDir: \(self.configuration.workingDirectory ?? "none")")
2324
} catch {
2425
logger?.error("Failed to create backend: \(error.localizedDescription)")
2526
// Keep the old backend if creation fails
@@ -31,8 +32,7 @@ public final class ClaudeCodeClient: ClaudeCode, @unchecked Sendable {
3132

3233
/// Debug information about the last command executed
3334
public var lastExecutedCommandInfo: ExecutedCommandInfo? {
34-
// Note: This is a placeholder - actual implementation would need backend support
35-
nil
35+
return backend.lastExecutedCommandInfo
3636
}
3737

3838
/// Initializes the client with a configuration

0 commit comments

Comments
 (0)