cortexctl 0.1.0.dev20260811135705__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.
- cortexctl-0.1.0.dev20260811135705/.gitignore +69 -0
- cortexctl-0.1.0.dev20260811135705/PKG-INFO +213 -0
- cortexctl-0.1.0.dev20260811135705/README.md +202 -0
- cortexctl-0.1.0.dev20260811135705/cortex_cli/__init__.py +1 -0
- cortexctl-0.1.0.dev20260811135705/cortex_cli/__main__.py +4 -0
- cortexctl-0.1.0.dev20260811135705/cortex_cli/client.py +1222 -0
- cortexctl-0.1.0.dev20260811135705/cortex_cli/config.py +88 -0
- cortexctl-0.1.0.dev20260811135705/cortex_cli/main.py +4878 -0
- cortexctl-0.1.0.dev20260811135705/cortex_cli/registry.py +862 -0
- cortexctl-0.1.0.dev20260811135705/pyproject.toml +51 -0
- cortexctl-0.1.0.dev20260811135705/tests/test_cli.py +4012 -0
- cortexctl-0.1.0.dev20260811135705/tests/test_packaging.py +124 -0
- cortexctl-0.1.0.dev20260811135705/uv.lock +179 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
cortex-main/
|
|
2
|
+
demo/
|
|
3
|
+
|
|
4
|
+
# ===== Python =====
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*.pyo
|
|
8
|
+
*.egg-info/
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
*.egg
|
|
12
|
+
.eggs/
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
.mypy_cache/
|
|
16
|
+
.coverage
|
|
17
|
+
htmlcov/
|
|
18
|
+
*.so
|
|
19
|
+
|
|
20
|
+
# Virtual environments
|
|
21
|
+
.venv/
|
|
22
|
+
venv/
|
|
23
|
+
env/
|
|
24
|
+
.env.local
|
|
25
|
+
.env.*.local
|
|
26
|
+
|
|
27
|
+
# ===== OS / IDE =====
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
.idea/
|
|
31
|
+
*.swp
|
|
32
|
+
*.swo
|
|
33
|
+
*~
|
|
34
|
+
.vscode/settings.json
|
|
35
|
+
|
|
36
|
+
# ===== Node / Frontend =====
|
|
37
|
+
node_modules/
|
|
38
|
+
frontend/dist/
|
|
39
|
+
frontend/.next/
|
|
40
|
+
frontend/build/
|
|
41
|
+
frontend/.turbo/
|
|
42
|
+
|
|
43
|
+
# ===== Docker =====
|
|
44
|
+
docker-compose.override.yml
|
|
45
|
+
|
|
46
|
+
# ===== Environment =====
|
|
47
|
+
.env
|
|
48
|
+
.env.production
|
|
49
|
+
.env.staging
|
|
50
|
+
.deploy/
|
|
51
|
+
|
|
52
|
+
# ===== Logs =====
|
|
53
|
+
*.log
|
|
54
|
+
logs/
|
|
55
|
+
|
|
56
|
+
# ===== Temporal =====
|
|
57
|
+
temporalio/
|
|
58
|
+
|
|
59
|
+
# ===== Alembic =====
|
|
60
|
+
# Keep alembic migrations in version control, but ignore local config
|
|
61
|
+
# alembic.ini is project-level and should be committed
|
|
62
|
+
|
|
63
|
+
# ===== Var =====
|
|
64
|
+
backend/var/
|
|
65
|
+
|
|
66
|
+
# ===== TMP =====
|
|
67
|
+
.tmp/
|
|
68
|
+
|
|
69
|
+
*.backup
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: cortexctl
|
|
3
|
+
Version: 0.1.0.dev20260811135705
|
|
4
|
+
Summary: Cortex knowledge base CLI (console command: cortex)
|
|
5
|
+
Project-URL: Homepage, https://github.com/eeeming/Cortex
|
|
6
|
+
Project-URL: Repository, https://github.com/eeeming/Cortex
|
|
7
|
+
Project-URL: Documentation, https://github.com/eeeming/Cortex/blob/test/cli/README.md
|
|
8
|
+
Requires-Python: >=3.12
|
|
9
|
+
Requires-Dist: typer>=0.26.3
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# CLI
|
|
13
|
+
|
|
14
|
+
Cortex CLI 是根级 Python 项目,命令名为 `cortex`。
|
|
15
|
+
|
|
16
|
+
CLI 是一期一等入口,但不直接写数据库。当前 CLI 仍通过 `/api/v1` 兼容 HTTP 面访问后端;长期方向是复用后端 application service / usecase,远程 CLI 再沉淀独立命令 / 查询协议,始终遵守 Workspace RBAC。
|
|
17
|
+
|
|
18
|
+
## 当前骨架
|
|
19
|
+
|
|
20
|
+
```text
|
|
21
|
+
cli/
|
|
22
|
+
├── cortex_cli/
|
|
23
|
+
│ ├── client.py # 标准库 HTTP API Client
|
|
24
|
+
│ ├── config.py # 本地 CLI state:API URL、token、默认 Workspace
|
|
25
|
+
│ ├── main.py # Typer CLI 入口
|
|
26
|
+
│ └── registry.py # Agent 友好的命令树元数据
|
|
27
|
+
└── tests/
|
|
28
|
+
└── test_cli.py
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 已实现命令
|
|
32
|
+
|
|
33
|
+
当前 CLI 已接入 M3 后端 API 纵切:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
cortex auth login --email owner@example.com --password <debug-password> --json
|
|
37
|
+
cortex auth whoami --json
|
|
38
|
+
cortex auth logout --json
|
|
39
|
+
cortex doctor --json
|
|
40
|
+
|
|
41
|
+
cortex workspace list --json
|
|
42
|
+
cortex workspace create --name 产品团队知识库 --json
|
|
43
|
+
cortex workspace use <workspace-id>
|
|
44
|
+
cortex workspace get --json
|
|
45
|
+
cortex workspace update --name 新名称 --json
|
|
46
|
+
cortex workspace delete <workspace-id> --json
|
|
47
|
+
cortex workspace leave <workspace-id> --json
|
|
48
|
+
cortex workspace transfer-owner <workspace-id> --new-owner-id <user-id> --json
|
|
49
|
+
|
|
50
|
+
cortex workspace invite list --query user@example.com --status pending --json
|
|
51
|
+
cortex workspace invite create --email user@example.com --role editor --json
|
|
52
|
+
cortex workspace invite revoke <invite-id> --json
|
|
53
|
+
cortex workspace invite enter <invite-id> --json
|
|
54
|
+
cortex workspace invite reject <invite-id> --json
|
|
55
|
+
|
|
56
|
+
cortex workspace member list --query "User Name" --json
|
|
57
|
+
cortex workspace member set-role <user-id> --role viewer --json
|
|
58
|
+
cortex workspace member remove <user-id> --json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
说明:
|
|
62
|
+
|
|
63
|
+
- CLI 命令框架使用 Typer,保留 `cortex commands --json` 作为 Agent 发现入口。
|
|
64
|
+
- 直接运行 `cortex` 或无子命令的命令组,如 `cortex workspace`,会显示对应 `--help`。
|
|
65
|
+
- 当前 `auth login` 默认使用飞书 OAuth device flow + 后端轮询登录,适配远程容器 Agent;`auth login --method loopback` 保留为本机快捷登录;`auth login --email <email> --password <debug-password>` 保留为后端本地调试登录,且要求后端显式启用该能力。
|
|
66
|
+
- `auth logout` 会优先调用服务端 revoke 端点撤销 refresh token,再清理本地 state。
|
|
67
|
+
- `doctor` 会检查 API URL、`/health`、`/ready`、本地 state、token 和默认 Workspace。
|
|
68
|
+
- `workspace invite list` 和 `workspace member list` 支持 `--page`、`--page-size`、`--query`;邀请列表还支持 `--status pending|accepted|revoked|rejected`。
|
|
69
|
+
- 默认后端地址为 `http://127.0.0.1:8000/api/v1`,可用 `CORTEX_API_URL` 或全局 `--api-url` 覆盖;该路径是迁移期 CLI 兼容入口,不作为前端公开 OpenAPI 契约。
|
|
70
|
+
- API 请求默认超时为 30 秒,测试或慢速 E2E 环境可用 `CORTEX_CLI_REQUEST_TIMEOUT_SECONDS` 覆盖。
|
|
71
|
+
- 本地 state 默认写入 `~/.config/cortex/state.json`,保存时会设置为仅当前用户可读写;测试或自动化可用 `CORTEX_CLI_STATE` 覆盖。
|
|
72
|
+
- 未显式传 `workspace_id` 的 Workspace 子命令会读取 `cortex workspace use <workspace-id>` 设置的默认 Workspace。
|
|
73
|
+
|
|
74
|
+
## 向量索引运维
|
|
75
|
+
|
|
76
|
+
向量索引投影异常不会由普通查询、处理或启动路径自动清空 / 重建向量表。CLI 只提供状态读取和显式 rebuild 入口:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
cortex vector-index status --workspace-id <workspace-id> --json
|
|
80
|
+
cortex vector-index rebuild --workspace-id <workspace-id> --dry-run --json
|
|
81
|
+
cortex vector-index rebuild --workspace-id <workspace-id> --yes --json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`status --json` 会根据后端 Workspace 状态输出 `needs_rebuild`、索引状态和错误摘要字段,方便 Agent 判断是否需要提示用户执行 rebuild。`rebuild` 是写入型运维动作,必须先 dry-run 或传 `--yes`。
|
|
85
|
+
|
|
86
|
+
## 安装(用户 / Agent,与 Skills 一致)
|
|
87
|
+
|
|
88
|
+
安装后 PATH 中应有 **`cortex`** 命令。用户侧 Skills(`skills/cortex-upload`、`skills/cortex-search`)假定本机已安装 CLI,直接调用 `cortex …`。
|
|
89
|
+
|
|
90
|
+
**命名说明**
|
|
91
|
+
|
|
92
|
+
| 概念 | 名称 | 说明 |
|
|
93
|
+
| -------------- | --------------- | ----------------------------------------------- |
|
|
94
|
+
| 控制台命令 | `cortex` | 用户与 Skills 实际调用的入口 |
|
|
95
|
+
| PyPI / uv 包名 | **`cortexctl`** | 发行名(`cortex-cli` 在 PyPI 已被无关项目占用) |
|
|
96
|
+
| 实现源码 | monorepo `cli/` | 与后端同仓开发;业务镜像 **不 COPY `cli/`** |
|
|
97
|
+
|
|
98
|
+
**前置**:Python ≥ 3.12,并已安装 [uv](https://docs.astral.sh/uv/)(推荐)或 pipx。
|
|
99
|
+
|
|
100
|
+
### 推荐:从 PyPI 安装
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# 包名 cortexctl,安装后命令为 cortex
|
|
104
|
+
# 默认安装最新「正式版」(不含 .dev 预发布)
|
|
105
|
+
uv tool install cortexctl
|
|
106
|
+
|
|
107
|
+
# 需要测试通道(test 分支自动发布的预发布号,如 0.1.0.dev20260811153045)
|
|
108
|
+
uv tool install --prerelease=allow cortexctl
|
|
109
|
+
# 或钉死:uv tool install "cortexctl==0.1.0.dev20260811153045"
|
|
110
|
+
|
|
111
|
+
# 升级正式版
|
|
112
|
+
uv tool upgrade cortexctl
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
等价(pipx):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pipx install cortexctl
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**版本通道**
|
|
122
|
+
|
|
123
|
+
| 来源 | 版本形态 | 如何产生 |
|
|
124
|
+
| ------------------------------- | ------------------------ | ------------------ |
|
|
125
|
+
| `test` 分支变更 `cli/**` | 预发布 `X.Y.Z.dev时间戳` | CI 自动发布到 PyPI |
|
|
126
|
+
| `main` + tag `cortexctl-vX.Y.Z` | 正式 `X.Y.Z` | 打 tag 后 CI 发布 |
|
|
127
|
+
| `main` 仅 push | 不自动发布 | 只跑打包冒烟 |
|
|
128
|
+
|
|
129
|
+
> 若 PyPI 上尚无任何版本,请用下方「从 monorepo 源码 / Git」安装。
|
|
130
|
+
|
|
131
|
+
### 备选:从 monorepo 源码或 Git 安装(开发 / 未发布时)
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# 本地 monorepo
|
|
135
|
+
uv tool install /path/to/Cortex/cli
|
|
136
|
+
|
|
137
|
+
# 或直接从 GitHub monorepo 的 cli 子目录
|
|
138
|
+
uv tool install "git+https://github.com/eeeming/Cortex.git@test#subdirectory=cli"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### 安装后自检与登录
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
cortex version --json
|
|
145
|
+
cortex doctor --json
|
|
146
|
+
|
|
147
|
+
# 指向你的 Cortex API(默认 http://127.0.0.1:8000/api/v1)
|
|
148
|
+
export CORTEX_API_URL="https://<your-host>/api/v1"
|
|
149
|
+
# 或:cortex --api-url "https://<your-host>/api/v1" auth whoami --json
|
|
150
|
+
|
|
151
|
+
cortex auth login
|
|
152
|
+
cortex workspace list --json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
与 Skills 的关系:Agent 执行上传 / 查知识时使用同一套 `cortex` 子命令;请先完成安装与 `auth login` / `workspace use`。
|
|
156
|
+
|
|
157
|
+
### Docker(可选,非桌面主路径)
|
|
158
|
+
|
|
159
|
+
CI 会构建 `ghcr.io/eeeming/cortex/cortex-cli:<sha>`(镜像名历史沿用),适合容器内一次性调用,不替代本机 `uv tool install cortexctl`。
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
docker run --rm -e CORTEX_API_URL=https://<your-host>/api/v1 \
|
|
163
|
+
ghcr.io/eeeming/cortex/cortex-cli:test version --json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 分发与服务端精简
|
|
169
|
+
|
|
170
|
+
| 形态 | 用户如何得到 `cortex` | 服务端 / 镜像 |
|
|
171
|
+
| ---------------------- | -------------------------------------- | ------------------------------------------------------------- |
|
|
172
|
+
| **PyPI(推荐)** | `uv tool install cortexctl` | monorepo `cli/` 为真相源;backend/frontend **不 COPY `cli/`** |
|
|
173
|
+
| **Git / 源码(备选)** | monorepo `subdirectory=cli` 或本地路径 | 同上 |
|
|
174
|
+
| **独立公开仓** | 已弃用(不再作为安装主路径) | — |
|
|
175
|
+
|
|
176
|
+
### PyPI / `uv publish`
|
|
177
|
+
|
|
178
|
+
- 分发包名:**`cortexctl`**;命令:**`cortex`**。
|
|
179
|
+
- `project.urls.Repository` → `https://github.com/eeeming/Cortex`(主仓)。
|
|
180
|
+
- 维护者:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
cd cli
|
|
184
|
+
uv build
|
|
185
|
+
# 配置 PyPI token 或 Trusted Publisher 后:
|
|
186
|
+
uv publish
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
CI:
|
|
190
|
+
|
|
191
|
+
- 每次改 `cli/**`:build + wheel 安装 + `cortex version` 冒烟。
|
|
192
|
+
- 可选发布:`workflow_dispatch` 勾选 publish,或推送 tag `cortexctl-v*`(需 `UV_PUBLISH_TOKEN` / Trusted Publishing)。
|
|
193
|
+
|
|
194
|
+
未配置密钥时 CI **不会**假装已上传到 PyPI。
|
|
195
|
+
|
|
196
|
+
### 服务端精简镜像
|
|
197
|
+
|
|
198
|
+
- 生产 compose 只部署 backend-api / worker / frontend(及中间件)。
|
|
199
|
+
- `docker/backend/Dockerfile` 与 `docker/frontend/Dockerfile` **不得** `COPY cli/`。
|
|
200
|
+
- 用户 CLI 走本机 `cortexctl`(PyPI);运维可选独立 GHCR CLI 镜像。
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## 本地开发运行
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
cd cli
|
|
208
|
+
uv run cortex version --json
|
|
209
|
+
uv run cortex commands --json
|
|
210
|
+
uv run cortex auth login
|
|
211
|
+
uv run cortex auth login --email owner@example.com --password <debug-password> --json
|
|
212
|
+
uv run pytest
|
|
213
|
+
```
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# CLI
|
|
2
|
+
|
|
3
|
+
Cortex CLI 是根级 Python 项目,命令名为 `cortex`。
|
|
4
|
+
|
|
5
|
+
CLI 是一期一等入口,但不直接写数据库。当前 CLI 仍通过 `/api/v1` 兼容 HTTP 面访问后端;长期方向是复用后端 application service / usecase,远程 CLI 再沉淀独立命令 / 查询协议,始终遵守 Workspace RBAC。
|
|
6
|
+
|
|
7
|
+
## 当前骨架
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
cli/
|
|
11
|
+
├── cortex_cli/
|
|
12
|
+
│ ├── client.py # 标准库 HTTP API Client
|
|
13
|
+
│ ├── config.py # 本地 CLI state:API URL、token、默认 Workspace
|
|
14
|
+
│ ├── main.py # Typer CLI 入口
|
|
15
|
+
│ └── registry.py # Agent 友好的命令树元数据
|
|
16
|
+
└── tests/
|
|
17
|
+
└── test_cli.py
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 已实现命令
|
|
21
|
+
|
|
22
|
+
当前 CLI 已接入 M3 后端 API 纵切:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
cortex auth login --email owner@example.com --password <debug-password> --json
|
|
26
|
+
cortex auth whoami --json
|
|
27
|
+
cortex auth logout --json
|
|
28
|
+
cortex doctor --json
|
|
29
|
+
|
|
30
|
+
cortex workspace list --json
|
|
31
|
+
cortex workspace create --name 产品团队知识库 --json
|
|
32
|
+
cortex workspace use <workspace-id>
|
|
33
|
+
cortex workspace get --json
|
|
34
|
+
cortex workspace update --name 新名称 --json
|
|
35
|
+
cortex workspace delete <workspace-id> --json
|
|
36
|
+
cortex workspace leave <workspace-id> --json
|
|
37
|
+
cortex workspace transfer-owner <workspace-id> --new-owner-id <user-id> --json
|
|
38
|
+
|
|
39
|
+
cortex workspace invite list --query user@example.com --status pending --json
|
|
40
|
+
cortex workspace invite create --email user@example.com --role editor --json
|
|
41
|
+
cortex workspace invite revoke <invite-id> --json
|
|
42
|
+
cortex workspace invite enter <invite-id> --json
|
|
43
|
+
cortex workspace invite reject <invite-id> --json
|
|
44
|
+
|
|
45
|
+
cortex workspace member list --query "User Name" --json
|
|
46
|
+
cortex workspace member set-role <user-id> --role viewer --json
|
|
47
|
+
cortex workspace member remove <user-id> --json
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
说明:
|
|
51
|
+
|
|
52
|
+
- CLI 命令框架使用 Typer,保留 `cortex commands --json` 作为 Agent 发现入口。
|
|
53
|
+
- 直接运行 `cortex` 或无子命令的命令组,如 `cortex workspace`,会显示对应 `--help`。
|
|
54
|
+
- 当前 `auth login` 默认使用飞书 OAuth device flow + 后端轮询登录,适配远程容器 Agent;`auth login --method loopback` 保留为本机快捷登录;`auth login --email <email> --password <debug-password>` 保留为后端本地调试登录,且要求后端显式启用该能力。
|
|
55
|
+
- `auth logout` 会优先调用服务端 revoke 端点撤销 refresh token,再清理本地 state。
|
|
56
|
+
- `doctor` 会检查 API URL、`/health`、`/ready`、本地 state、token 和默认 Workspace。
|
|
57
|
+
- `workspace invite list` 和 `workspace member list` 支持 `--page`、`--page-size`、`--query`;邀请列表还支持 `--status pending|accepted|revoked|rejected`。
|
|
58
|
+
- 默认后端地址为 `http://127.0.0.1:8000/api/v1`,可用 `CORTEX_API_URL` 或全局 `--api-url` 覆盖;该路径是迁移期 CLI 兼容入口,不作为前端公开 OpenAPI 契约。
|
|
59
|
+
- API 请求默认超时为 30 秒,测试或慢速 E2E 环境可用 `CORTEX_CLI_REQUEST_TIMEOUT_SECONDS` 覆盖。
|
|
60
|
+
- 本地 state 默认写入 `~/.config/cortex/state.json`,保存时会设置为仅当前用户可读写;测试或自动化可用 `CORTEX_CLI_STATE` 覆盖。
|
|
61
|
+
- 未显式传 `workspace_id` 的 Workspace 子命令会读取 `cortex workspace use <workspace-id>` 设置的默认 Workspace。
|
|
62
|
+
|
|
63
|
+
## 向量索引运维
|
|
64
|
+
|
|
65
|
+
向量索引投影异常不会由普通查询、处理或启动路径自动清空 / 重建向量表。CLI 只提供状态读取和显式 rebuild 入口:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
cortex vector-index status --workspace-id <workspace-id> --json
|
|
69
|
+
cortex vector-index rebuild --workspace-id <workspace-id> --dry-run --json
|
|
70
|
+
cortex vector-index rebuild --workspace-id <workspace-id> --yes --json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
`status --json` 会根据后端 Workspace 状态输出 `needs_rebuild`、索引状态和错误摘要字段,方便 Agent 判断是否需要提示用户执行 rebuild。`rebuild` 是写入型运维动作,必须先 dry-run 或传 `--yes`。
|
|
74
|
+
|
|
75
|
+
## 安装(用户 / Agent,与 Skills 一致)
|
|
76
|
+
|
|
77
|
+
安装后 PATH 中应有 **`cortex`** 命令。用户侧 Skills(`skills/cortex-upload`、`skills/cortex-search`)假定本机已安装 CLI,直接调用 `cortex …`。
|
|
78
|
+
|
|
79
|
+
**命名说明**
|
|
80
|
+
|
|
81
|
+
| 概念 | 名称 | 说明 |
|
|
82
|
+
| -------------- | --------------- | ----------------------------------------------- |
|
|
83
|
+
| 控制台命令 | `cortex` | 用户与 Skills 实际调用的入口 |
|
|
84
|
+
| PyPI / uv 包名 | **`cortexctl`** | 发行名(`cortex-cli` 在 PyPI 已被无关项目占用) |
|
|
85
|
+
| 实现源码 | monorepo `cli/` | 与后端同仓开发;业务镜像 **不 COPY `cli/`** |
|
|
86
|
+
|
|
87
|
+
**前置**:Python ≥ 3.12,并已安装 [uv](https://docs.astral.sh/uv/)(推荐)或 pipx。
|
|
88
|
+
|
|
89
|
+
### 推荐:从 PyPI 安装
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
# 包名 cortexctl,安装后命令为 cortex
|
|
93
|
+
# 默认安装最新「正式版」(不含 .dev 预发布)
|
|
94
|
+
uv tool install cortexctl
|
|
95
|
+
|
|
96
|
+
# 需要测试通道(test 分支自动发布的预发布号,如 0.1.0.dev20260811153045)
|
|
97
|
+
uv tool install --prerelease=allow cortexctl
|
|
98
|
+
# 或钉死:uv tool install "cortexctl==0.1.0.dev20260811153045"
|
|
99
|
+
|
|
100
|
+
# 升级正式版
|
|
101
|
+
uv tool upgrade cortexctl
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
等价(pipx):
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pipx install cortexctl
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**版本通道**
|
|
111
|
+
|
|
112
|
+
| 来源 | 版本形态 | 如何产生 |
|
|
113
|
+
| ------------------------------- | ------------------------ | ------------------ |
|
|
114
|
+
| `test` 分支变更 `cli/**` | 预发布 `X.Y.Z.dev时间戳` | CI 自动发布到 PyPI |
|
|
115
|
+
| `main` + tag `cortexctl-vX.Y.Z` | 正式 `X.Y.Z` | 打 tag 后 CI 发布 |
|
|
116
|
+
| `main` 仅 push | 不自动发布 | 只跑打包冒烟 |
|
|
117
|
+
|
|
118
|
+
> 若 PyPI 上尚无任何版本,请用下方「从 monorepo 源码 / Git」安装。
|
|
119
|
+
|
|
120
|
+
### 备选:从 monorepo 源码或 Git 安装(开发 / 未发布时)
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# 本地 monorepo
|
|
124
|
+
uv tool install /path/to/Cortex/cli
|
|
125
|
+
|
|
126
|
+
# 或直接从 GitHub monorepo 的 cli 子目录
|
|
127
|
+
uv tool install "git+https://github.com/eeeming/Cortex.git@test#subdirectory=cli"
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 安装后自检与登录
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
cortex version --json
|
|
134
|
+
cortex doctor --json
|
|
135
|
+
|
|
136
|
+
# 指向你的 Cortex API(默认 http://127.0.0.1:8000/api/v1)
|
|
137
|
+
export CORTEX_API_URL="https://<your-host>/api/v1"
|
|
138
|
+
# 或:cortex --api-url "https://<your-host>/api/v1" auth whoami --json
|
|
139
|
+
|
|
140
|
+
cortex auth login
|
|
141
|
+
cortex workspace list --json
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
与 Skills 的关系:Agent 执行上传 / 查知识时使用同一套 `cortex` 子命令;请先完成安装与 `auth login` / `workspace use`。
|
|
145
|
+
|
|
146
|
+
### Docker(可选,非桌面主路径)
|
|
147
|
+
|
|
148
|
+
CI 会构建 `ghcr.io/eeeming/cortex/cortex-cli:<sha>`(镜像名历史沿用),适合容器内一次性调用,不替代本机 `uv tool install cortexctl`。
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
docker run --rm -e CORTEX_API_URL=https://<your-host>/api/v1 \
|
|
152
|
+
ghcr.io/eeeming/cortex/cortex-cli:test version --json
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 分发与服务端精简
|
|
158
|
+
|
|
159
|
+
| 形态 | 用户如何得到 `cortex` | 服务端 / 镜像 |
|
|
160
|
+
| ---------------------- | -------------------------------------- | ------------------------------------------------------------- |
|
|
161
|
+
| **PyPI(推荐)** | `uv tool install cortexctl` | monorepo `cli/` 为真相源;backend/frontend **不 COPY `cli/`** |
|
|
162
|
+
| **Git / 源码(备选)** | monorepo `subdirectory=cli` 或本地路径 | 同上 |
|
|
163
|
+
| **独立公开仓** | 已弃用(不再作为安装主路径) | — |
|
|
164
|
+
|
|
165
|
+
### PyPI / `uv publish`
|
|
166
|
+
|
|
167
|
+
- 分发包名:**`cortexctl`**;命令:**`cortex`**。
|
|
168
|
+
- `project.urls.Repository` → `https://github.com/eeeming/Cortex`(主仓)。
|
|
169
|
+
- 维护者:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
cd cli
|
|
173
|
+
uv build
|
|
174
|
+
# 配置 PyPI token 或 Trusted Publisher 后:
|
|
175
|
+
uv publish
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
CI:
|
|
179
|
+
|
|
180
|
+
- 每次改 `cli/**`:build + wheel 安装 + `cortex version` 冒烟。
|
|
181
|
+
- 可选发布:`workflow_dispatch` 勾选 publish,或推送 tag `cortexctl-v*`(需 `UV_PUBLISH_TOKEN` / Trusted Publishing)。
|
|
182
|
+
|
|
183
|
+
未配置密钥时 CI **不会**假装已上传到 PyPI。
|
|
184
|
+
|
|
185
|
+
### 服务端精简镜像
|
|
186
|
+
|
|
187
|
+
- 生产 compose 只部署 backend-api / worker / frontend(及中间件)。
|
|
188
|
+
- `docker/backend/Dockerfile` 与 `docker/frontend/Dockerfile` **不得** `COPY cli/`。
|
|
189
|
+
- 用户 CLI 走本机 `cortexctl`(PyPI);运维可选独立 GHCR CLI 镜像。
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 本地开发运行
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
cd cli
|
|
197
|
+
uv run cortex version --json
|
|
198
|
+
uv run cortex commands --json
|
|
199
|
+
uv run cortex auth login
|
|
200
|
+
uv run cortex auth login --email owner@example.com --password <debug-password> --json
|
|
201
|
+
uv run pytest
|
|
202
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Cortex command line interface package."""
|