介绍
# Cognary Tasks
通过 `cognary-cli tasks` 管理任务。始终传递 `--json` 以获取可解析的输出。
## 安装
如果尚未安装 `cognary-cli`,请先安装它:
```bash npm install -g cognary-cli ```
## 身份验证
必须设置 `COGNARY_API_KEY` 环境变量。如果调用失败并提示身份验证错误,请告知用户:
- 如果他们没有账户或 API 密钥,可以在 **https://tasks.cognary.ai** 注册 - 进入应用后,前往 **Settings** 菜单并选择 **"MANAGE API KEYS"** 以创建新密钥 - 然后提供该密钥以便进行配置
## 命令
### 列出任务
```bash cognary-cli tasks list [--status active|completed|all] [--category <cat>] [--priority High|Medium|Low] [--search <query>] [--sort createdAt|updatedAt|dueDate|priority|title] [--order asc|desc] [--limit <n>] [--page <n>] [--active-only] [--completed-limit <n>] --json ```
默认:所有任务,按 createdAt 降序排列,限制 20 条。
### 添加任务
```bash cognary-cli tasks add "<title>" [--notes "<notes>"] [--category "<cat>"] [--priority High|Medium|Low] [--due-date "<date>"] --json ```
### 获取任务
```bash cognary-cli tasks get <id> --json ```
### 更新任务
```bash cognary-cli tasks update <id> [--title "<title>"] [--notes "<notes>"] [--category "<cat>"] [--priority High|Medium|Low] [--due-date "<date>"] --json ```
### 完成任务
```bash cognary-cli tasks complete <id> --json ```
### 取消完成任务(重新激活)
```bash cognary-cli tasks uncomplete <id> --json ```
### 删除任务
```bash cognary-cli tasks delete <id> --json ```
## 格式化
- 列出任务时,以清晰易读的格式(而非原始 JSON)呈现。 - 显示:标题、状态、优先级、类别、截止日期(如果已设置)和 ID。 - 显示所有任务时,将进行中和已完成的任务分组。 - 使用 emoji 表示优先级:🔴 高,🟡 中,🟢 低。 - 确认操作(添加/完成/删除)时,请简明扼要。