cortex-mine
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKnowledge Cortex — Mine
Knowledge Cortex — 挖掘
Mine your Gmail history into structured flat files — contacts, clients, communications, and key facts — stored in . No server required. Files you own.
~/.cortex/将你的Gmail历史记录提取为结构化扁平文件——包括联系人、客户、沟通内容和关键事实——存储在目录下。无需服务器,数据完全归你所有。
~/.cortex/When invoked
触发场景
Read for the storage format before any file operations.
{skill_path}/references/file-schema.md在进行任何文件操作前,请阅读了解存储格式。
{skill_path}/references/file-schema.mdCommands
指令对应操作
| What user says | Action |
|---|---|
| "run the cortex" / "cortex run" | Run mining pass |
| "cortex dry run" | Mine without writing — pass |
| "cortex from DATE" | Mine from specific date — pass |
| "set up the cortex" | Run first-time setup |
| 用户指令 | 执行操作 |
|---|---|
| "run the cortex" / "cortex run" | 执行挖掘任务 |
| "cortex dry run" | 执行模拟挖掘(不写入文件)——传递 |
| "cortex from DATE" | 从指定日期开始挖掘——传递 |
| "set up the cortex" | 执行首次设置 |
Setup (first run)
首次设置(首次运行时)
Check prerequisites:
bash
which gws || echo "MISSING: npm install -g @googleworkspace/cli"
python3 -c "import anthropic" 2>/dev/null || echo "MISSING: pip install anthropic"
ls ~/.cortex/state.json 2>/dev/null || echo "FIRST RUN"If missing: tell user then .
If missing: tell user (or on managed Python).
If first run: initialise storage.
gwsnpm install -g @googleworkspace/cligws auth setupanthropicpip install anthropicpip install anthropic --break-system-packagesbash
mkdir -p ~/.cortex/originals
echo '{}' > ~/.cortex/contacts.json
echo '{}' > ~/.cortex/clients.json
touch ~/.cortex/communications.jsonl ~/.cortex/knowledge.jsonl ~/.cortex/files.jsonlWrite :
~/.cortex/state.jsonjson
{"version":"1.0","cursors":{"gmail":null},"last_run":null,"totals":{"contacts":0,"clients":0,"communications":0,"knowledge":0,"files":0},"runs":[]}检查依赖项:
bash
which gws || echo "MISSING: npm install -g @googleworkspace/cli"
python3 -c "import anthropic" 2>/dev/null || echo "MISSING: pip install anthropic"
ls ~/.cortex/state.json 2>/dev/null || echo "FIRST RUN"如果缺少:告知用户执行,然后运行。
如果缺少模块:告知用户执行(在托管Python环境中可使用)。
如果是首次运行:初始化存储目录。
gwsnpm install -g @googleworkspace/cligws auth setupanthropicpip install anthropicpip install anthropic --break-system-packagesbash
mkdir -p ~/.cortex/originals
echo '{}' > ~/.cortex/contacts.json
echo '{}' > ~/.cortex/clients.json
touch ~/.cortex/communications.jsonl ~/.cortex/knowledge.jsonl ~/.cortex/files.jsonl创建文件:
~/.cortex/state.jsonjson
{"version":"1.0","cursors":{"gmail":null},"last_run":null,"totals":{"contacts":0,"clients":0,"communications":0,"knowledge":0,"files":0},"runs":[]}Mining
挖掘操作
bash
python3 {skill_path}/scripts/cortex-mine.py
python3 {skill_path}/scripts/cortex-mine.py --dry-run
python3 {skill_path}/scripts/cortex-mine.py --from 2024-01-01
python3 {skill_path}/scripts/cortex-mine.py --batch-size 25The script prints a run report on completion. Show it to the user verbatim.
Common errors:
- — install gws CLI
gws: command not found - /
AuthError— run403gws auth setup - — set env var or add to
ANTHROPIC_API_KEY not set~/.cortex/.env - —
ModuleNotFoundError: anthropicpip install anthropic
bash
python3 {skill_path}/scripts/cortex-mine.py
python3 {skill_path}/scripts/cortex-mine.py --dry-run
python3 {skill_path}/scripts/cortex-mine.py --from 2024-01-01
python3 {skill_path}/scripts/cortex-mine.py --batch-size 25脚本运行完成后会输出运行报告,请将报告原封不动地展示给用户。
常见错误:
- — 安装gws CLI
gws: command not found - /
AuthError— 运行403gws auth setup - — 设置环境变量或添加到
ANTHROPIC_API_KEY not set文件中~/.cortex/.env - — 执行
ModuleNotFoundError: anthropicpip install anthropic
Scheduling
任务调度
- Claude Code Desktop: Cowork > Scheduled > New Task > > Daily
Run the cortex-mine skill - CLI:
/loop 24h run the cortex-mine skill - Cron:
0 6 * * * cd ~ && ANTHROPIC_API_KEY=sk-... python3 /path/to/cortex-mine.py
- Claude Code Desktop:Cowork > Scheduled > New Task > > 每日
Run the cortex-mine skill - CLI:
/loop 24h run the cortex-mine skill - Cron:
0 6 * * * cd ~ && ANTHROPIC_API_KEY=sk-... python3 /path/to/cortex-mine.py
Exporting data
数据导出
See for patterns to export cortex data to Obsidian, SQLite, Notion, CRM systems, or custom APIs.
{skill_path}/references/export-adapters.md请查看,了解将cortex数据导出到Obsidian、SQLite、Notion、CRM系统或自定义API的实现方案。
{skill_path}/references/export-adapters.mdEnvironment
环境变量
| Variable | Default | Purpose |
|---|---|---|
| | Storage root |
| — | Required for extraction |
| | Threads per run |
| — | Your email — excluded from contacts |
| 变量名 | 默认值 | 用途 |
|---|---|---|
| | 存储根目录 |
| — | 提取功能必需参数 |
| | 每次运行的线程数 |
| — | 你的邮箱地址——会被排除在联系人列表之外 |
References
参考文档
- File schemas:
{skill_path}/references/file-schema.md - Pre-filter rules:
{skill_path}/references/prefilter-patterns.md - Export patterns:
{skill_path}/references/export-adapters.md
- 文件格式:
{skill_path}/references/file-schema.md - 预过滤规则:
{skill_path}/references/prefilter-patterns.md - 导出方案:
{skill_path}/references/export-adapters.md