Metadata-Version: 2.4
Name: aicorkit
Version: 0.1.6
Summary: AI-powered desktop tool orchestration CLI
License:                                  Apache License
                                   Version 2.0, January 2004
                                http://www.apache.org/licenses/
        
           TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
        
           1. Definitions.
        
              "License" shall mean the terms and conditions for use, reproduction,
              and distribution as defined by Sections 1 through 9 of this document.
        
              "Licensor" shall mean the copyright owner or entity authorized by
              the copyright owner that is granting the License.
        
              "Legal Entity" shall mean the union of the acting entity and all
              other entities that control, are controlled by, or are under common
              control with that entity. For the purposes of this definition,
              "control" means (i) the power, direct or indirect, to cause the
              direction or management of such entity, whether by contract or
              otherwise, or (ii) ownership of fifty percent (50%) or more of the
              outstanding shares, or (iii) beneficial ownership of such entity.
        
              "You" (or "Your") shall mean an individual or Legal Entity
              exercising permissions granted by this License.
        
              "Source" form shall mean the preferred form for making modifications,
              including but not limited to software source code, documentation
              source, and configuration files.
        
              "Object" form shall mean any form resulting from mechanical
              transformation or translation of a Source form, including but
              not limited to compiled object code, generated documentation,
              and conversions to other media types.
        
              "Work" shall mean the work of authorship, whether in Source or
              Object form, made available under the License, as indicated by a
              copyright notice that is included in or attached to the work
              (an example is provided in the Appendix below).
        
              "Derivative Works" shall mean any work, whether in Source or Object
              form, that is based on (or derived from) the Work and for which the
              editorial revisions, annotations, elaborations, or other modifications
              represent, as a whole, an original work of authorship. For the purposes
              of this License, Derivative Works shall not include works that remain
              separable from, or merely link (or bind by name) to the interfaces of,
              the Work and Derivative Works thereof.
        
              "Contribution" shall mean any work of authorship, including
              the original version of the Work and any modifications or additions
              to that Work or Derivative Works thereof, that is intentionally
              submitted to Licensor for inclusion in the Work by the copyright owner
              or by an individual or Legal Entity authorized to submit on behalf of
              the copyright owner. For the purposes of this definition, "submitted"
              means any form of electronic, verbal, or written communication sent
              to the Licensor or its representatives, including but not limited to
              communication on electronic mailing lists, source code control systems,
              and issue tracking systems that are managed by, or on behalf of, the
              Licensor for the purpose of discussing and improving the Work, but
              excluding communication that is conspicuously marked or otherwise
              designated in writing by the copyright owner as "Not a Contribution."
        
              "Contributor" shall mean Licensor and any individual or Legal Entity
              on behalf of whom a Contribution has been received by Licensor and
              subsequently incorporated within the Work.
        
           2. Grant of Copyright License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              copyright license to reproduce, prepare Derivative Works of,
              publicly display, publicly perform, sublicense, and distribute the
              Work and such Derivative Works in Source or Object form.
        
           3. Grant of Patent License. Subject to the terms and conditions of
              this License, each Contributor hereby grants to You a perpetual,
              worldwide, non-exclusive, no-charge, royalty-free, irrevocable
              (except as stated in this section) patent license to make, have made,
              use, offer to sell, sell, import, and otherwise transfer the Work,
              where such license applies only to those patent claims licensable
              by such Contributor that are necessarily infringed by their
              Contribution(s) alone or by combination of their Contribution(s)
              with the Work to which such Contribution(s) was submitted. If You
              institute patent litigation against any entity (including a
              cross-claim or counterclaim in a lawsuit) alleging that the Work
              or a Contribution incorporated within the Work constitutes direct
              or contributory patent infringement, then any patent licenses
              granted to You under this License for that Work shall terminate
              as of the date such litigation is filed.
        
           4. Redistribution. You may reproduce and distribute copies of the
              Work or Derivative Works thereof in any medium, with or without
              modifications, and in Source or Object form, provided that You
              meet the following conditions:
        
              (a) You must give any other recipients of the Work or
                  Derivative Works a copy of this License; and
        
              (b) You must cause any modified files to carry prominent notices
                  stating that You changed the files; and
        
              (c) You must retain, in the Source form of any Derivative Works
                  that You distribute, all copyright, patent, trademark, and
                  attribution notices from the Source form of the Work,
                  excluding those notices that do not pertain to any part of
                  the Derivative Works; and
        
              (d) If the Work includes a "NOTICE" text file as part of its
                  distribution, then any Derivative Works that You distribute must
                  include a readable copy of the attribution notices contained
                  within such NOTICE file, excluding those notices that do not
                  pertain to any part of the Derivative Works, in at least one
                  of the following places: within a NOTICE text file distributed
                  as part of the Derivative Works; within the Source form or
                  documentation, if provided along with the Derivative Works; or,
                  within a display generated by the Derivative Works, if and
                  wherever such third-party notices normally appear. The contents
                  of the NOTICE file are for informational purposes only and
                  do not modify the License. You may add Your own attribution
                  notices within Derivative Works that You distribute, alongside
                  or as an addendum to the NOTICE text from the Work, provided
                  that such additional attribution notices cannot be construed
                  as modifying the License.
        
              You may add Your own copyright statement to Your modifications and
              may provide additional or different license terms and conditions
              for use, reproduction, or distribution of Your modifications, or
              for any such Derivative Works as a whole, provided Your use,
              reproduction, and distribution of the Work otherwise complies with
              the conditions stated in this License.
        
           5. Submission of Contributions. Unless You explicitly state otherwise,
              any Contribution intentionally submitted for inclusion in the Work
              by You to the Licensor shall be under the terms and conditions of
              this License, without any additional terms or conditions.
              Notwithstanding the above, nothing herein shall supersede or modify
              the terms of any separate license agreement you may have executed
              with Licensor regarding such Contributions.
        
           6. Trademarks. This License does not grant permission to use the trade
              names, trademarks, service marks, or product names of the Licensor,
              except as required for reasonable and customary use in describing the
              origin of the Work and reproducing the content of the NOTICE file.
        
           7. Disclaimer of Warranty. Unless required by applicable law or
              agreed to in writing, Licensor provides the Work (and each
              Contributor provides its Contributions) on an "AS IS" BASIS,
              WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
              implied, including, without limitation, any warranties or conditions
              of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
              PARTICULAR PURPOSE. You are solely responsible for determining the
              appropriateness of using or redistributing the Work and assume any
              risks associated with Your exercise of permissions under this License.
        
           8. Limitation of Liability. In no event and under no legal theory,
              whether in tort (including negligence), contract, or otherwise,
              unless required by applicable law (such as deliberate and grossly
              negligent acts) or agreed to in writing, shall any Contributor be
              liable to You for damages, including any direct, indirect, special,
              incidental, or consequential damages of any character arising as a
              result of this License or out of the use or inability to use the
              Work (including but not limited to damages for loss of goodwill,
              work stoppage, computer failure or malfunction, or any and all
              other commercial damages or losses), even if such Contributor
              has been advised of the possibility of such damages.
        
           9. Accepting Warranty or Additional Liability. While redistributing
              the Work or Derivative Works thereof, You may choose to offer,
              and charge a fee for, acceptance of support, warranty, indemnity,
              or other liability obligations and/or rights consistent with this
              License. However, in accepting such obligations, You may act only
              on Your own behalf and on Your sole responsibility, not on behalf
              of any other Contributor, and only if You agree to indemnify,
              defend, and hold each Contributor harmless for any liability
              incurred by, or claims asserted against, such Contributor by reason
              of your accepting any such warranty or additional liability.
        
           END OF TERMS AND CONDITIONS
        
           APPENDIX: How to apply the Apache License to your work.
        
              To apply the Apache License to your work, attach the following
              boilerplate notice, with the fields enclosed by brackets "[]"
              replaced with your own identifying information. (Don't include
              the brackets!)  The text should be enclosed in the appropriate
              comment syntax for the file format. We also recommend that a
              file or class name and description of purpose be included on the
              same "printed page" as the copyright notice for easier
              identification within third-party archives.
        
           Copyright [yyyy] [name of copyright owner]
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
               http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
        
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: pywin32>=306; platform_system == "Windows"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Provides-Extra: meeting
Requires-Dist: sounddevice>=0.4.6; extra == "meeting"
Requires-Dist: numpy>=1.24; extra == "meeting"
Requires-Dist: soundfile>=0.12; extra == "meeting"
Requires-Dist: openai>=1.0; extra == "meeting"
Requires-Dist: dashscope>=1.20; extra == "meeting"
Requires-Dist: pywinauto>=0.6.9; extra == "meeting"
Requires-Dist: pyautogui>=0.9; extra == "meeting"
Provides-Extra: all
Requires-Dist: aicorkit[meeting]; extra == "all"
Requires-Dist: aicorkit[graph]; extra == "all"
Provides-Extra: graph
Requires-Dist: numpy>=1.24; extra == "graph"
Requires-Dist: dashscope>=1.20; extra == "graph"
Requires-Dist: openai>=1.0; extra == "graph"
Requires-Dist: markitdown[docx,pdf,pptx,xls,xlsx]>=0.1.6; extra == "graph"
Dynamic: license-file

# aicorkit

面向 AI Agent（Kiro / Claude 等）的 **Windows 桌面自动化 CLI**。通过 pywin32 直接驱动 Outlook COM，并提供本地知识库（Graph / Memory Tree）、会议语音管道等能力。

## 环境要求

- **Python 3.11+**
- **Windows**（Outlook COM、会议音频依赖 Windows 主机）
- Outlook 桌面客户端已安装并登录（使用邮件/日历时）
- 可选：`DASHSCOPE_API_KEY`（会议 STT/TTS、Graph 向量 embedding）

## 安装

### 从源码安装

```powershell
cd D:\CODE\aicorkit
pip install -e .
```

### 可选依赖

| 包 | 用途 | 命令 |
|----|------|------|
| `[graph]` | 知识库向量检索（numpy、dashscope、openai） | `pip install -e ".[graph]"` |
| `[meeting]` | 会议 STT → LLM → TTS 管道 | `pip install -e ".[meeting]"` |
| `[dev]` | 开发测试 | `pip install -e ".[dev]"` |
| `[all]` | graph + meeting | `pip install -e ".[all]"` |

### Windows 运行方式

若 `aicorkit` 不在 PATH，可用模块方式调用（推荐）：

```powershell
python -m aicorkit --help
python -m aicorkit graph status
```

pip 脚本目录常见位置：`%AppData%\Roaming\Python\Python313\Scripts`（可按需加入 PATH）。

## 配置

配置分两层，**项目级覆盖全局**：

| 层级 | 路径 |
|------|------|
| 全局 | `~/.aicorkit/config.yaml` |
| 项目 | `<项目根>/.aicorkit/config.yaml`（从当前目录向上查找最近一份） |

```powershell
python -m aicorkit config init
python -m aicorkit config show
python -m aicorkit config paths
python -m aicorkit config set backend kiro
python -m aicorkit config set graph.embed.provider dashscope
python -m aicorkit config set atlassian.jira_url https://jira.example.com
python -m aicorkit config set atlassian.confluence_url https://wiki.example.com
```

凭据写入 `~/.aicorkit/secrets.env`（勿提交 git）：

```
ATLASSIAN_USERNAME=your_user
ATLASSIAN_PASSWORD=your_password
```

项目级示例（仓库根目录 `.aicorkit/config.yaml`）：

```yaml
graph:
  workspace: .aicorkit/memory    # 项目独立知识库目录

graph_sources:
  - id: repo-docs
    kind: folder
    label: 项目文档
    enabled: true
    path: ./docs
    glob: "**/*.md"
```

列表字段（如 `graph_sources`）会被项目 config **整段替换**，不会与全局逐项合并。

## 使用说明

### Outlook

```powershell
# 只读
python -m aicorkit outlook list-emails -f Inbox -c 10
python -m aicorkit outlook read-email -q "季度报告"
python -m aicorkit outlook list-calendar -d 7
python -m aicorkit outlook shared-calendar --email boss@company.com -d 7
python -m aicorkit outlook free-busy --email colleague@company.com -d 3
python -m aicorkit outlook list-rooms

# 写入（Agent 执行前需用户确认）
python -m aicorkit outlook send-email --to "a@b.com" --subject "Hi" --body "Hello"
python -m aicorkit outlook create-meeting `
  --subject "Sprint Review" `
  --start "2026-06-08 14:00" `
  --duration 60 `
  --attendees "team@company.com"
```

| 命令 | 说明 |
|------|------|
| `outlook list-emails` | 列出收件箱/已发送邮件 |
| `outlook read-email` | 按主题关键词搜索并读取 |
| `outlook send-email` | 发送邮件 |
| `outlook list-calendar` | 查看近期日程 |
| `outlook create-meeting` | 创建会议邀请 |
| `outlook shared-calendar` | 查看他人共享日历 |
| `outlook free-busy` | 查看他人忙闲 |
| `outlook list-rooms` | 常用会议室 |

### Meeting（会议语音）

需 `pip install -e ".[meeting]"` 和 `DASHSCOPE_API_KEY`。会议 LLM 默认使用 **cursor-agent**（`meeting.backend: cursor`），与顶层 `backend` 独立。

```powershell
python -m aicorkit meeting listen          # STT → LLM → TTS
python -m aicorkit meeting auto-answer
python -m aicorkit meeting start           # listen + auto-answer

python -m aicorkit config set meeting.backend cursor   # 默认已是 cursor
python -m aicorkit config set meeting.backend kiro     # 改回 kiro-cli
python -m aicorkit config set meeting.graph_archive true
```

### Jira / Confluence

需配置 `atlassian.jira_url`、`atlassian.confluence_url` 与 `secrets.env` 凭据。

```powershell
# 连接测试
python -m aicorkit atlassian test

# Jira 只读
python -m aicorkit jira search --jql "assignee = currentUser() AND status != Done"
python -m aicorkit jira get-issue CMS-123
python -m aicorkit jira list-boards --project CMS
python -m aicorkit jira list-sprints --board-id 945 --state active

# Confluence 只读
python -m aicorkit confluence search --space AESCESS -q "API"
python -m aicorkit confluence list-pages --space AESCESS
python -m aicorkit confluence get-page --id 13069892

# 写入（需 --yes，Agent 须先征得用户确认）
python -m aicorkit jira add-comment CMS-123 --body "..." --yes
python -m aicorkit jira transition CMS-123 --to "In Progress" --yes
python -m aicorkit confluence update-page --id 123 --version 5 --body "..." --yes
```

| 命令组 | 只读 | 写入（需 `--yes`） |
|--------|------|---------------------|
| `jira` | search, list-issues, get-issue, list-comments, list-projects, list-boards, list-sprints, list-board-issues | create-issue, add-comment, transition, update-issue |
| `confluence` | search, list-spaces, list-pages, get-page | update-page, add-comment |

### Graph 知识库

本地 **SQLite + Obsidian 兼容 wiki/**，支持入库、检索、摘要树、实体图。

**数据位置**

| 项 | 默认路径 |
|----|----------|
| 全局 workspace | `~/.aicorkit/memory/` |
| 项目 workspace | `<项目>/.aicorkit/memory/` |
| 数据库 | `chunks.db` |
| Vault | `wiki/` |
| 精编记忆 | `~/.aicorkit/MEMORY.md`（可配置） |

**一键 setup（推荐）**

```powershell
# 最小：init + notes 源 + INDEX + dashboard
python -m aicorkit graph setup --yes

# 完整：项目 config + 文档 + Outlook + 同步 + skill
python -m aicorkit graph setup --yes --project --docs ./docs --outlook --sync --skill-platform cursor
```

**初始化与状态**

```powershell
python -m aicorkit graph init
python -m aicorkit graph status
```

**入库**（写入操作需 `--yes`）

```powershell
python -m aicorkit graph ingest document `
  --source-id "proj:design" --title "设计" --body-file ./design.md --yes

python -m aicorkit graph ingest file --path ./note.md --source-id "notes:manual" --yes

python -m aicorkit graph ingest email --from outlook --folder Inbox -c 20 --yes

python -m aicorkit graph ingest chat --source-id "chat:s1" --file turns.json --yes
Get-Content turns.json -Raw | python -m aicorkit graph ingest chat --source-id "chat:s1" --stdin --yes

python -m aicorkit graph ingest meeting --file meeting.json --yes
```

**数据源同步**

```powershell
python -m aicorkit graph source list
python -m aicorkit graph source add --kind folder --label "文档" --path D:/docs --yes
python -m aicorkit graph source add --kind outlook --label "收件箱" --folder Inbox --yes
python -m aicorkit graph source sync --all --yes
```

支持 `folder` / `outlook` / `web` / `notes`。

**检索**（只读，Agent 可直接调用）

```powershell
python -m aicorkit graph search "知识库架构"
python -m aicorkit graph search "设计" --mode hybrid -n 10
python -m aicorkit graph search --entity "项目"
python -m aicorkit graph fetch --chunk-ids "chunk_id1,chunk_id2"

python -m aicorkit graph query source --id docs:design -d 7
python -m aicorkit graph query global -d 1
python -m aicorkit graph query topic --entity "知识库"
python -m aicorkit graph drill --node-id <node_id> --depth 2
python -m aicorkit graph walk "上周会议结论" -n 5
```

向量检索需配置 embedding：

```powershell
python -m aicorkit config set graph.embed.provider dashscope   # DASHSCOPE_API_KEY
python -m aicorkit config set graph.embed.provider ollama       # 本地 Ollama
python -m aicorkit config set graph.embed.provider openai        # OpenAI-compatible
```

**Worker 与摘要树**

入库后异步处理：打分 → 实体抽取 → embedding → buffer → seal（L1/L2 摘要，Source / Topic / Global 三棵树）。

```powershell
python -m aicorkit graph worker run-once
python -m aicorkit graph worker start
python -m aicorkit graph worker status
python -m aicorkit graph tree list --kind topic
python -m aicorkit graph tree digest --yes
python -m aicorkit graph entity list --hot
python -m aicorkit graph export -o graph.json
```

**Vault 与运维**

```powershell
python -m aicorkit graph vault open
python -m aicorkit graph vault index --yes
python -m aicorkit graph dashboard --yes
python -m aicorkit graph memory show
python -m aicorkit graph archivist file ./session.json --yes
python -m aicorkit graph daemon start --once
```

Obsidian 打开 vault 目录（`graph vault path` 输出路径），浏览 `INDEX.md` 与双链。

### Skill 生成

为 Agent 生成技能文件（默认 **一次生成三个**）：

```powershell
# 默认：aicorkit-outlook + aicorkit-graph + aicorkit-atlassian
python -m aicorkit skill -p cursor
python -m aicorkit skill -p kiro
python -m aicorkit skill -p claude

# 仅 Jira / Confluence
python -m aicorkit skill -p cursor --atlassian

# 仅 Outlook / meeting
python -m aicorkit skill -p cursor --outlook

# 仅知识库 Graph
python -m aicorkit skill -p cursor --graph
```

| 平台 | aicorkit-outlook | aicorkit-graph | aicorkit-atlassian |
|------|------------------|----------------|---------------------|
| Claude | `.claude/skills/aicorkit-outlook/` | `.claude/skills/aicorkit-graph/` | `.claude/skills/aicorkit-atlassian/` |
| Kiro | `.kiro/skills/aicorkit-outlook/` | `.kiro/skills/aicorkit-graph/` | `.kiro/skills/aicorkit-atlassian/` |
| Cursor | `.cursor/skills/aicorkit-outlook/` | `.cursor/skills/aicorkit-graph/` | `.cursor/skills/aicorkit-atlassian/` |

### Agent 确认规则

| 类型 | 示例 | 需要用户确认 |
|------|------|--------------|
| 只读 | `graph search` / `jira get-issue` / `confluence get-page` | 否 |
| 写入 | `graph ingest` / `jira add-comment` / `confluence update-page` / `outlook send-email` | 是（Jira/Confluence/Graph 用 `--yes`） |

## 调试

### 常见问题

**`python` 或 `aicorkit` 找不到**

- 使用 `python -m aicorkit ...` 代替直接调用 `aicorkit`
- 确认 Python 3.11+：`python --version`
- 开发安装：`pip install -e .`

**Outlook 报错 / 无响应**

- 确认 Outlook 桌面版已启动并登录
- 首次 COM 调用可能弹出授权对话框，需允许
- 在 PowerShell 中单独测试：`python -m aicorkit outlook list-emails -c 3`

**Graph `worker run-once` 返回 `processed: 0`**

- 正常：sync 内部已跑过 worker，队列已空
- 新 ingest 后若 job 堆积：`python -m aicorkit graph worker run-once`

**向量检索无结果**

- 检查 `graph.embed.provider` 是否为 `none`
- DashScope 需设置 `DASHSCOPE_API_KEY`
- 切换 provider 后需重新 ingest 以生成向量

**项目 config 未生效**

- 确认在项目目录下执行命令
- `python -m aicorkit config paths` 查看是否识别到 `project_config`

### 查看配置与路径

```powershell
python -m aicorkit config paths
python -m aicorkit config show
python -m aicorkit graph status
python -m aicorkit graph vault path
python -m aicorkit graph worker status
```

### 开发调试

```powershell
pip install -e ".[dev]"
pytest
```

Graph 设计细节见 [`docs/design-graph-knowledge-base.md`](docs/design-graph-knowledge-base.md)。

## 项目结构

```
aicorkit/
├── pyproject.toml
├── README.md
├── docs/
│   └── design-graph-knowledge-base.md
└── aicorkit/
    ├── cli.py              # 主 CLI（outlook / meeting / config / skill）
    ├── config.py           # 全局 + 项目 config 合并
    ├── outlook.py          # Outlook COM
    ├── skill.py            # SKILL.md 生成
    ├── meeting/            # 会议 STT/LLM/TTS
    ├── llm/                # ACP 后端
    └── graph/              # 本地知识库
        ├── ingest.py       # 入库
        ├── retrieval/      # search / query / walk
        ├── pipeline/       # worker / jobs
        ├── tree/           # 摘要树 seal
        ├── sources/        # folder / outlook / web / notes
        ├── store/          # SQLite + vectors
        └── vault/          # Obsidian hub / INDEX
```

## 工作原理（Outlook）

```
python -m aicorkit outlook list-emails
  → aicorkit/outlook.py
    → pywin32 → Outlook.Application COM
      → MAPI → Inbox → JSON 输出
```

Python 通过 pywin32 直接与 Outlook COM 通信，无需 MCP 服务器或 HTTP 中间层。

## 扩展新工具

1. 在 `aicorkit/` 下新增模块（如 `foo.py`）
2. 在 `aicorkit/cli.py` 注册 Click 子命令
3. 更新 `aicorkit/skill.py` 并运行 `python -m aicorkit skill -p kiro`
