maxc-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maxc_cli-0.1.0/MANIFEST.in +2 -0
- maxc_cli-0.1.0/PKG-INFO +220 -0
- maxc_cli-0.1.0/README.md +199 -0
- maxc_cli-0.1.0/pyproject.toml +7 -0
- maxc_cli-0.1.0/scripts/sync_codex_skill.py +68 -0
- maxc_cli-0.1.0/setup.cfg +4 -0
- maxc_cli-0.1.0/setup.py +37 -0
- maxc_cli-0.1.0/skills/use-maxc-cli/SKILL.md +220 -0
- maxc_cli-0.1.0/skills/use-maxc-cli/agents/openai.yaml +4 -0
- maxc_cli-0.1.0/skills/use-maxc-cli/references/bootstrap-auth.md +278 -0
- maxc_cli-0.1.0/skills/use-maxc-cli/references/command-patterns.md +262 -0
- maxc_cli-0.1.0/skills/use-maxc-cli/references/setup-install.md +98 -0
- maxc_cli-0.1.0/src/maxc_cli/__init__.py +5 -0
- maxc_cli-0.1.0/src/maxc_cli/__main__.py +6 -0
- maxc_cli-0.1.0/src/maxc_cli/app.py +3406 -0
- maxc_cli-0.1.0/src/maxc_cli/audit.py +18 -0
- maxc_cli-0.1.0/src/maxc_cli/auth_providers.py +471 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/__init__.py +8 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/auth.py +144 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/data.py +87 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/job.py +304 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/meta.py +312 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/odps.py +130 -0
- maxc_cli-0.1.0/src/maxc_cli/backend/query.py +148 -0
- maxc_cli-0.1.0/src/maxc_cli/cache.py +662 -0
- maxc_cli-0.1.0/src/maxc_cli/cli.py +1274 -0
- maxc_cli-0.1.0/src/maxc_cli/config.py +406 -0
- maxc_cli-0.1.0/src/maxc_cli/exceptions.py +99 -0
- maxc_cli-0.1.0/src/maxc_cli/helpers.py +964 -0
- maxc_cli-0.1.0/src/maxc_cli/models.py +533 -0
- maxc_cli-0.1.0/src/maxc_cli/output.py +75 -0
- maxc_cli-0.1.0/src/maxc_cli/store.py +123 -0
- maxc_cli-0.1.0/src/maxc_cli/utils.py +136 -0
- maxc_cli-0.1.0/src/maxc_cli.egg-info/PKG-INFO +220 -0
- maxc_cli-0.1.0/src/maxc_cli.egg-info/SOURCES.txt +46 -0
- maxc_cli-0.1.0/src/maxc_cli.egg-info/dependency_links.txt +1 -0
- maxc_cli-0.1.0/src/maxc_cli.egg-info/entry_points.txt +2 -0
- maxc_cli-0.1.0/src/maxc_cli.egg-info/requires.txt +2 -0
- maxc_cli-0.1.0/src/maxc_cli.egg-info/top_level.txt +1 -0
- maxc_cli-0.1.0/tests/test_agent_hints_and_cli.py +319 -0
- maxc_cli-0.1.0/tests/test_cache.py +120 -0
- maxc_cli-0.1.0/tests/test_cli_mock.py +1209 -0
- maxc_cli-0.1.0/tests/test_compat.py +36 -0
- maxc_cli-0.1.0/tests/test_e2e_smoke.py +110 -0
- maxc_cli-0.1.0/tests/test_integration.py +124 -0
- maxc_cli-0.1.0/tests/test_integration_real.py +756 -0
- maxc_cli-0.1.0/tests/test_job_improvements.py +323 -0
- maxc_cli-0.1.0/tests/test_query_auto_promote.py +228 -0
maxc_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: maxc-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Agent-native MaxCompute CLI for external coding agents
|
|
5
|
+
Classifier: Programming Language :: Python :: 3
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Requires-Python: >=3.8,<3.13
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: PyYAML>=5.4
|
|
14
|
+
Requires-Dist: pyodps
|
|
15
|
+
Dynamic: classifier
|
|
16
|
+
Dynamic: description
|
|
17
|
+
Dynamic: description-content-type
|
|
18
|
+
Dynamic: requires-dist
|
|
19
|
+
Dynamic: requires-python
|
|
20
|
+
Dynamic: summary
|
|
21
|
+
|
|
22
|
+
# maxc-cli
|
|
23
|
+
|
|
24
|
+
`maxc-cli` 是一个面向外部 Agent 的 MaxCompute 工具层。它不是 Agent 本身,而是给 Codex、Claude Code、Cursor 或自研 Agent 调用的结构化 CLI。
|
|
25
|
+
|
|
26
|
+
当前工作树以真实 MaxCompute 为目标。连接信息可以来自环境变量,也可以通过 `maxc auth login` 持久化到本地配置文件。缺少认证时,CLI 会返回结构化引导信息,不再回退到运行时 mock catalog。
|
|
27
|
+
|
|
28
|
+
## 文档入口
|
|
29
|
+
|
|
30
|
+
- `docs/design.md`
|
|
31
|
+
产品定位、命令体系和 skill/source 布局
|
|
32
|
+
- `docs/implementation.md`
|
|
33
|
+
当前代码的真实行为和输出契约
|
|
34
|
+
- `docs/product-positioning.md`
|
|
35
|
+
为什么当前应先把 `maxc-cli` 做成工具层
|
|
36
|
+
- `docs/roadmap.md`
|
|
37
|
+
当前路线图和发布后续项
|
|
38
|
+
- `skills/use-maxc-cli/`
|
|
39
|
+
仓库内 versioned 的 Codex skill source
|
|
40
|
+
|
|
41
|
+
## 当前能力
|
|
42
|
+
|
|
43
|
+
- 统一的 Agent-Native JSON envelope
|
|
44
|
+
- `auth / session / query / job / meta / data / diff / cache / agent context`
|
|
45
|
+
- `auth login`、`auth whoami`、`auth can-i`
|
|
46
|
+
- `session set/show/unset`
|
|
47
|
+
- `query cost`、`query explain`、分页 `--page-size` / `--cursor`
|
|
48
|
+
- `meta search-columns`、richer `meta describe`、`meta latest-partition`、`meta freshness`
|
|
49
|
+
- `meta lineage` 对真实 backend 明确返回 `supported=false` 占位契约
|
|
50
|
+
- `data sample --partition --columns --rows`
|
|
51
|
+
- `data profile --partition`
|
|
52
|
+
- `diff schema`、`diff partition`、`diff data`
|
|
53
|
+
- SQLite 本地缓存、结构化审计日志、语义元数据缓存
|
|
54
|
+
- 仓库内置 `skills/use-maxc-cli/` skill source 与同步脚本 `scripts/sync_codex_skill.py`
|
|
55
|
+
|
|
56
|
+
## 安装
|
|
57
|
+
|
|
58
|
+
仓库内开发安装:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
python -m pip install -e .
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
发布后安装:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python -m pip install maxc-cli
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
当前打包元数据支持 Python `3.6` 到 `3.12`。
|
|
71
|
+
|
|
72
|
+
基础依赖已经包含:
|
|
73
|
+
|
|
74
|
+
- `pyodps`
|
|
75
|
+
- `PyYAML`
|
|
76
|
+
- Python 3.6 下的 `dataclasses` backport
|
|
77
|
+
|
|
78
|
+
按需依赖:
|
|
79
|
+
|
|
80
|
+
- `pandas`
|
|
81
|
+
某些包含 TIMESTAMP-like 类型的结果集读取路径可能需要它,但它不是安装 `maxc-cli` 的直接前置依赖
|
|
82
|
+
|
|
83
|
+
## Codex Skill
|
|
84
|
+
|
|
85
|
+
仓库内 `skills/use-maxc-cli/` 是 canonical source。将它同步到本机 Codex skill 目录:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
python scripts/sync_codex_skill.py
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
默认目标目录是:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
~/.codex/skills/use-maxc-cli
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 登录与 Bootstrap
|
|
98
|
+
|
|
99
|
+
建议的最短接入路径:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
maxc auth whoami --json
|
|
103
|
+
maxc auth login --from-env --json
|
|
104
|
+
maxc auth whoami --json
|
|
105
|
+
maxc cache build --json
|
|
106
|
+
maxc meta list-tables --json
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
如果当前 shell 已经有 MaxCompute 环境变量,可以直接持久化:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
maxc auth login --from-env --json
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
显式传参登录:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
maxc auth login \
|
|
119
|
+
--access-id "<access_key_id>" \
|
|
120
|
+
--secret-access-key "<access_key_secret>" \
|
|
121
|
+
--project "<project>" \
|
|
122
|
+
--endpoint "http://service.<region>.maxcompute.aliyun.com/api" \
|
|
123
|
+
--region "<region>" \
|
|
124
|
+
--json
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`auth whoami --json` 的重点字段在 `data.identity`:
|
|
128
|
+
|
|
129
|
+
- `authenticated`
|
|
130
|
+
- `configured`
|
|
131
|
+
- `validation_status`
|
|
132
|
+
- `identity_source`
|
|
133
|
+
- `project`
|
|
134
|
+
|
|
135
|
+
如果 `authenticated=false`,继续查看 `data.auth_options` 获取推荐登录动作。
|
|
136
|
+
|
|
137
|
+
默认配置发现顺序:
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
~/.maxc/config.yaml
|
|
141
|
+
./.maxc/config.yaml
|
|
142
|
+
./.maxc.yaml
|
|
143
|
+
./.maxc
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
项目和 schema 的会话覆盖保存在:
|
|
147
|
+
|
|
148
|
+
```text
|
|
149
|
+
~/.maxc/session_override.yaml
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## 快速运行
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
maxc auth whoami --json
|
|
156
|
+
maxc agent context --json
|
|
157
|
+
maxc session show --json
|
|
158
|
+
maxc cache build --json
|
|
159
|
+
maxc meta list-tables --json
|
|
160
|
+
maxc meta search-columns "id" --json
|
|
161
|
+
maxc meta describe your_table --json
|
|
162
|
+
maxc meta latest-partition your_table --json
|
|
163
|
+
maxc meta freshness your_table --json
|
|
164
|
+
maxc meta lineage your_table --json
|
|
165
|
+
maxc data sample your_table --partition ds=2026-03-20 --columns id,ds --rows 5 --json
|
|
166
|
+
maxc data profile your_table --partition ds=2026-03-20 --json
|
|
167
|
+
maxc query "SELECT 1 AS one" --json
|
|
168
|
+
maxc query cost "SELECT 1 AS one" --json
|
|
169
|
+
maxc query explain "SELECT 1 AS one" --json
|
|
170
|
+
maxc job submit "SELECT 1 AS one" --json
|
|
171
|
+
maxc job wait job_xxx --stream
|
|
172
|
+
maxc diff schema left_table right_table --json
|
|
173
|
+
maxc diff partition left_table right_table --json
|
|
174
|
+
maxc diff data left_table right_table --keys id --columns value_col --rows 100 --json
|
|
175
|
+
maxc cache status --json
|
|
176
|
+
maxc cache build-status --build-id build_xxx --json
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## `cache build --json` 行为
|
|
180
|
+
|
|
181
|
+
- `stdout` 只输出单个最终 JSON envelope
|
|
182
|
+
- `stderr` 持续输出进度文本,避免慢构建期间完全静默
|
|
183
|
+
- `--async --json` 会立即返回 `build_id`,随后用 `cache build-status --build-id <id> --json` 轮询
|
|
184
|
+
|
|
185
|
+
## JSON 契约
|
|
186
|
+
|
|
187
|
+
所有 `--json` 命令都返回 envelope:
|
|
188
|
+
|
|
189
|
+
- `version`
|
|
190
|
+
- `command`
|
|
191
|
+
- `command_id`
|
|
192
|
+
- `status`
|
|
193
|
+
- `data`
|
|
194
|
+
- `metadata`
|
|
195
|
+
- `error`
|
|
196
|
+
- `agent_hints`
|
|
197
|
+
|
|
198
|
+
常用规范化 `data` 结构:
|
|
199
|
+
|
|
200
|
+
- `auth whoami` -> `data.identity`
|
|
201
|
+
- `auth can-i` -> `data.authorization`
|
|
202
|
+
- `query` / `job wait` / `job result` -> `data.result` 和 `data.pagination`
|
|
203
|
+
- `query cost` / `query explain` -> `data.analysis`
|
|
204
|
+
- `meta describe` -> `data.table`
|
|
205
|
+
- `meta search` / `meta search-columns` -> `data.search.matches`
|
|
206
|
+
- `data sample` -> `data.sample`
|
|
207
|
+
- `data profile` -> `data.profile`
|
|
208
|
+
- `agent context` -> `data.context`
|
|
209
|
+
|
|
210
|
+
## 当前限制
|
|
211
|
+
|
|
212
|
+
- `meta lineage` 还没有接真实血缘 API;真实 backend 会明确返回 `supported=false`、`coverage=unsupported`
|
|
213
|
+
- `auth can-i` 当前只支持表级 `SELECT` 预检
|
|
214
|
+
- `auth login` 会把 AccessKey 明文写入本地 YAML;CLI 会尽量把文件权限收敛到 `0600`
|
|
215
|
+
- 环境变量优先于配置文件;`session_override.yaml` 对 project/schema 的优先级高于两者
|
|
216
|
+
- `meta list-tables` 是 cache-backed;冷启动时需要先执行 `cache build`
|
|
217
|
+
- `diff data` 当前是 keyed snapshot compare:每侧最多读取 `--rows` 行,不是全表 exhaustive diff
|
|
218
|
+
- 真实 backend 目前不提供统一 CU 口径成本,因此 `--cost-check` 在真实 backend 上不可用
|
|
219
|
+
- 真实 backend 的 `query explain / query cost` 当前基于 `execute_sql_cost` 和结构化 query outline,不是完整优化器执行计划树
|
|
220
|
+
- `--cursor` 当前是 CLI 侧 offset token,不是 MaxCompute 服务端游标
|
maxc_cli-0.1.0/README.md
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# maxc-cli
|
|
2
|
+
|
|
3
|
+
`maxc-cli` 是一个面向外部 Agent 的 MaxCompute 工具层。它不是 Agent 本身,而是给 Codex、Claude Code、Cursor 或自研 Agent 调用的结构化 CLI。
|
|
4
|
+
|
|
5
|
+
当前工作树以真实 MaxCompute 为目标。连接信息可以来自环境变量,也可以通过 `maxc auth login` 持久化到本地配置文件。缺少认证时,CLI 会返回结构化引导信息,不再回退到运行时 mock catalog。
|
|
6
|
+
|
|
7
|
+
## 文档入口
|
|
8
|
+
|
|
9
|
+
- `docs/design.md`
|
|
10
|
+
产品定位、命令体系和 skill/source 布局
|
|
11
|
+
- `docs/implementation.md`
|
|
12
|
+
当前代码的真实行为和输出契约
|
|
13
|
+
- `docs/product-positioning.md`
|
|
14
|
+
为什么当前应先把 `maxc-cli` 做成工具层
|
|
15
|
+
- `docs/roadmap.md`
|
|
16
|
+
当前路线图和发布后续项
|
|
17
|
+
- `skills/use-maxc-cli/`
|
|
18
|
+
仓库内 versioned 的 Codex skill source
|
|
19
|
+
|
|
20
|
+
## 当前能力
|
|
21
|
+
|
|
22
|
+
- 统一的 Agent-Native JSON envelope
|
|
23
|
+
- `auth / session / query / job / meta / data / diff / cache / agent context`
|
|
24
|
+
- `auth login`、`auth whoami`、`auth can-i`
|
|
25
|
+
- `session set/show/unset`
|
|
26
|
+
- `query cost`、`query explain`、分页 `--page-size` / `--cursor`
|
|
27
|
+
- `meta search-columns`、richer `meta describe`、`meta latest-partition`、`meta freshness`
|
|
28
|
+
- `meta lineage` 对真实 backend 明确返回 `supported=false` 占位契约
|
|
29
|
+
- `data sample --partition --columns --rows`
|
|
30
|
+
- `data profile --partition`
|
|
31
|
+
- `diff schema`、`diff partition`、`diff data`
|
|
32
|
+
- SQLite 本地缓存、结构化审计日志、语义元数据缓存
|
|
33
|
+
- 仓库内置 `skills/use-maxc-cli/` skill source 与同步脚本 `scripts/sync_codex_skill.py`
|
|
34
|
+
|
|
35
|
+
## 安装
|
|
36
|
+
|
|
37
|
+
仓库内开发安装:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
python -m pip install -e .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
发布后安装:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
python -m pip install maxc-cli
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
当前打包元数据支持 Python `3.6` 到 `3.12`。
|
|
50
|
+
|
|
51
|
+
基础依赖已经包含:
|
|
52
|
+
|
|
53
|
+
- `pyodps`
|
|
54
|
+
- `PyYAML`
|
|
55
|
+
- Python 3.6 下的 `dataclasses` backport
|
|
56
|
+
|
|
57
|
+
按需依赖:
|
|
58
|
+
|
|
59
|
+
- `pandas`
|
|
60
|
+
某些包含 TIMESTAMP-like 类型的结果集读取路径可能需要它,但它不是安装 `maxc-cli` 的直接前置依赖
|
|
61
|
+
|
|
62
|
+
## Codex Skill
|
|
63
|
+
|
|
64
|
+
仓库内 `skills/use-maxc-cli/` 是 canonical source。将它同步到本机 Codex skill 目录:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python scripts/sync_codex_skill.py
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
默认目标目录是:
|
|
71
|
+
|
|
72
|
+
```text
|
|
73
|
+
~/.codex/skills/use-maxc-cli
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## 登录与 Bootstrap
|
|
77
|
+
|
|
78
|
+
建议的最短接入路径:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
maxc auth whoami --json
|
|
82
|
+
maxc auth login --from-env --json
|
|
83
|
+
maxc auth whoami --json
|
|
84
|
+
maxc cache build --json
|
|
85
|
+
maxc meta list-tables --json
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
如果当前 shell 已经有 MaxCompute 环境变量,可以直接持久化:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
maxc auth login --from-env --json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
显式传参登录:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
maxc auth login \
|
|
98
|
+
--access-id "<access_key_id>" \
|
|
99
|
+
--secret-access-key "<access_key_secret>" \
|
|
100
|
+
--project "<project>" \
|
|
101
|
+
--endpoint "http://service.<region>.maxcompute.aliyun.com/api" \
|
|
102
|
+
--region "<region>" \
|
|
103
|
+
--json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`auth whoami --json` 的重点字段在 `data.identity`:
|
|
107
|
+
|
|
108
|
+
- `authenticated`
|
|
109
|
+
- `configured`
|
|
110
|
+
- `validation_status`
|
|
111
|
+
- `identity_source`
|
|
112
|
+
- `project`
|
|
113
|
+
|
|
114
|
+
如果 `authenticated=false`,继续查看 `data.auth_options` 获取推荐登录动作。
|
|
115
|
+
|
|
116
|
+
默认配置发现顺序:
|
|
117
|
+
|
|
118
|
+
```text
|
|
119
|
+
~/.maxc/config.yaml
|
|
120
|
+
./.maxc/config.yaml
|
|
121
|
+
./.maxc.yaml
|
|
122
|
+
./.maxc
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
项目和 schema 的会话覆盖保存在:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
~/.maxc/session_override.yaml
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 快速运行
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
maxc auth whoami --json
|
|
135
|
+
maxc agent context --json
|
|
136
|
+
maxc session show --json
|
|
137
|
+
maxc cache build --json
|
|
138
|
+
maxc meta list-tables --json
|
|
139
|
+
maxc meta search-columns "id" --json
|
|
140
|
+
maxc meta describe your_table --json
|
|
141
|
+
maxc meta latest-partition your_table --json
|
|
142
|
+
maxc meta freshness your_table --json
|
|
143
|
+
maxc meta lineage your_table --json
|
|
144
|
+
maxc data sample your_table --partition ds=2026-03-20 --columns id,ds --rows 5 --json
|
|
145
|
+
maxc data profile your_table --partition ds=2026-03-20 --json
|
|
146
|
+
maxc query "SELECT 1 AS one" --json
|
|
147
|
+
maxc query cost "SELECT 1 AS one" --json
|
|
148
|
+
maxc query explain "SELECT 1 AS one" --json
|
|
149
|
+
maxc job submit "SELECT 1 AS one" --json
|
|
150
|
+
maxc job wait job_xxx --stream
|
|
151
|
+
maxc diff schema left_table right_table --json
|
|
152
|
+
maxc diff partition left_table right_table --json
|
|
153
|
+
maxc diff data left_table right_table --keys id --columns value_col --rows 100 --json
|
|
154
|
+
maxc cache status --json
|
|
155
|
+
maxc cache build-status --build-id build_xxx --json
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## `cache build --json` 行为
|
|
159
|
+
|
|
160
|
+
- `stdout` 只输出单个最终 JSON envelope
|
|
161
|
+
- `stderr` 持续输出进度文本,避免慢构建期间完全静默
|
|
162
|
+
- `--async --json` 会立即返回 `build_id`,随后用 `cache build-status --build-id <id> --json` 轮询
|
|
163
|
+
|
|
164
|
+
## JSON 契约
|
|
165
|
+
|
|
166
|
+
所有 `--json` 命令都返回 envelope:
|
|
167
|
+
|
|
168
|
+
- `version`
|
|
169
|
+
- `command`
|
|
170
|
+
- `command_id`
|
|
171
|
+
- `status`
|
|
172
|
+
- `data`
|
|
173
|
+
- `metadata`
|
|
174
|
+
- `error`
|
|
175
|
+
- `agent_hints`
|
|
176
|
+
|
|
177
|
+
常用规范化 `data` 结构:
|
|
178
|
+
|
|
179
|
+
- `auth whoami` -> `data.identity`
|
|
180
|
+
- `auth can-i` -> `data.authorization`
|
|
181
|
+
- `query` / `job wait` / `job result` -> `data.result` 和 `data.pagination`
|
|
182
|
+
- `query cost` / `query explain` -> `data.analysis`
|
|
183
|
+
- `meta describe` -> `data.table`
|
|
184
|
+
- `meta search` / `meta search-columns` -> `data.search.matches`
|
|
185
|
+
- `data sample` -> `data.sample`
|
|
186
|
+
- `data profile` -> `data.profile`
|
|
187
|
+
- `agent context` -> `data.context`
|
|
188
|
+
|
|
189
|
+
## 当前限制
|
|
190
|
+
|
|
191
|
+
- `meta lineage` 还没有接真实血缘 API;真实 backend 会明确返回 `supported=false`、`coverage=unsupported`
|
|
192
|
+
- `auth can-i` 当前只支持表级 `SELECT` 预检
|
|
193
|
+
- `auth login` 会把 AccessKey 明文写入本地 YAML;CLI 会尽量把文件权限收敛到 `0600`
|
|
194
|
+
- 环境变量优先于配置文件;`session_override.yaml` 对 project/schema 的优先级高于两者
|
|
195
|
+
- `meta list-tables` 是 cache-backed;冷启动时需要先执行 `cache build`
|
|
196
|
+
- `diff data` 当前是 keyed snapshot compare:每侧最多读取 `--rows` 行,不是全表 exhaustive diff
|
|
197
|
+
- 真实 backend 目前不提供统一 CU 口径成本,因此 `--cost-check` 在真实 backend 上不可用
|
|
198
|
+
- 真实 backend 的 `query explain / query cost` 当前基于 `execute_sql_cost` 和结构化 query outline,不是完整优化器执行计划树
|
|
199
|
+
- `--cursor` 当前是 CLI 侧 offset token,不是 MaxCompute 服务端游标
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Sync the repo-tracked Codex skill into a Codex home."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import shutil
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _default_source() -> Path:
|
|
12
|
+
return Path(__file__).resolve().parent.parent / "skills" / "use-maxc-cli"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _default_target() -> Path:
|
|
16
|
+
return Path.home() / ".codex" / "skills" / "use-maxc-cli"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _parse_args() -> argparse.Namespace:
|
|
20
|
+
parser = argparse.ArgumentParser(description="Sync the repo-tracked use-maxc-cli skill into Codex.")
|
|
21
|
+
parser.add_argument(
|
|
22
|
+
"--source",
|
|
23
|
+
default=str(_default_source()),
|
|
24
|
+
help="Path to the source skill directory. Defaults to the repo-tracked skill.",
|
|
25
|
+
)
|
|
26
|
+
parser.add_argument(
|
|
27
|
+
"--target",
|
|
28
|
+
default=str(_default_target()),
|
|
29
|
+
help="Path to the target Codex skill directory. Defaults to ~/.codex/skills/use-maxc-cli.",
|
|
30
|
+
)
|
|
31
|
+
parser.add_argument(
|
|
32
|
+
"--dry-run",
|
|
33
|
+
action="store_true",
|
|
34
|
+
help="Print the resolved paths without copying files.",
|
|
35
|
+
)
|
|
36
|
+
return parser.parse_args()
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _validate_paths(source: Path, target: Path) -> None:
|
|
40
|
+
if not (source / "SKILL.md").exists():
|
|
41
|
+
raise SystemExit(f"Source skill is missing SKILL.md: {source}")
|
|
42
|
+
if source.name != "use-maxc-cli":
|
|
43
|
+
raise SystemExit(f"Source directory must be named `use-maxc-cli`: {source}")
|
|
44
|
+
if target.name != "use-maxc-cli":
|
|
45
|
+
raise SystemExit(f"Target directory must end with `use-maxc-cli`: {target}")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def main() -> int:
|
|
49
|
+
args = _parse_args()
|
|
50
|
+
source = Path(args.source).expanduser().resolve()
|
|
51
|
+
target = Path(args.target).expanduser().resolve()
|
|
52
|
+
_validate_paths(source, target)
|
|
53
|
+
|
|
54
|
+
if args.dry_run:
|
|
55
|
+
print(f"Source: {source}")
|
|
56
|
+
print(f"Target: {target}")
|
|
57
|
+
return 0
|
|
58
|
+
|
|
59
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
60
|
+
if target.exists():
|
|
61
|
+
shutil.rmtree(target)
|
|
62
|
+
shutil.copytree(source, target)
|
|
63
|
+
print(f"Synced {source} -> {target}")
|
|
64
|
+
return 0
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
raise SystemExit(main())
|
maxc_cli-0.1.0/setup.cfg
ADDED
maxc_cli-0.1.0/setup.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
from setuptools import find_packages, setup
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
ROOT = Path(__file__).resolve().parent
|
|
7
|
+
README = ROOT / "README.md"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
setup(
|
|
11
|
+
name="maxc-cli",
|
|
12
|
+
version="0.1.0",
|
|
13
|
+
description="Agent-native MaxCompute CLI for external coding agents",
|
|
14
|
+
long_description=README.read_text(encoding="utf-8"),
|
|
15
|
+
long_description_content_type="text/markdown",
|
|
16
|
+
python_requires=">=3.8,<3.13",
|
|
17
|
+
package_dir={"": "src"},
|
|
18
|
+
packages=find_packages(where="src"),
|
|
19
|
+
include_package_data=True,
|
|
20
|
+
classifiers=[
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.8",
|
|
23
|
+
"Programming Language :: Python :: 3.9",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.11",
|
|
26
|
+
"Programming Language :: Python :: 3.12",
|
|
27
|
+
],
|
|
28
|
+
install_requires=[
|
|
29
|
+
"PyYAML>=5.4",
|
|
30
|
+
"pyodps",
|
|
31
|
+
],
|
|
32
|
+
entry_points={
|
|
33
|
+
"console_scripts": [
|
|
34
|
+
"maxc=maxc_cli.__main__:main",
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
)
|