cubest 0.1.0
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.
- package/LICENSE +201 -0
- package/NOTICE +27 -0
- package/README.ar.md +110 -0
- package/README.bn.md +111 -0
- package/README.es.md +110 -0
- package/README.hi.md +110 -0
- package/README.ja.md +113 -0
- package/README.md +469 -0
- package/README.pa.md +114 -0
- package/README.pt.md +113 -0
- package/README.ru.md +1174 -0
- package/README.zh-CN.md +233 -0
- package/bin/cubest.js +28 -0
- package/cubest.py +1862 -0
- package/package.json +28 -0
- package/profiles/agents_inventory.yaml +15 -0
- package/profiles/api_routes.yaml +20 -0
- package/profiles/call_graph.yaml +19 -0
- package/profiles/code_atlas.yaml +33 -0
- package/profiles/code_stats.yaml +15 -0
- package/profiles/csv_analytics.yaml +31 -0
- package/profiles/disk_usage.yaml +29 -0
- package/profiles/doc_structure.yaml +16 -0
- package/profiles/file_tree.yaml +27 -0
- package/profiles/frontend_geoip.yaml +49 -0
- package/profiles/git_log_activity.yaml +29 -0
- package/profiles/imports.yaml +16 -0
- package/profiles/jsonl_events.yaml +19 -0
- package/profiles/k8s_resources.yaml +25 -0
- package/profiles/loc_counter.yaml +51 -0
- package/profiles/mr_impact.yaml +19 -0
- package/profiles/nginx_access.yaml +33 -0
- package/profiles/nginx_cdn_covers.yaml +32 -0
- package/profiles/openapi_endpoints.yaml +19 -0
- package/profiles/react_components.yaml +15 -0
- package/profiles/sdd_checklist.yaml +17 -0
- package/profiles/sdd_specs.yaml +19 -0
- package/profiles/seo_audit.yaml +31 -0
- package/profiles/seo_semantic_tree.yaml +17 -0
- package/profiles/sitemap_map.yaml +20 -0
- package/profiles/skills_inventory.yaml +17 -0
- package/profiles/spec_status.yaml +18 -0
- package/profiles/sql_functions.yaml +31 -0
- package/profiles/tech_debt.yaml +16 -0
- package/profiles/xml_tags.yaml +21 -0
- package/profiles/yaml_keys.yaml +19 -0
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# cubest
|
|
2
|
+
|
|
3
|
+
[English](README.md) · **简体中文** · [Español](README.es.md) · [हिन्दी](README.hi.md) · [العربية](README.ar.md) · [বাংলা](README.bn.md) · [Português](README.pt.md) · [Русский](README.ru.md) · [日本語](README.ja.md) · [ਪੰਜਾਬੀ](README.pa.md)
|
|
4
|
+
|
|
5
|
+
> **AI 代理每次仓库扫描节省 7–22 倍 token。** 单遍 OLAP 聚合器,把任意文本流
|
|
6
|
+
> —— 代码、日志、CSV、JSONL、XML、HTML、SDD 制品 —— 折叠成紧凑的多维立方体。
|
|
7
|
+
> 专为 **Claude Code、Cursor、Codex、Aider、Windsurf、Cline、Continue.dev**
|
|
8
|
+
> 以及任何按输入 token 计费的 AI 编码代理设计。
|
|
9
|
+
|
|
10
|
+
<p align="left">
|
|
11
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" alt="License Apache 2.0"></a>
|
|
12
|
+
<img src="https://img.shields.io/badge/python-3.8%2B-blue.svg" alt="Python 3.8+">
|
|
13
|
+
<img src="https://img.shields.io/badge/deps-仅标准库-green.svg" alt="stdlib only">
|
|
14
|
+
<img src="https://img.shields.io/badge/tests-57%20通过-brightgreen.svg" alt="57 tests passing">
|
|
15
|
+
<img src="https://img.shields.io/badge/profiles-31%20个内置-purple.svg" alt="31 profiles">
|
|
16
|
+
<img src="https://img.shields.io/badge/输出格式-13-orange.svg" alt="13 output formats">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
## 🧠 为什么 AI 代理应该关心
|
|
20
|
+
|
|
21
|
+
在 7 个真实场景中测得(见 [`examples/`](examples/)):
|
|
22
|
+
|
|
23
|
+
| # | 场景 | 朴素工具响应 | Cubest 响应 | 比率 |
|
|
24
|
+
|---|------------------------------------------|:-----------:|:-----------:|:-----------:|
|
|
25
|
+
| 1 | 5000 行 nginx 日志 5xx 排查 | 3,590 tok | 158 tok | **22.7×** |
|
|
26
|
+
| 2 | 仓库入门(40 文件) | 1,256 tok | 175 tok | 7.2× |
|
|
27
|
+
| 3 | 从 `git diff` 生成 MR 影响图 | 280 tok | 16 tok | **17.5×** |
|
|
28
|
+
| 4 | 小型 CSV 汇总(300 行) | 280 tok | 368 tok | 0.8× ❌ |
|
|
29
|
+
| 5 | 10 页 HTML 的 SEO 审计 | 382 tok | 49 tok | 7.8× |
|
|
30
|
+
| 6 | 300 文件的磁盘使用审计 | 338 tok | 68 tok | 5.0× |
|
|
31
|
+
| 7 | RSS 分类汇总(3 源 × 30 项) | 1,692 tok | 265 tok | 6.4× |
|
|
32
|
+
| | **中位数** | | | **7.2×** |
|
|
33
|
+
| | **峰值(流式日志)** | | | **22.7×** |
|
|
34
|
+
|
|
35
|
+
Cubest 在**大流量和层次化数据**上占优。对于极小的表格数据(300 行 CSV),
|
|
36
|
+
朴素的 `awk` 管道已经足够紧凑,cubest 反而输了。在关键场景 —— 日志、代码树、
|
|
37
|
+
sitemap 爬虫 —— 落入代理上下文的 token 减少 5–25 倍。
|
|
38
|
+
|
|
39
|
+
按 Claude Sonnet 4.6 / Opus 4.7 的 3–15 美元每百万输入 token 计算,
|
|
40
|
+
每天 1000 个代理会话可节省**每月数千美元**的工具响应摄入费用 ——
|
|
41
|
+
而且长会话不再撞上下文墙。
|
|
42
|
+
|
|
43
|
+
## ⚡ 快速开始
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# 选项 A —— 纯下载(无依赖,JSON 配置文件可直接使用)
|
|
47
|
+
curl -O https://raw.githubusercontent.com/BaryshevS/cubest/main/cubest.py
|
|
48
|
+
python3 cubest.py --profile file_tree .
|
|
49
|
+
|
|
50
|
+
# 选项 B —— 通过 pip 安装(PyPI 即将发布)
|
|
51
|
+
pip install cubest
|
|
52
|
+
cubest --profile file_tree .
|
|
53
|
+
|
|
54
|
+
# 选项 C —— 通过 uv 临时运行,不需要 venv
|
|
55
|
+
uv run --with pyyaml \
|
|
56
|
+
https://raw.githubusercontent.com/BaryshevS/cubest/main/cubest.py \
|
|
57
|
+
--profile file_tree .
|
|
58
|
+
|
|
59
|
+
# 选项 D —— npm 包装器(委托给 python3)
|
|
60
|
+
npx cubest --profile file_tree .
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 🎯 核心功能
|
|
64
|
+
|
|
65
|
+
一个 Python 文件(`cubest.py`,约 1800 行,`PyYAML` 可选),它:
|
|
66
|
+
|
|
67
|
+
1. **流式读取**文本源 —— 文件、目录、`.gz` 归档、stdin
|
|
68
|
+
2. 通过正则或 10 个内置预设**提取**记录
|
|
69
|
+
3. **聚合**到内存中的层次化 OLAP 立方体
|
|
70
|
+
(维度 × 度量:`count`、`sum`、`avg`、`min`、`max`、`p50`、
|
|
71
|
+
`p90`、`p95`、`p99`,通过蓄水池采样实现)
|
|
72
|
+
4. 以 13 种格式**渲染**立方体 —— 从紧凑树到独立的交互式 HTML 仪表板
|
|
73
|
+
|
|
74
|
+
零数据库、零 LLM、零 tree-sitter、零外部服务。
|
|
75
|
+
|
|
76
|
+
## 🔌 AI 代理集成
|
|
77
|
+
|
|
78
|
+
Cubest 与代理无关。已测试并支持:
|
|
79
|
+
|
|
80
|
+
| 代理 | 接入方法 |
|
|
81
|
+
|-----------------------------|-------------------------------------------------------------|
|
|
82
|
+
| **Claude Code** | 作为 `.claude/skills/cubest/` 技能发布;见 [SKILL.md](SKILL.md) |
|
|
83
|
+
| **Cursor** | 在 Cursor 规则中将 `cubest` 添加为允许的 shell 工具 |
|
|
84
|
+
| **OpenAI Codex CLI** | 直接在 shell 中使用 —— Codex 会通过 `--help` 发现它 |
|
|
85
|
+
| **Aider** | `/run cubest ...` 或添加到 `--command` 别名 |
|
|
86
|
+
| **Windsurf (Codeium)** | 在 `windsurf.rules` 中允许 `cubest` |
|
|
87
|
+
| **Cline (VS Code)** | 启用命令执行;代理按需调用 |
|
|
88
|
+
| **Continue.dev** | 在 `~/.continue/config.json` 中添加为自定义斜杠命令 |
|
|
89
|
+
| **任何支持工具调用的代理** | 将 `cubest -p '<inline JSON>' <path>` 包装成一个工具 |
|
|
90
|
+
|
|
91
|
+
魔法所在:代理**自己生成** `<inline JSON>` 配置文件,针对用户提问动态定制。
|
|
92
|
+
无预设提示,无固定 API —— 一个工具就能适应任何查询。
|
|
93
|
+
|
|
94
|
+
## 🚀 常用命令
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# 快速摸清陌生仓库(30 行代替 3000 行)
|
|
98
|
+
cubest --profile file_tree .
|
|
99
|
+
|
|
100
|
+
# Nginx access.log.gz —— 顶部 URL × 状态 × 平均耗时 + p95/p99
|
|
101
|
+
cubest --profile nginx_access /var/log/nginx/access.log.gz
|
|
102
|
+
|
|
103
|
+
# 按语言统计代码行数(scc/tokei/cloc 的直接替代)
|
|
104
|
+
cubest --profile loc_counter .
|
|
105
|
+
|
|
106
|
+
# 近似调用图 → 交互式 HTML 仪表板
|
|
107
|
+
cubest --profile call_graph src/ > graph.html && open graph.html
|
|
108
|
+
|
|
109
|
+
# CSV → OLAP → ECharts 仪表板(一个 HTML 文件,无需服务器)
|
|
110
|
+
cubest -p '{
|
|
111
|
+
"dimensions": ["campaign", "device"],
|
|
112
|
+
"measures": [{"name":"impressions","type":"sum","field":"impressions"}],
|
|
113
|
+
"extract": [{"type":"preset","preset":"csv"}],
|
|
114
|
+
"output": {"format":"echarts","chart_type":"sankey"}
|
|
115
|
+
}' ads.csv > ads.html
|
|
116
|
+
|
|
117
|
+
# 从 git diff 生成 MR/PR 影响图
|
|
118
|
+
git diff --name-only origin/main...HEAD | \
|
|
119
|
+
cubest -F - --profile mr_impact .
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 📊 输出格式
|
|
123
|
+
|
|
124
|
+
**13 种输出格式** —— 选择匹配您受众的:
|
|
125
|
+
|
|
126
|
+
| 格式 | 适合场景 |
|
|
127
|
+
|--------------------|---------------------------------------------------|
|
|
128
|
+
| `tree` (默认) | 人眼阅读,终端 |
|
|
129
|
+
| `flat` | ~30% 更少 token(面包屑行) |
|
|
130
|
+
| `compact` | 仅顶层,按计数排序 |
|
|
131
|
+
| `csv` / `tsv` | 电子表格,下游工具 |
|
|
132
|
+
| `md_table` | PR/Confluence/README |
|
|
133
|
+
| `yaml` / `json` | 程序化消费 |
|
|
134
|
+
| `xml` | XML 管道 |
|
|
135
|
+
| `dot` | GraphViz → SVG/PDF |
|
|
136
|
+
| `mermaid` | GitHub/GitLab/Notion 内联 |
|
|
137
|
+
| `plantuml` | 企业文档栈 |
|
|
138
|
+
| `drawio` | draw.io / diagrams.net 导入 |
|
|
139
|
+
| `echarts` | 独立交互式 HTML,内嵌 6 种图表类型 |
|
|
140
|
+
|
|
141
|
+
**31 个内置配置文件** —— 直接使用或自定义:
|
|
142
|
+
|
|
143
|
+
完整列表见 [English README](README.md#-what-you-get) 或
|
|
144
|
+
[`profiles/`](profiles/) 目录。
|
|
145
|
+
|
|
146
|
+
## 🧪 基准测试
|
|
147
|
+
|
|
148
|
+
在 CPython 3.8、笔记本级硬件上测量(2026 年 7 月):
|
|
149
|
+
|
|
150
|
+
| 场景 | 指标 |
|
|
151
|
+
|-------------------------------|-----------------------------------------------|
|
|
152
|
+
| Cube 插入 | ~200k 记录/秒,50 万条时占用 25 MiB RSS |
|
|
153
|
+
| 扫描 1 万个小文件 | ~14k 文件/秒(`paths` 预设,不读内容) |
|
|
154
|
+
| 流式 gzip access log 处理 | ~43k 行/秒,**每 50 万行 ΔRSS <200 KiB** |
|
|
155
|
+
| 从 5 万个单元格生成 `flat` | ~1 毫秒 |
|
|
156
|
+
| 与朴素读取相比的 token 节省 | **中位数 7.2×,峰值 22.7×** |
|
|
157
|
+
|
|
158
|
+
流式处理保持恒定内存 —— 10 TB 的日志受 I/O 限制,而非内存。
|
|
159
|
+
|
|
160
|
+
## 🔁 替代常见工具
|
|
161
|
+
|
|
162
|
+
不是完全替代,但用一个文件覆盖 80% 的典型场景,无需安装工具动物园:
|
|
163
|
+
|
|
164
|
+
| 工具 | 由...替代 |
|
|
165
|
+
|-------------------------------|--------------------------------------------------|
|
|
166
|
+
| `scc` / `tokei` / `cloc` | `loc_counter` |
|
|
167
|
+
| `du -sh */` | `disk_usage` |
|
|
168
|
+
| `find + wc -l` | `file_tree` |
|
|
169
|
+
| GoAccess | `nginx_access` + `format: echarts` |
|
|
170
|
+
| `jq | sort | uniq -c` | `jsonl_events` |
|
|
171
|
+
| `yq` / `kubectl get` | `k8s_resources` |
|
|
172
|
+
| `swagger-cli` | `openapi_endpoints` |
|
|
173
|
+
| `git log --stat | awk` | `git_log_activity` |
|
|
174
|
+
| `ctags` + grep | `code_atlas` |
|
|
175
|
+
| awk 直方图 + 百分位数 | `p50/p90/p95/p99` 度量 |
|
|
176
|
+
| Screaming Frog (SEO) | `seo_audit` + `seo_semantic_tree` + `sitemap_map`|
|
|
177
|
+
| `pyan` / `graphviz-ast` | `call_graph` + `format: dot` |
|
|
178
|
+
|
|
179
|
+
## 👥 角色
|
|
180
|
+
|
|
181
|
+
| 角色 | 主要用例 |
|
|
182
|
+
|---------------------|-----------------------------------------------------------------|
|
|
183
|
+
| **AI 代理** | 紧凑仓库地图、机器可读 JSON/CSV/DOT 用于工具链、长会话上下文经济 |
|
|
184
|
+
| **开发者** | 入门、API/组件/技术债务清单、PR 预飞行 |
|
|
185
|
+
| **SRE / on-call** | 对 `.gz` 日志进行事件调查、延迟百分位数 |
|
|
186
|
+
| **DevOps** | CI 报告、K8s 清单库存、git 活动仪表板 |
|
|
187
|
+
| **数据工程师** | 对数据仓库导出进行二次 OLAP、分析汇总 |
|
|
188
|
+
| **SEO / 内容** | 站点审计、语义标题树、sitemap 分类法 |
|
|
189
|
+
|
|
190
|
+
## 📜 许可证与归属
|
|
191
|
+
|
|
192
|
+
Apache License 2.0 —— 见 [LICENSE](LICENSE) 和 [NOTICE](NOTICE)。
|
|
193
|
+
|
|
194
|
+
**归属要求(Apache 2.0 §4d)**:如果您重新分发 cubest —— 在派生作品中、
|
|
195
|
+
嵌入到您的产品中、作为托管服务、容器镜像、CLI 包装器、IDE 插件或代理模板 ——
|
|
196
|
+
您**必须**包含 NOTICE 文件(或其可读内容),保留上游 URL:
|
|
197
|
+
|
|
198
|
+
> https://github.com/BaryshevS/cubest
|
|
199
|
+
|
|
200
|
+
放置选项:分发中的 `NOTICE` / `THIRD_PARTY_NOTICES` / `ATTRIBUTION` 文件、
|
|
201
|
+
您的文档,或"关于" / "致谢" / "由...支持"屏幕。
|
|
202
|
+
|
|
203
|
+
## 🗺️ 路线图
|
|
204
|
+
|
|
205
|
+
见 [ROADMAP.md](ROADMAP.md)。
|
|
206
|
+
|
|
207
|
+
## 🤝 贡献
|
|
208
|
+
|
|
209
|
+
欢迎问题和 PR。对于实质性更改,请先开启讨论。
|
|
210
|
+
所有贡献均在 Apache 2.0 许可证下接受。
|
|
211
|
+
|
|
212
|
+
## 💖 赞助
|
|
213
|
+
|
|
214
|
+
如果 cubest 在您日常的代理工作流中节省了 token,或缩短了故障处理时间,
|
|
215
|
+
请考虑成为赞助者 —— 资金将直接用于路线图项目(t-digest、流式 CSV、
|
|
216
|
+
代理片段)以及基础设施:
|
|
217
|
+
|
|
218
|
+
- **GitHub Sponsors** → https://github.com/sponsors/BaryshevS
|
|
219
|
+
- **Open Collective** → https://opencollective.com/baryshevsv
|
|
220
|
+
|
|
221
|
+
每月 3 美元就能让项目持续运转。赞助者在 issue 处理中享有优先权,
|
|
222
|
+
并会在发布说明中获得署名。
|
|
223
|
+
|
|
224
|
+
## ⭐ 收藏此仓库
|
|
225
|
+
|
|
226
|
+
如果 cubest 为您节省了一部分 AI 预算,或将 SRE 事件缩短了一小时 ——
|
|
227
|
+
一颗星帮助他人找到它。这就是全部请求。
|
|
228
|
+
|
|
229
|
+
<p align="left">
|
|
230
|
+
<a href="https://github.com/BaryshevS/cubest/stargazers">
|
|
231
|
+
<img src="https://img.shields.io/github/stars/BaryshevS/cubest?style=social" alt="Star cubest on GitHub">
|
|
232
|
+
</a>
|
|
233
|
+
</p>
|
package/bin/cubest.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin npm wrapper — delegates to python3 cubest.py located next to this file.
|
|
3
|
+
// Requires Python 3.8+ available on PATH. Optional: pip install pyyaml.
|
|
4
|
+
|
|
5
|
+
const { spawn } = require("child_process");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
|
|
8
|
+
const script = path.resolve(__dirname, "..", "cubest.py");
|
|
9
|
+
const py = process.env.PYTHON || "python3";
|
|
10
|
+
|
|
11
|
+
const child = spawn(py, [script, ...process.argv.slice(2)], {
|
|
12
|
+
stdio: "inherit",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
child.on("error", (err) => {
|
|
16
|
+
if (err.code === "ENOENT") {
|
|
17
|
+
console.error(
|
|
18
|
+
`cubest: '${py}' not found. Install Python 3.8+ or set PYTHON env var.`
|
|
19
|
+
);
|
|
20
|
+
process.exit(127);
|
|
21
|
+
}
|
|
22
|
+
console.error("cubest: failed to spawn:", err.message);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
child.on("exit", (code, signal) => {
|
|
27
|
+
process.exit(code ?? (signal ? 1 : 0));
|
|
28
|
+
});
|