Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ Rules that should stay true:
| `internal/validate` | Shared validation helpers for names and header values |
| `internal/utils` | Small reusable helpers such as CSV parsing |
| `internal/auth` | OAuth device-flow placeholder |
| `internal/mcpclient` | MCP configuration, server-local auth, SDK sessions, bounded discovery and lossless arguments/results |
| `internal/update` | Self-update implementation |

### `cmd/*`
Expand All @@ -121,6 +122,7 @@ Rules that should stay true:
| `cmd/root.go` | Root command, global flags, shared wiring |
| `cmd/auth` | `auth login/status/check/logout` |
| `cmd/api` | Raw API command |
| `cmd/mcp` | Independent MCP discovery, help, invocation and offline preview |
| `cmd/context` | Context lifecycle commands |
| `cmd/doctor.go` | Root-level environment diagnostics command |
| `cmd/update` | Self-update command |
Expand All @@ -137,6 +139,7 @@ Rules that should stay true:
- `context`
- `doctor`
- `help`
- `mcp`
- `update`
- `version`
- registered public systems via `cmd/system/register.go`
Expand Down Expand Up @@ -313,10 +316,14 @@ When a Go-implemented action supports both named flags and raw `--body`, treat `

## Final result projection

`api` and public system actions register `output.AddJQFlag(cmd)` locally. Go actions inherit it through `AddCommonRequestFlags` / `AddCommonRequestFlagsWithoutBody`; YAML actions register it in their builder. `jq` is reserved for generated flags.
`api`, `mcp`, and public system actions register `output.AddJQFlag(cmd)` locally. Go actions inherit it through `AddCommonRequestFlags` / `AddCommonRequestFlagsWithoutBody`; YAML actions register it in their builder. `jq` is reserved for generated flags.

Write final request results through `output.WriteCommandEnvelope(cmd, env)`, after any result checks, redaction, response mutation, or pagination aggregation. Keep intermediate requests in the shared request layer without projecting them. The output helper compiles during flag parsing, buffers JSON Lines with finite execution/output budgets, bypasses failed envelopes, and preserves completed request results on projection failures. Keep unsupported commands explicit instead of adding a root flag that can be silently ignored. Detailed semantics are defined in `docs/design.md`.

## MCP command boundary

`cmd/mcp` is a root command, not a public system. `--list` reads local configuration only and masks all header values. Header values are literal and never expanded from environment variables. Remote operations use only the selected `mcp.json` server headers and never resolve gateway context, credentials, stage or tenant. Keep SDK negotiation/session ownership in `internal/mcpclient`, preserve raw JSON numbers at the HTTP boundary, and never replay `tools/call`. See `docs/design.md` section 5.8 for version, resource-limit and result-state contracts. Keep MCP integration cases in `tests/integration/cases/mcp/` and user guidance in `skills/bk-cli-mcp/SKILL.md`.

## Runtime, auth, and request behavior

Detailed shared request-contract rules live in `docs/design.md`. When you add or change request behavior, treat `docs/design.md` as the source of truth for:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
- **多上下文支持**: 管理多个 BlueKing 部署的凭据
- **环境自检**: 使用 `bk-cli doctor` 检查 context、凭据、URL 渲染和网关连通性,凭据值脱敏显示
- **自动化友好的输出**: 带 `ok` 字段的 JSON 信封、机器可读错误、可预测的退出码;API 响应保留 JSON 数字精度
- **内置结果筛选**: `api` 和 system action 支持 `--jq '<表达式>'`,以完整最终 envelope 为输入,每个结果输出一行 JSON;无需安装外部 jq
- **内置结果筛选**: `api`、`mcp` 和 system action 支持 `--jq '<表达式>'`,以完整最终 envelope 为输入,每个结果输出一行 JSON;无需安装外部 jq
- **灵活请求体输入**: `--body` 支持内联 JSON、`@file` 文件读取和 stdin 输入
- **丰富的系统命令**: 内置多个 BlueKing system 子命令,也保留原始 `api` 调用作为兜底能力
- **内置 Agent Skills**: 可通过 `bk-cli skills list` 和 `bk-cli skills read <name>` 查看随当前版本打包的使用指引,`skills read --raw` 可输出原始 Markdown
- **个人 token 登录**: `bk-cli auth login --personal_token='<personal-token>'`,使用个人中心生成的 token 调用支持 Bearer 鉴权的 API
- **加密凭据存储**: 每个上下文使用 AES-256-GCM 加密
- **单一二进制文件**: 无运行时依赖
- **远程 MCP 工具**: 基于独立 `mcp.json` 配置连接 Streamable HTTP 服务,支持服务列表、连接检查、工具发现、动态帮助、工具调用和离线预览

## 快速开始

Expand Down
3 changes: 2 additions & 1 deletion README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ For the full design contract, see [docs/design.md](docs/design.md).
- **Multi-context support**: manage credentials for multiple BlueKing deployments
- **Environment diagnostics**: use `bk-cli doctor` to check contexts, credentials, URL rendering, and gateway connectivity, with credential values masked
- **Automation-friendly output**: JSON envelopes with an `ok` field, machine-readable errors, and predictable exit codes; API responses preserve JSON number precision
- **Built-in result filtering**: `api` and system actions accept `--jq '<expression>'` over the complete final envelope, emitting one JSON value per line without an external jq installation
- **Built-in result filtering**: `api`, `mcp`, and system actions accept `--jq '<expression>'` over the complete final envelope, emitting one JSON value per line without an external jq installation
- **Flexible request body input**: `--body` supports inline JSON, `@file` file reads, and stdin
- **Rich system commands**: built-in BlueKing system subcommands, with raw `api` calls kept as a fallback
- **Embedded agent skills**: inspect version-matched usage guidance with `bk-cli skills list` and `bk-cli skills read <name>`; use `skills read --raw` for raw Markdown
- **Personal token login**: `bk-cli auth login --personal_token='<personal-token>'` uses a token from the personal center to call APIs that support Bearer authentication
- **Encrypted credential storage**: AES-256-GCM encryption per context
- **Single binary**: with no runtime dependencies
- **Remote MCP tools**: Connect to Streamable HTTP services using a separate `mcp.json`, with configured server listing, connection checks, tool discovery, dynamic help, tool calls, and offline previews

## Quick Start

Expand Down
Loading
Loading