Skip to content

Sync SDK with CLI v2.1.87#46

Closed
guess wants to merge 11 commits into
mainfrom
feature/cli-sync
Closed

Sync SDK with CLI v2.1.87#46
guess wants to merge 11 commits into
mainfrom
feature/cli-sync

Conversation

@guess
Copy link
Copy Markdown
Owner

@guess guess commented Mar 29, 2026

Summary

  • Bump bundled CLI version from 2.1.76 to 2.1.87
  • Add ApiRetry and SessionStateChanged system message types
  • Add get_context_usage, reload_plugins, and seed_read_state control protocol requests
  • Add --system-prompt-file, --append-system-prompt-file, and --bare CLI options
  • Update type-mapping and cli-flags reference files, CLAUDE.md

Test plan

  • All 1514 tests pass (0 failures)
  • mix quality passes (compile, format, credo, dialyzer)
  • New message types tested: parsing, fallback clauses, type guards
  • New control requests tested: JSON wire format verification
  • New options tested: validation and CLI flag conversion

@guess
Copy link
Copy Markdown
Owner Author

guess commented Mar 29, 2026

Code review

Found 1 issue:

  1. New system message subtypes ApiRetry and SessionStateChanged are not registered in lib/claude_code/message/system_message.ex. The @type t union (line 24) and type?/1 guard (lines 42-54) are missing clauses for both new structs. This means Message.message?/1 returns false for these message types, since it delegates to SystemMessage.type?/1 for system messages. Code that filters or routes messages using message?/1 will silently drop API retry and session state change notifications.

@type t ::
Init.t()
| CompactBoundary.t()
| HookStarted.t()
| HookResponse.t()
| HookProgress.t()
| Status.t()
| LocalCommandOutput.t()
| FilesPersisted.t()
| ElicitationComplete.t()
| TaskStarted.t()
| TaskProgress.t()
| TaskNotification.t()
@doc """
Checks if a value is any type of system message.
"""
@spec type?(any()) :: boolean()
def type?(%Init{}), do: true
def type?(%CompactBoundary{}), do: true
def type?(%HookStarted{}), do: true
def type?(%HookResponse{}), do: true
def type?(%HookProgress{}), do: true
def type?(%Status{}), do: true
def type?(%LocalCommandOutput{}), do: true
def type?(%FilesPersisted{}), do: true
def type?(%ElicitationComplete{}), do: true
def type?(%TaskStarted{}), do: true
def type?(%TaskProgress{}), do: true
def type?(%TaskNotification{}), do: true
def type?(_), do: false

Every other system message subtype in the codebase is registered in both the type union and the guard function. The fix is to add aliases, type union entries, and type?/1 clauses for ApiRetry and SessionStateChanged.

Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

Test added 10 commits March 29, 2026 15:18
Implements parsing for the api_retry system subtype emitted by the CLI
when retrying API requests due to rate limits or transient errors.
Adds seed_read_state control request to seed the CLI's file read state
cache with a path+mtime entry, preventing Edit validation failures after
context compaction.
Adds :bare boolean option that maps to --bare CLI flag, skipping hooks,
LSP, plugin sync, and skill directory walks for faster scripted sessions.
@guess guess force-pushed the feature/cli-sync branch from 532d204 to abdeee3 Compare March 29, 2026 19:18
@guess guess closed this Mar 29, 2026
@guess guess deleted the feature/cli-sync branch March 29, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant