ccpocket

repository·main·Indexed 21 days ago

https://github.com/k9i-0/ccpocket

A mobile and desktop application for controlling AI coding agents like Codex and Claude remotely. It utilizes a self-hosted Bridge Server (@ccpocket/bridge) to connect interfaces to local agent sessions, allowing users to review code, approve actions, and manage git workflows via WebSockets.

Tokens
52.8K
Snippets
128
Records
247
Agent score
75%

What's inside ccpocket

  1. Experimental Linux Desktop Support Status

    main
    Linux desktop support in CC Pocket is currently in an experimental/in-progress state. Users should treat Linux artifacts as experimental and expect potential limitations in service availability and GUI behavior. The project is working towards a supported release by validating core integration tests, packaging strategies, and multi-environment stability.
  2. Conflict detection rules for pending actions

    main

    The system uses a conservative approach to determine if a pending action conflicts with the current Bridge state.

    PendingInputAction is a CONFLICT if the delta since baseSeq contains:

    • user_input from another device or client.
    • A result that completes the current turn.
    • System events that change the conversation context (e.g., session switch, rewind, sandbox restart, or stop_session).

    PendingInputAction is NOT a conflict if the delta contains:

    • status updates.
    • stream_delta or thinking_delta.
    • assistant messages.
    • tool_result.
    • permission_request or permission_resolved.
    • conversation_queue updates.

    Other Action Conflict Rules:

    • PendingStartSessionAction: Not a conflict if projectPath, provider, and startOptions are valid (since the session doesn't exist on the Bridge yet).
    • PendingResumeSessionAction: Conflict if the provider session's metadata/timestamp has changed.
    • PendingRenameSessionAction: Failed if the session cannot be resolved; otherwise, follows 'latest-wins'.
    • PendingCodexQueueAction: Failed if the target itemId no longer exists in the Bridge's conversation_queue.
  3. Understand the Supporter program and its benefits

    main

    The Supporter program is an optional way to support the continued development of CC Pocket. It is designed to be lightweight and does not unlock core features or change how the application functions.

    Key points:

    • No Paywalls: CC Pocket is free to use. Being a Supporter does not unlock restricted features; it is purely for supporting development costs (AI usage, testing devices, etc.).
    • Supporter Benefits: Monthly Supporters unlock alternative application icons available in Settings > App Icon.
    • Support Types: You can provide support via a one-time contribution (Drink Support or Lunch Support) or a monthly subscription (Supporter Monthly).
    • Support Overview: All supporters (monthly or one-time) can view their support history/overview in the Support page.
  4. Understand the CC Pocket Architecture

    main

    CC Pocket is a client framework designed for self-hosting. It allows you to control local Codex or Claude agent sessions from mobile or desktop surfaces via a Bridge Server.

    The Workflow Model:

    1. CC Pocket App: The control surface (mobile/desktop) used for sending prompts, approving actions, and browsing files.
    2. Bridge Server: Runs on the machine containing the project. It communicates with the app via a JSON WebSocket protocol and manages local agent tools, shell, git, and the filesystem.
    3. Local Agents: The actual Codex or Claude sessions running on the host machine.
  5. Use AI to generate commit messages and PR content

    main

    ccpocket uses the host machine's existing CLI authentication to generate commit messages and PR details via the official CLI interfaces (claude -p or codex -q). This ensures compliance with existing user billing and authentication.

    Implementation logic:

    • For Claude Code sessions: Uses claude -p --model <model>.
    • For Codex sessions: Uses codex -q --model <model>.
    • If no specific model is configured in the session, it falls back to the CLI default.
    # Example: Generating a commit message for a Claude Code session
    echo "${diff}" | claude -p --model claude-sonnet-4-6 \
      "Generate a commit message. ${customPrompt}"
    
    # Example: Generating a commit message for a Codex session
    echo "${diff}" | codex -q --model gpt-5.4-mini \
      "Generate a commit message. ${customPrompt}"
  6. Understand Agent Teams constraints

    main

    When working with Agent Teams, be aware of the following limitations:

    1. CLI-Only: It is a Claude Code CLI feature and cannot be controlled directly via the SDK.
    2. No Persistence: Teammates are not restored when resuming a session.
    3. No Nesting: Nested teams are not supported (a teammate cannot create its own team).
    4. Cost: Each teammate runs as an independent Claude instance, which increases token usage/costs.
    5. Single Team per Session: Only one team can exist per session.
  7. Understand the Adaptive Workspace Layout

    main

    CC Pocket uses an adaptive layout system that switches between 1, 2, and 3 panes based on available screen width rather than device type. This allows the app to provide an optimized experience on tablets, foldables, and macOS.

    Pane Roles

    • Left Pane: Contains the session list, new session triggers, and navigation to settings/gallery.
    • Center Pane: The primary workspace area, hosting ClaudeSessionScreen or CodexSessionScreen.
    • Right Pane: An auxiliary area for tools like GitScreen, ExploreScreen, or GalleryScreen.

    Layout Modes

    • 1 Pane (< 600dp): Standard full-screen mode. Navigation uses route pushes (e.g., moving from list to detail).
    • 2 Pane (600 - 1099dp): Typically shows Left + Center. If a right pane tool (like Git) is requested, the layout switches to Center + Right, automatically collapsing the left pane to prioritize the center content.
    • 3 Pane (1100dp+): Shows Left + Center + Right simultaneously. Both side panes can be manually collapsed.
  8. Understand the CC Pocket Supporter model

    main

    CC Pocket is free to use. The Supporter program is an optional way to support ongoing development and does not unlock core features or restrict app usage.

    Key Concepts:

    • No Feature Locking: Core functionality is not gated behind a paywall.
    • Privacy-First Design: The app avoids creating CC Pocket accounts or collecting long-term identifiers for monetization. This means there is no cross-platform synchronization between iOS and Android.
    • Supporter Benefits: Primarily consists of a dedicated Support screen to view history and access alternative app icons via Settings > App Icon.
  9. Authenticate Bridge requests with Push Relay Functions

    main
    The Push Relay Functions use Firebase Anonymous Auth for security. The Bridge sends an ID token obtained via Firebase Anonymous Auth as a Bearer token. The Relay validates this token and uses the authenticated UID as the Bridge ID. Because authentication is handled via the token itself, no additional environment variables or shared secrets need to be configured.
  10. Understand the Git Worker RPC architecture

    main
    The system uses a Git Worker (running as worker.js within Electron) to handle Git plumbing operations via RPC calls from the UI. While the AI agent generates code changes, the application itself is responsible for branch creation, commits, pushes, and PR creation. This separation ensures that the agent only focuses on code generation while the app manages the repository state.
  11. Define Claude CLI Permission Rules

    main

    Permissions can be granularly defined using the pattern ToolName(ruleContent). Rules can be set to allow, deny, or ask behaviors.

    Rule Syntax Examples

    • Read: Matches any use of the Read tool.
    • Bash(npm:*): Prefix match; matches any Bash command starting with npm.
    • Bash(git status): Exact match; matches only the specific command git status.
    • Edit(.claude): Matches the Edit tool when targeting .claude files.
    • Write(/etc/*): Matches the Write tool for paths under /etc/.

    Rule Scopes (Destinations)

    Rules are stored in different locations depending on their intended lifecycle:

    • session: Volatile, in-memory approvals for the current session.
    • cliArg: Passed via --allowed-tools or --disallowed-tools.
    • command: Provided via slash commands.
    • localSettings: Stored in .claude/settings.local.json.
    • projectSettings: Stored in .claude/settings.json (typically checked into version control).
    • userSettings: Stored in ~/.claude/settings.json.
    • policySettings: Organization-level read-only policies.
    • flagSettings: Runtime feature flags (read-only).
    {
      "permissions": {
        "allow": ["Bash(npm:*)", "Edit(.claude)", "Read"],
        "deny": ["Bash(rm -rf:*)"],
        "ask": ["Write(/etc/*)"],
        "defaultMode": "acceptEdits"
      }
    }
  12. Handle Codex ThreadEvents and Items

    main

    The SDK communicates via a stream of ThreadEvent objects. You should listen for these events to track the lifecycle of a thread and the progress of individual items (like reasoning or tool calls).

    Event Lifecycle Patterns

    Standard Text Response: thread.started $\rightarrow$ turn.started $\rightarrow$ item.completed(reasoning) $\rightarrow$ item.completed(agent_message) $\rightarrow$ turn.completed

    Response with Command Execution: thread.started $\rightarrow$ turn.started $\rightarrow$ item.completed(reasoning) $\rightarrow$ item.completed(agent_message) $\rightarrow$ item.started(command_execution) $\rightarrow$ item.completed(command_execution) $\rightarrow$ item.completed(agent_message) $\rightarrow$ turn.completed

    ThreadItem Types

    Items represent the specific content generated during a turn:

    • AgentMessageItem: The actual text response from the agent.
    • ReasoningItem: A summary of the agent's internal reasoning (e.g., "**Planning file read execution**").
    • CommandExecutionItem: Details about shell commands being run (includes command, aggregated_output, exit_code, and status).
    • FileChangeItem: Patches or file modifications.
    • McpToolCallItem: Calls to MCP tools.
    • WebSearchItem: Web search results.
    • TodoListItem: Task lists generated by the agent.
    • ErrorItem: Error details.
    type ThreadEvent =
      | ThreadStartedEvent
      | TurnStartedEvent
      | TurnCompletedEvent
      | TurnFailedEvent
      | ItemStartedEvent
      | ItemUpdatedEvent
      | ItemCompletedEvent
      | ThreadErrorEvent;
    
    type ThreadItem =
      | AgentMessageItem
      | ReasoningItem
      | CommandExecutionItem
      | FileChangeItem
      | McpToolCallItem
      | WebSearchItem
      | TodoListItem
      | ErrorItem;