Agent-native MaxCompute CLI for external coding agents
Project description
maxc-cli
maxc-cli 是一个面向外部 Agent 的 MaxCompute 工具层。它不是 Agent 本身,而是给 Codex、Claude Code、Cursor 或自研 Agent 调用的结构化 CLI。
当前工作树以真实 MaxCompute 为目标。连接信息可以来自环境变量,也可以通过 maxc auth login 持久化到本地配置文件。缺少认证时,CLI 会返回结构化引导信息,不再回退到运行时 mock catalog。
文档入口
docs/design.md产品定位、命令体系和 skill/source 布局docs/implementation.md当前代码的真实行为和输出契约docs/product-positioning.md为什么当前应先把maxc-cli做成工具层docs/roadmap.md当前路线图和发布后续项skills/use-maxc-cli/仓库内 versioned 的 Codex skill source
当前能力
- 统一的 Agent-Native JSON envelope
auth / session / query / job / meta / data / diff / cache / agent contextauth login、auth whoami、auth can-isession set/show/unsetquery cost、query explain、分页--page-size/--cursormeta search-columns、richermeta describe、meta latest-partition、meta freshnessmeta lineage对真实 backend 明确返回supported=false占位契约data sample --partition --columns --rowsdata profile --partitiondiff schema、diff partition、diff data- SQLite 本地缓存、结构化审计日志、语义元数据缓存
- 仓库内置
skills/use-maxc-cli/skill source 与同步脚本scripts/sync_codex_skill.py
安装
仓库内开发安装:
python -m pip install -e .
发布后安装:
python -m pip install maxc-cli
当前打包元数据支持 Python 3.6 到 3.12。
基础依赖已经包含:
pyodpsPyYAML- Python 3.6 下的
dataclassesbackport
按需依赖:
pandas某些包含 TIMESTAMP-like 类型的结果集读取路径可能需要它,但它不是安装maxc-cli的直接前置依赖
Codex Skill
仓库内 skills/use-maxc-cli/ 是 canonical source。将它同步到本机 Codex skill 目录:
python scripts/sync_codex_skill.py
默认目标目录是:
~/.codex/skills/use-maxc-cli
登录与 Bootstrap
建议的最短接入路径:
maxc auth whoami --json
maxc auth login --from-env --json
maxc auth whoami --json
maxc cache build --json
maxc meta list-tables --json
如果当前 shell 已经有 MaxCompute 环境变量,可以直接持久化:
maxc auth login --from-env --json
显式传参登录:
maxc auth login \
--access-id "<access_key_id>" \
--secret-access-key "<access_key_secret>" \
--project "<project>" \
--endpoint "http://service.<region>.maxcompute.aliyun.com/api" \
--region "<region>" \
--json
auth whoami --json 的重点字段在 data.identity:
authenticatedconfiguredvalidation_statusidentity_sourceproject
如果 authenticated=false,继续查看 data.auth_options 获取推荐登录动作。
默认配置发现顺序:
~/.maxc/config.yaml
./.maxc/config.yaml
./.maxc.yaml
./.maxc
项目和 schema 的会话覆盖保存在:
~/.maxc/session_override.yaml
快速运行
maxc auth whoami --json
maxc agent context --json
maxc session show --json
maxc cache build --json
maxc meta list-tables --json
maxc meta search-columns "id" --json
maxc meta describe your_table --json
maxc meta latest-partition your_table --json
maxc meta freshness your_table --json
maxc meta lineage your_table --json
maxc data sample your_table --partition ds=2026-03-20 --columns id,ds --rows 5 --json
maxc data profile your_table --partition ds=2026-03-20 --json
maxc query "SELECT 1 AS one" --json
maxc query cost "SELECT 1 AS one" --json
maxc query explain "SELECT 1 AS one" --json
maxc job submit "SELECT 1 AS one" --json
maxc job wait job_xxx --stream
maxc diff schema left_table right_table --json
maxc diff partition left_table right_table --json
maxc diff data left_table right_table --keys id --columns value_col --rows 100 --json
maxc cache status --json
maxc cache build-status --build-id build_xxx --json
cache build --json 行为
stdout只输出单个最终 JSON envelopestderr持续输出进度文本,避免慢构建期间完全静默--async --json会立即返回build_id,随后用cache build-status --build-id <id> --json轮询
JSON 契约
所有 --json 命令都返回 envelope:
versioncommandcommand_idstatusdatametadataerroragent_hints
常用规范化 data 结构:
auth whoami->data.identityauth can-i->data.authorizationquery/job wait/job result->data.result和data.paginationquery cost/query explain->data.analysismeta describe->data.tablemeta search/meta search-columns->data.search.matchesdata sample->data.sampledata profile->data.profileagent context->data.context
当前限制
meta lineage还没有接真实血缘 API;真实 backend 会明确返回supported=false、coverage=unsupportedauth can-i当前只支持表级SELECT预检auth login会把 AccessKey 明文写入本地 YAML;CLI 会尽量把文件权限收敛到0600- 环境变量优先于配置文件;
session_override.yaml对 project/schema 的优先级高于两者 meta list-tables是 cache-backed;冷启动时需要先执行cache builddiff data当前是 keyed snapshot compare:每侧最多读取--rows行,不是全表 exhaustive diff- 真实 backend 目前不提供统一 CU 口径成本,因此
--cost-check在真实 backend 上不可用 - 真实 backend 的
query explain / query cost当前基于execute_sql_cost和结构化 query outline,不是完整优化器执行计划树 --cursor当前是 CLI 侧 offset token,不是 MaxCompute 服务端游标
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file maxc_cli-0.1.2.tar.gz.
File metadata
- Download URL: maxc_cli-0.1.2.tar.gz
- Upload date:
- Size: 113.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21a89d96daadf7e114bc33172c382b2098bd625c8501a72ca25bf1b6104b6a08
|
|
| MD5 |
3d6ddd41f36469d9589c8103930c61d7
|
|
| BLAKE2b-256 |
f2c3473eb8b7276322235580a1129e2aba44d26a0295f756c819c6ed70bd3222
|
File details
Details for the file maxc_cli-0.1.2-py3-none-any.whl.
File metadata
- Download URL: maxc_cli-0.1.2-py3-none-any.whl
- Upload date:
- Size: 81.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
495057ad0bca176442ab2ba55ccdd54ff9cec7ad278171e0c0d43d0533b7d697
|
|
| MD5 |
ff2a31f76339127f06f0f2423a66a3c8
|
|
| BLAKE2b-256 |
c12c4ab56168c79d3b7bf3128597b1a6786ae6b3fbd596a9914ff0a13238ef45
|