ctx-cloud-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseContext Mode Cloud Setup
Context Mode Cloud 配置指南
Interactive onboarding flow to connect this plugin to Context Mode Cloud.
用于将此插件连接至Context Mode Cloud的交互式入门流程。
Instructions
操作步骤
-
Check existing config — readusing Bash:
~/.context-mode/sync.jsoncat ~/.context-mode/sync.json 2>/dev/null || echo "NOT_FOUND"- If the file exists and contains a non-empty , inform the user that cloud sync is already configured and show the current
api_tokenandapi_url(never reveal the token — show only the last 4 characters masked asorganization_id).ctx_****abcd - Ask if they want to reconfigure or keep the current settings. If they want to keep, stop here.
- If the file exists and contains a non-empty
-
Collect configuration — ask the user for three values, one at a time:a) API URL
- Default:
https://api.context-mode.com - Tell the user: "Press Enter to use the default, or paste your self-hosted API URL."
- If the user says "default", use .
https://api.context-mode.com
b) API Token- Tell the user: "Paste your API token from the Context Mode dashboard: Settings > API Tokens."
- This field is required — do not proceed without it.
- Validate format: token should start with and be at least 20 characters. If invalid, warn and ask again.
ctx_
c) Organization ID- Tell the user: "Paste your Organization ID from the dashboard: Settings > Team."
- This field is required — do not proceed without it.
- Default:
-
Save config — write the merged config tousing Bash:
~/.context-mode/sync.jsonbashmkdir -p ~/.context-mode cat > ~/.context-mode/sync.json << 'JSONEOF' { "enabled": true, "api_url": "<API_URL>", "api_token": "<API_TOKEN>", "organization_id": "<ORG_ID>", "batch_size": 50, "flush_interval_ms": 30000 } JSONEOF chmod 600 ~/.context-mode/sync.jsonReplace,<API_URL>, and<API_TOKEN>with the collected values.<ORG_ID> -
Test the connection — send a health check using Bash:bash
curl -sf -o /dev/null -w "%{http_code}" \ -H "Authorization: Bearer <API_TOKEN>" \ "<API_URL>/api/health"- = success
200 - Any other code or failure = connection error
-
Display results as markdown directly in the conversation:On success:
## context-mode cloud setup - [x] Config saved to ~/.context-mode/sync.json - [x] Connection test: PASS (200 OK) - [x] Organization: <ORG_ID> Cloud sync is now active. Events will be sent to the dashboard on your next Claude Code session. Run `/ctx-cloud-status` to check sync health at any time.On failure:## context-mode cloud setup - [x] Config saved to ~/.context-mode/sync.json - [ ] Connection test: FAIL (<error details>) Config was saved but the connection test failed. Check that: 1. Your API URL is reachable 2. Your API token is valid and not expired 3. Your network allows outbound HTTPS Run `/ctx-cloud-setup` again to reconfigure.
-
检查现有配置 — 使用Bash读取文件:
~/.context-mode/sync.jsoncat ~/.context-mode/sync.json 2>/dev/null || echo "NOT_FOUND"- 如果文件已存在且包含非空的,告知用户云同步已完成配置,并显示当前的
api_token和api_url(绝对不可泄露完整令牌——仅显示最后4位,格式如organization_id)。ctx_****abcd - 询问用户是否需要重新配置或保留当前设置。若用户选择保留,流程到此结束。
- 如果文件已存在且包含非空的
-
收集配置信息 — 分三次向用户请求以下三个值:a) API URL
- 默认值:
https://api.context-mode.com - 告知用户:“按回车键使用默认值,或粘贴您的自托管API URL。”
- 若用户输入“default”,则使用。
https://api.context-mode.com
b) API 令牌- 告知用户:“从Context Mode控制面板粘贴您的API令牌:设置 > API令牌。”
- 此字段为必填项 — 未获取到令牌则不继续流程。
- 格式验证:令牌需以开头且长度至少为20字符。若格式无效,发出警告并重新请求。
ctx_
c) 组织ID- 告知用户:“从控制面板粘贴您的组织ID:设置 > 团队。”
- 此字段为必填项 — 未获取到组织ID则不继续流程。
- 默认值:
-
保存配置 — 使用Bash将合并后的配置写入文件:
~/.context-mode/sync.jsonbashmkdir -p ~/.context-mode cat > ~/.context-mode/sync.json << 'JSONEOF' { "enabled": true, "api_url": "<API_URL>", "api_token": "<API_TOKEN>", "organization_id": "<ORG_ID>", "batch_size": 50, "flush_interval_ms": 30000 } JSONEOF chmod 600 ~/.context-mode/sync.json将、<API_URL>和<API_TOKEN>替换为收集到的对应值。<ORG_ID> -
测试连接 — 使用Bash发送健康检查请求:bash
curl -sf -o /dev/null -w "%{http_code}" \ -H "Authorization: Bearer <API_TOKEN>" \ "<API_URL>/api/health"- 返回= 连接成功
200 - 其他状态码或请求失败 = 连接错误
- 返回
-
展示结果 — 直接在对话中以markdown格式显示:连接成功时:
## context-mode cloud 配置结果 - [x] 配置已保存至~/.context-mode/sync.json - [x] 连接测试:通过(200 OK) - [x] 组织:<ORG_ID> 云同步现已激活。在您的下一次Claude Code会话中,事件将被发送至控制面板。随时运行`/ctx-cloud-status`命令检查同步健康状态。连接失败时:## context-mode cloud 配置结果 - [x] 配置已保存至~/.context-mode/sync.json - [ ] 连接测试:失败(<错误详情>) 配置已保存但连接测试失败。请检查: 1. 您的API URL是否可访问 2. 您的API令牌是否有效且未过期 3. 您的网络是否允许HTTPS出站请求 重新运行`/ctx-cloud-setup`命令进行重新配置。
Security Notes
安全注意事项
- Never log or display the full API token. Always mask it.
- Set file permissions to (owner read/write only).
600 - The token is sent only over HTTPS in the header.
Authorization
- 绝不要记录或显示完整的API令牌,始终对其进行掩码处理。
- 将文件权限设置为(仅所有者可读写)。
600 - 令牌仅通过HTTPS在请求头中传输。
Authorization