hello2cc

repository·main·Indexed 20 days ago

https://github.com/hellowind777/hello2cc

A Claude Code alignment plugin designed to make third-party models (such as GPT, DeepSeek, or Gemini) behave like native Claude Opus sessions. It aligns tool choice, agent routing, task workflows, and response styles to match native Claude Code patterns. The plugin includes a ccstatusline bridge to backfill usage metrics from transcripts and provides a 'Native' output style to prioritize execution-first, concise interactions.

Tokens
10K
Snippets
27
Records
37
Agent score
69%

What's inside hello2cc

  1. How hello2cc handles StatusLine and Subagent context

    main

    To ensure compatibility with various Claude Code versions and naming conventions, hello2cc implements robust identity and context resolution:

    Subagent Identity Resolution

    The system is designed to be resilient to changes in key naming (e.g., camelCase vs snake_case). It recognizes the following identifiers for subagents:

    • agentId
    • agent_id
    • agent.id

    Transcript Path Resolution

    Instead of relying solely on inferring paths from subagents/agent-<id>.jsonl, the system supports direct usage of agent_transcript_path or agent_transcript_path found within transcript records.

    Context Window Inference

    hello2cc uses inferContextWindowSize() to approximate the context window based on model names, mimicking Claude Code's internal logic. It supports common patterns like:

    • [1m]
    • opus-4-6
    • sonnet-4-6
    • claude-sonnet-4
    • It also respects the CLAUDE_CODE_MAX_CONTEXT_TOKENS environment variable.
  2. How the ccstatusline bridge works

    main

    The ccstatusline-bridge.mjs script performs the following logic to ensure accurate status reporting:

    1. Intercepts JSON: Reads the JSON payload passed from Claude Code to StatusLine.
    2. Aggregates Usage: Uses transcript_path to sum up usage from both the main session and any referenced subagent transcripts.
    3. Field Mapping: Recognizes various naming conventions for agents and transcripts, including:
      • agentId / agent_id / agent.id
      • agentTranscriptPath / agent_transcript_path
    4. Conditional Backfilling: Only fills in context_window fields if they are missing or equal to 0. It will not overwrite non-zero statistics provided natively by Claude Code.
    5. Context Window Inference: If context_window_size is missing, it prioritizes the CLAUDE_CODE_MAX_CONTEXT_TOKENS environment variable. If that is also missing, it infers the window size based on common 1M token model defaults.
    6. Passthrough: Passes the enriched JSON to ccstatusline@latest without modifying the original source code of Claude Code or ccstatusline.
  3. How hello2cc works

    main

    hello2cc acts as a plugin layer between a third-party model (connected via a gateway/provider) and the Claude Code host. It does not handle API keys or provider mapping; it focuses on behavioral alignment through three main layers:

    1. Host State Guidance: Explicitly provides the model with the current session's tools, agents, workflows, MCP, and continuity state to prevent incorrect tool selection.
    2. Pre/Post Tool Guardrails: Normalizes inputs, cleans placeholder values, records failure memory, and maintains a fail-closed state for deterministic errors.
    3. Native Style Shell: Constrains model output to be direct, concise, and execution-oriented, mimicking Claude Code's default style.

    This architecture helps reduce 'drift' in tool usage, team/task management, and conversational style.

  4. Understand the scope and responsibilities of hello2cc

    main

    It is critical to understand that hello2cc is not a full implementation of the hellox Rust workspace. It functions exclusively as a plugin adaptation layer for Claude Code.

    What hello2cc handles:

    • Hook Lifecycle: Managing events like SessionStart, UserPromptSubmit, SubagentStart, TaskCreated, etc.
    • Parameter Normalization: Unifying Agent, Team, and Task semantics.
    • Session/Transcript State: Parsing transcripts and extracting host-state snapshots.
    • StatusLine Context: Bridging ccstatusline usage by backfilling data from transcripts when Claude Code payloads are incomplete.
    • Subagent Context: Injecting context for subagents and handling identity resolution.

    What hello2cc does NOT handle:

    • Rust Crates: It does not implement hellox-cli, hellox-gateway, or hellox-tui.
    • Gateway/Providers: Third-party adapter layers are outside this repository's scope.
    • Cloud Services: It does not implement hosted authentication, remote hubs, web consoles, or managed session synchronization (it follows a local-first philosophy).
    • Direct Source Modification: It does not modify the Claude Code or ccstatusline source code directly.
  5. Understand the priority of hello2cc Native rules

    main

    When using the hello2cc Native style, it is not an absolute override. There is a strict hierarchy of instructions that determines how the agent behaves:

    1. Highest Priority: User instructions, Claude Code host instructions, and repository/user rules defined in CLAUDE.md or AGENTS.md always win.
    2. Style Application: Use this style only when it does not conflict with higher-priority rules. If a higher-priority rule requires a specific top banner, footer action bar, checklist syntax, or command flow, follow that rule exactly.
    3. Constraint: Do not use this style to replace an existing workflow, wrapper format, command-routing convention, or project-specific response structure already established by higher-priority rules.
  6. Verify hello2cc implementation and compatibility

    main

    To ensure the plugin adaptation layer is correctly implemented and meets the required boundaries, use the following commands:

    Validate Implementation

    Run the validation suite to ensure the plugin layer meets the defined requirements:

    npm run validate

    Test StatusLine Filtering

    To specifically verify the ccstatusline bridge, subagent ID recognition, and transcript path handling, run the dedicated test suite:

    npm test -- tests/ccstatusline-filter.test.mjs

    General Code Quality Check

    Run the standard check command to ensure code consistency:

    npm run check
    npm run validate
    npm test -- tests/ccstatusline-filter.test.mjs
    npm run check
  7. Configure ccstatusline compatibility bridge for Claude Code

    main

    When using hello2cc with third-party models, Claude Code's StatusLine may occasionally report usage metrics (like context_window.current_usage, used_percentage, total_input_tokens, and total_output_tokens) as 0. Because ccstatusline prioritizes these fields, the progress bar may incorrectly show 0 even if real usage data exists in the transcript.

    Since hello2cc cannot automatically override the existing statusLine.command via plugins, you must manually update your Claude Code settings to use the hello2cc bridge command. This bridge intercepts the JSON sent to StatusLine, aggregates usage from the main session and subagent transcripts via transcript_path, and fills in missing or zeroed usage data before passing it to ccstatusline.

    {
      "statusLine": {
        "type": "command",
        "command": "node "D:/GitHub/dev/hello2cc/scripts/ccstatusline-bridge.mjs""
      }
    }
  8. Customize the ccstatusline bridge command

    main

    You can customize which downstream command the bridge uses to render the status line. By default, the bridge uses npx -y ccstatusline@latest.

    To use a different downstream command (for example, bunx), append it to the bridge script path in your statusLine.command configuration, or use the HELLO2CC_CCSTATUSLINE_COMMAND environment variable.

    // Example: Appending bunx to the bridge command
    {
      "statusLine": {
        "type": "command",
        "command": "node "D:/GitHub/dev/hello2cc/scripts/ccstatusline-bridge.mjs" bunx ccstatusline@latest"
      }
    }
    # Example: Using an environment variable
    HELLO2CC_CCSTATUSLINE_COMMAND="bunx ccstatusline@latest"
  9. Install hello2cc as a Claude Code plugin

    main

    To use hello2cc to make third-party models (GPT, DeepSeek, Gemini, etc.) behave more like native Claude Opus sessions within Claude Code, follow these steps:

    1. Prerequisites:

      • Node.js 18 or later.
      • Claude Code with plugin support.
      • A working third-party model mapping layer (e.g., CCSwitch).
    2. Installation:

      • Clone the repository and enter the directory:
        git clone https://github.com/hellowind777/hello2cc.git
        cd hello2cc
      • Add the local marketplace entry (replace <repo-path> with your actual local path):
        claude plugins marketplace add "<repo-path>"
      • Install and enable the plugin:
        claude plugins install hello2cc@hello2cc-local
        claude plugins enable hello2cc@hello2cc-local
      • Reload Claude Code to apply changes:
        /reload-plugins
    3. Verification: Run claude plugins list to ensure hello2cc@hello2cc-local is installed and enabled.

    git clone https://github.com/hellowind777/hello2cc.git
    cd hello2cc
    claude plugins marketplace add "$(pwd)"
    claude plugins install hello2cc@hello2cc-local
    claude plugins enable hello2cc@hello2cc-local
    /reload-plugins
  10. Bridge ccstatusline usage statistics

    main

    If Claude Code reports 0 usage in the status line while using a third-party model, you can use a bridging script to backfill statistics from the transcript.

    Refer to docs/ccstatusline.md for the specific bridging commands. The script supports agentId, agent_id, and agent.id and only performs backfilling when the context_window field is missing or zero.

  11. Use the hello2cc Native output style

    main

    The hello2cc Native style is designed for users who want to maintain a native workflow within Claude Code. It prioritizes native tools, native agent/planning behaviors, and table-friendly outputs. It is an execution-first style that avoids unnecessary ceremony, self-referential narration, and over-guidance.

    Key Principles

    • Execution-First: Keep interactions restrained and focus on results. Avoid "I'm thinking" or "Let's..." preambles.
    • Scope Adherence: Stay within the requested scope. Do not refactor unrelated code or invent future-facing abstractions.
    • Directness: Answer questions directly. Avoid front-loading replies with long procedural narration. Answer first, then add necessary details.
    • No Invitational Filler: Do not end responses with phrases like "if you want, I can..." or "let me know if...". Instead, end with the result, current status, a blocker, or a concrete next action.
    • Faithful Reporting: Report outcomes accurately. If a validation step wasn't run or a check failed, state it plainly.

    Formatting Preferences

    • Tables: For comparisons, trade-offs, or capability boundaries, use the pattern: one-sentence judgment + compact Markdown table + recommendation.
    • Markdown Tables: Prefer standard Markdown tables over ASCII tables or diagrams unless Markdown is insufficient or plain text is explicitly requested.
    • Conciseness: Use concise, natural, and accurate wording. Avoid jargon-heavy phrasing, sales tones, or empty intensifiers.
  12. Install and setup hello2cc

    main

    hello2cc is a plugin for Claude Code designed to align the behavior of third-party models (like GPT, DeepSeek, Gemini, etc.) with Claude Code's native Opus session patterns. It improves tool selection, agent routing, and output style.

    Prerequisites

    • Node.js 18 or higher
    • A version of Claude Code that supports plugins
    • A model mapping layer (like CCSwitch) if you are not using native Claude models.

    Installation Steps

    1. Clone the repository:
      git clone https://github.com/hellowind777/hello2cc.git
      cd hello2cc
    2. Add the local marketplace: Replace <repo-path> with the absolute path to your cloned hello2cc directory.
      claude plugins marketplace add "<repo-path>"
    3. Install and enable the plugin:
      claude plugins install hello2cc@hello2cc-local
      claude plugins enable hello2cc@hello2cc-local
    4. Reload plugins:
      /reload-plugins

    Verification

    Run the following command to ensure the plugin is active:

    claude plugins list

    Expected result: hello2cc@hello2cc-local should be listed with a status of enabled.

    git clone https://github.com/hellowind777/hello2cc.git
    cd hello2cc
    claude plugins marketplace add "<repo-path>"
    claude plugins install hello2cc@hello2cc-local
    claude plugins enable hello2cc@hello2cc-local
    /reload-plugins