Skip to content

feat: agent auto-install, AI approval refactor, and misc fixes - #2

Merged
junjieit merged 9 commits into
mainfrom
fix/misc-issues
May 30, 2026
Merged

feat: agent auto-install, AI approval refactor, and misc fixes#2
junjieit merged 9 commits into
mainfrom
fix/misc-issues

Conversation

@junjieit

Copy link
Copy Markdown
Contributor

Summary

  • Add agent auto-install API (npm/brew/script fallback chain) with GET /agents and POST /agents/install endpoints
  • Refactor Claude permission hook: separate auto-allow, policy check, AI review, and human escalation into distinct layers
  • Improve rm path escape detection with proper path normalization instead of hardcoded system path prefixes
  • Merge consecutive assistant message blocks with --- separator across all providers (Claude, Codex, OpenCode)
  • Seed message inbox from provider archive to preserve historical conversation on first access
  • Add error_message field to SessionStatusEvent for failed sessions
  • Guard against empty hook files causing JSON parse errors
  • Pass OpenCode system prompt via dedicated API field instead of prepending to user message

Test plan

  • Unit tests for consecutive assistant block merging (including across tool_result)
  • Verify agent install API with GET /agents and POST /agents/install
  • Test Claude permission hook: auto-allow, policy, AI review, and human fallback paths
  • Test rm path escape detection with relative and absolute paths
  • Verify empty hook files are skipped without errors

🤖 Generated with Claude Code

junjieit and others added 9 commits May 29, 2026 22:24
Previously the system prompt was concatenated into the user message.
Now it's sent as a separate `system` field in the prompt_async request
body, matching the OpenCode API's PromptInput schema.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Remove overly broad system path patterns (/etc/, /var/, /usr/, /bin/,
/sbin/) from hard block list. Instead, detect rm commands that reference
paths escaping the project root via path_escapes_project().

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Before pushing the first user message, pre-seed the in-memory message
cache from the provider's archive so that list_messages doesn't shadow
historical conversation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add AgentInstallResult, AgentInstallInput, and AgentSummary models
for the agent auto-install API.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add /agents and /agents/install endpoints. Agents can be installed via
npm, brew, or platform-specific install scripts. Falls back to manual
install hints when auto-install is unavailable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Auto-approve Claude Code permission requests using the same policy
  as Codex, instead of always requiring user approval.
- Guard against empty body files in next_claude_permission_request and
  next_claude_status_event to prevent JSON parse errors.
- Remove redundant AI approval check from Claude permission hook.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Use `---` to separate multiple content blocks within a single
assistant turn, both for real-time streaming and historical messages.
Filter out `tool_result` user entries in Claude Code archives so
consecutive assistant text blocks merge into one message.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Previously the Claude Code hook skipped the AI risk assessment layer
entirely — commands not matched by the deterministic policy went
straight to human approval. Now the hook calls ai_approval::review_request()
before escalating, consistent with the Codex/OpenCode paths.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Include the failure reason directly in the session_status event payload
so clients don't need to correlate a separate AgentError event.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@junjieit
junjieit merged commit 3c8e1d5 into main May 30, 2026
1 check passed
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