intelligems-core

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/intelligems-core

/intelligems-core

Shared library that powers all Intelligems Analytics skills. Sets up your workspace with the API client, metric helpers, and configuration.
You rarely need to run this directly — other skills (like
/test-verdict
) automatically check for the workspace and set it up if needed.

为所有Intelligems Analytics技能提供支持的共享库。用于为你的工作区配置API客户端、指标辅助工具及相关设置。
你几乎无需直接运行此库——其他技能(如
/test-verdict
)会自动检查工作区状态,若需要则自动完成设置。

What's Included

包含内容

FilePurpose
ig_client.py
API client with automatic retry and rate-limit handling
ig_metrics.py
Extract values, uplift, confidence, and CI bounds from API responses
ig_helpers.py
Formatting, runtime calculation, variation lookup
ig_config.py
Shared thresholds (80% confidence, 10-day minimum, etc.)
ig_slack.py
Slack Block Kit formatting and webhook delivery
setup_workspace.sh
Creates
~/intelligems-analytics/
with venv and dependencies
setup_automation.sh
Creates macOS LaunchAgent for scheduled Slack delivery

文件用途
ig_client.py
具备自动重试和速率限制处理功能的API客户端
ig_metrics.py
从API响应中提取数值、提升量、置信度及置信区间边界
ig_helpers.py
格式化、运行时计算、变体查询
ig_config.py
共享阈值设置(如80%置信度、最小10天周期等)
ig_slack.py
Slack Block Kit格式化及Webhook推送
setup_workspace.sh
创建包含虚拟环境及依赖项的
~/intelligems-analytics/
目录
setup_automation.sh
创建用于定时Slack推送的macOS LaunchAgent

Step 1: Get API Key

步骤1:获取API密钥

Ask the user for their Intelligems API key.
"What's your Intelligems API key? You can get one by contacting support@intelligems.io"
Never hardcode or assume an API key.

向用户索要他们的Intelligems API密钥。
“你的Intelligems API密钥是什么?你可以通过联系support@intelligems.io获取。”
绝对不要硬编码或默认假设API密钥。

Step 2: Set Up Workspace

步骤2:设置工作区

Run the setup script to create the workspace:
bash
bash setup_workspace.sh
This creates:
  • ~/intelligems-analytics/
    — working directory
  • ~/intelligems-analytics/venv/
    — Python virtual environment
  • ~/intelligems-analytics/.env
    — API key configuration
Then save the user's API key:
bash
echo "INTELLIGEMS_API_KEY=<user's key>" > ~/intelligems-analytics/.env

运行设置脚本以创建工作区:
bash
bash setup_workspace.sh
此脚本会创建:
  • ~/intelligems-analytics/
    — 工作目录
  • ~/intelligems-analytics/venv/
    — Python虚拟环境
  • ~/intelligems-analytics/.env
    — API密钥配置文件
然后保存用户的API密钥:
bash
echo "INTELLIGEMS_API_KEY=<user's key>" > ~/intelligems-analytics/.env

Step 3: Copy Core Libraries

步骤3:复制核心库

Copy all files from
references/
into the workspace:
bash
cp references/ig_client.py ~/intelligems-analytics/
cp references/ig_metrics.py ~/intelligems-analytics/
cp references/ig_helpers.py ~/intelligems-analytics/
cp references/ig_config.py ~/intelligems-analytics/

references/
目录下的所有文件复制到工作区:
bash
cp references/ig_client.py ~/intelligems-analytics/
cp references/ig_metrics.py ~/intelligems-analytics/
cp references/ig_helpers.py ~/intelligems-analytics/
cp references/ig_config.py ~/intelligems-analytics/

Step 4: Verify

步骤4:验证

Activate the environment and verify the client works:
bash
source ~/intelligems-analytics/venv/bin/activate
python3 -c "
from ig_client import IntelligemsAPI
from dotenv import load_dotenv
import os
load_dotenv()
api = IntelligemsAPI(os.getenv('INTELLIGEMS_API_KEY'))
tests = api.get_active_experiments()
print(f'Connected. Found {len(tests)} active experiment(s).')
"
If successful, the workspace is ready for any Intelligems Analytics skill.
激活虚拟环境并验证客户端是否正常工作:
bash
source ~/intelligems-analytics/venv/bin/activate
python3 -c "
from ig_client import IntelligemsAPI
from dotenv import load_dotenv
import os
load_dotenv()
api = IntelligemsAPI(os.getenv('INTELLIGEMS_API_KEY'))
tests = api.get_active_experiments()
print(f'Connected. Found {len(tests)} active experiment(s).')
"
如果验证成功,工作区就可以用于任何Intelligems Analytics技能了。