Claude Code plugin for copilot-proxy — injects session rules, subagent markers for x-initiator agent detection, and prompt hooks
copilot-proxy 的 Claude Code 插件 — 通过注入 subagent 标记,帮助 copilot-proxy 正确设置 x-initiator: agent,减少 Premium Request 消耗。
GitHub Copilot 根据 X-Initiator 请求头计费:
x-initiator: user → 消耗 1 个 Premium Requestx-initiator: agent → 免费(不扣配额)当 Claude Code 创建子代理(如并行工具调用)时,copilot-proxy 需要知道该请求来自代理而非用户。本插件会在子代理请求的首条用户消息中注入 __SUBAGENT_MARKER__,copilot-proxy 检测到后自动设置 x-initiator: agent。
# 1. 添加 marketplace
/plugin marketplace add ilovechuanchuan-star/cc-plugin
# 2. 从 marketplace 安装插件
/plugin install copilot-proxy-plugin@cc-plugin-marketplace
/plugin install ilovechuanchuan-star/cc-plugin
claude plugin list
输出中应包含 copilot-proxy-plugin。
| Hook | 脚本 | 用途 |
|---|---|---|
| SessionStart | session-start-rules.js | 注入可选的会话规则(通过环境变量控制) |
| SubagentStart | subagent-start-marker.js | 向子代理上下文注入 __SUBAGENT_MARKER__ 及会话/代理元数据 |
| UserPromptSubmit | user-prompt-submit-reminder.js | 占位 Hook(直通,预留扩展) |
当 Claude Code 创建子代理时,插件会注入如下标记:
__SUBAGENT_MARKER__{"session_id":"...","agent_id":"...","agent_type":"..."}
该标记嵌入在首条用户消息的 <system-reminder> 块中。copilot-proxy 的 parseSubagentMarkerFromFirstUser() 检测到后,设置 x-initiator: agent,从而节省 Premium Request 配额。
可通过环境变量启用额外的会话规则:
| 变量 | 效果 |
|---|---|
CLAUDE_PLUGIN_ENABLE_QUESTION_RULES=1 | 强制使用提问工具,禁止直接向用户提问 |
CLAUDE_PLUGIN_ENABLE_NO_BACKGROUND_AGENTS_RULE=1 | 禁止 Agent 工具的 run_in_background: true(避免代理延迟错误) |
cc-plugin/
├── .claude-plugin/
│ ├── marketplace.json # Marketplace 元数据
│ └── plugin.json # 插件身份与版本
├── hooks/
│ └── hooks.json # Hook 事件 → 脚本映射
├── scripts/
│ ├── session-start-rules.js # SessionStart: 注入规则
│ ├── subagent-start-marker.js # SubagentStart: 注入标记
│ └── user-prompt-submit-reminder.js # UserPromptSubmit: 直通
└── README.md
__SUBAGENT_MARKER__(修复新 session 启动时 CLAUDE.md / SessionStart hook 上下文被误判为 user 的问题);修复 SubagentStart marker 缺失 <system-reminder> 包装导致 copilot-proxy 无法识别的 bugOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
npx claudepluginhub ilovechuanchuan-star/cc-plugin --plugin copilot-proxy-pluginInject SubagentStart marker context for copilot-api initiator override.
Meta-tools for Claude Code configuration and customization
Syncs all AGENTS.md files to CLAUDE.md (recursively) and adds CLAUDE.md to .gitignore. Useful when your tooling uses AGENTS.md but Claude Code reads CLAUDE.md.
Easily create hooks to prevent unwanted behaviors by analyzing conversation patterns
Ultra-compressed communication mode. Cuts 65% of output tokens (measured) while keeping full technical accuracy by speaking like a caveman.
Memory compression system for Claude Code - persist context across sessions