cortex-mine

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Knowledge Cortex — Mine

Knowledge Cortex — 挖掘

Mine your Gmail history into structured flat files — contacts, clients, communications, and key facts — stored in
~/.cortex/
. No server required. Files you own.
将你的Gmail历史记录提取为结构化扁平文件——包括联系人、客户、沟通内容和关键事实——存储在
~/.cortex/
目录下。无需服务器,数据完全归你所有。

When invoked

触发场景

Read
{skill_path}/references/file-schema.md
for the storage format before any file operations.
在进行任何文件操作前,请阅读
{skill_path}/references/file-schema.md
了解存储格式。

Commands

指令对应操作

What user saysAction
"run the cortex" / "cortex run"Run mining pass
"cortex dry run"Mine without writing — pass
--dry-run
"cortex from DATE"Mine from specific date — pass
--from YYYY-MM-DD
"set up the cortex"Run first-time setup
用户指令执行操作
"run the cortex" / "cortex run"执行挖掘任务
"cortex dry run"执行模拟挖掘(不写入文件)——传递
--dry-run
参数
"cortex from DATE"从指定日期开始挖掘——传递
--from YYYY-MM-DD
参数
"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
gws
missing: tell user
npm install -g @googleworkspace/cli
then
gws auth setup
. If
anthropic
missing: tell user
pip install anthropic
(or
pip install anthropic --break-system-packages
on managed Python). If first run: initialise storage.
bash
mkdir -p ~/.cortex/originals
echo '{}' > ~/.cortex/contacts.json
echo '{}' > ~/.cortex/clients.json
touch ~/.cortex/communications.jsonl ~/.cortex/knowledge.jsonl ~/.cortex/files.jsonl
Write
~/.cortex/state.json
:
json
{"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"
如果缺少
gws
:告知用户执行
npm install -g @googleworkspace/cli
,然后运行
gws auth setup
。 如果缺少
anthropic
模块:告知用户执行
pip install anthropic
(在托管Python环境中可使用
pip install anthropic --break-system-packages
)。 如果是首次运行:初始化存储目录。
bash
mkdir -p ~/.cortex/originals
echo '{}' > ~/.cortex/contacts.json
echo '{}' > ~/.cortex/clients.json
touch ~/.cortex/communications.jsonl ~/.cortex/knowledge.jsonl ~/.cortex/files.jsonl
创建
~/.cortex/state.json
文件:
json
{"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 25
The script prints a run report on completion. Show it to the user verbatim.
Common errors:
  • gws: command not found
    — install gws CLI
  • AuthError
    /
    403
    — run
    gws auth setup
  • ANTHROPIC_API_KEY not set
    — set env var or add to
    ~/.cortex/.env
  • ModuleNotFoundError: anthropic
    pip 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: command not found
    — 安装gws CLI
  • AuthError
    /
    403
    — 运行
    gws auth setup
  • ANTHROPIC_API_KEY not set
    — 设置环境变量或添加到
    ~/.cortex/.env
    文件中
  • ModuleNotFoundError: anthropic
    — 执行
    pip install anthropic

Scheduling

任务调度

  • Claude Code Desktop: Cowork > Scheduled > New Task >
    Run the cortex-mine skill
    > Daily
  • 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
{skill_path}/references/export-adapters.md
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的实现方案。

Environment

环境变量

VariableDefaultPurpose
CORTEX_DIR
~/.cortex
Storage root
ANTHROPIC_API_KEY
Required for extraction
CORTEX_BATCH_SIZE
50
Threads per run
CORTEX_OWNER_EMAIL
Your email — excluded from contacts
变量名默认值用途
CORTEX_DIR
~/.cortex
存储根目录
ANTHROPIC_API_KEY
提取功能必需参数
CORTEX_BATCH_SIZE
50
每次运行的线程数
CORTEX_OWNER_EMAIL
你的邮箱地址——会被排除在联系人列表之外

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