Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ docs/codebase.md
docs/llm-wiki.md
roadmap_jael.md
validation/
teamwiki/
docs/designs/code-knowledge-graph.md
101 changes: 72 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,42 @@ The CLI picks a provider automatically from the repo URL:

| Command | Description |
|---------|-------------|
| `teamai init [--scope <user\|project>] [--role <id>] [--force]` | Initialize (auto-installs gf CLI, OAuth login, links repo, registers member, configures reviewers, injects hooks) |
| `teamai push [--all] [--role <id>]` | Push local new resources to a dedicated branch and open a Merge Request; new skills prompt interactively for a target namespace (override with `--role`) |
| `teamai pull [--silent]` | Pull team resources and inject them into local AI tools (both scopes pulled sequentially) |
| `teamai status` | Show the diff between local and the team repo |
| `teamai list [type] [--source repo\|local\|all] [--agent <id>]` | List resources (skills\|rules\|docs\|env\|wiki). With `--source local` or `all`, scans skills directories of installed AI agents and tags each skill's origin (`[team]` / `[builtin]` / `[source:<name>]` / `[local-only]`) |
| `teamai skill [list\|show <name>]` | List all skills by default; `show <name>` prints the skill's origin, contributors, installed-agent list, and description summary |
| `teamai members` | List registered team members |
| `teamai remove <type> <name>` | Remove a resource from both the team repo and local, then open an MR (skills\|rules\|wiki) |
| `teamai roles` | Manage team roles (`init`/`list`/`set`/`add`/`remove`/`update`) |
| `teamai source` | Manage cross-team skill subscription sources (`add`/`remove`/`list`/`browse`) |
| `teamai contribute --file <path> [--scope <user\|project>]` | Push an AI-generated experience document to the team repo |
| `teamai recall <query>` | Search the team knowledge base, automatically merging user + project scope results |
| `teamai import --from-repo <url>` | Clone a remote repo and generate a per-repo summary under `docs/team-codebase/repos/<slug>.md`; AI recommends a business domain and persists the assignment to `.teamai/domains.yaml` |
| `teamai import --from-repo-list <yaml>` | Batch import a whitelist of repos with concurrency control, then aggregate the results into per-domain views |
| `teamai import --from-org <org> --bootstrap` | List every repo under an organization (GitHub or TGit), AI-cluster them into business domains, and run an interactive review before the first full sync |
| `teamai import --from-iwiki <id> [--iwiki-dual]` | Import iWiki documents as learnings; in dual mode also extract business-API / external-knowledge / glossary sections into `docs/team-codebase/external-knowledge.md` |
| `teamai cache --status \| --gc` | Inspect or garbage-collect the shallow-clone cache at `~/.teamai/cache/repos/` (LRU + size cap, default 5GB) |
| `teamai codebase --lint [--fix]` | Cross-file consistency lint over `docs/team-codebase` and `.teamai/`; reports anchor / orphan / source-invalid / sync-stale issues; `--fix` applies low-risk mechanical fixes |
| `teamai review [id] [--apply \| --reject \| --all-apply]` | Inspect and process pending codebase changes from `.teamai/pending-review.jsonl`; `--apply` patches in place via section anchors |
| `teamai domains drift [url] [--apply \| --lock \| --apply-all]` | Inspect and resolve domain-drift signals; `--apply` reassigns the repo to the recommended domain and refreshes the aggregate views |
| `teamai digest` | Generate a team AI usage weekly digest (skill leaderboard, new/updated skills, session summaries) |
| `teamai hooks` | Manage AI-tool hooks (list / inject / remove) |
| `teamai ci extract-mr --url <url> [--mode comment\|write\|both] [--individual-comments]` | CI pipeline integration: extract knowledge from MR/PR, post as comments, and write to team repo after merge. With `--individual-comments`, each suggestion is posted separately with reaction/reject support (GitHub 👎 / TGit ☝️) |
| `teamai uninstall [--force]` | Uninstall teamai: remove hooks, rules, skills, env, docs, and `~/.teamai/` |
| `teamai doctor` | Diagnose configuration problems |

Global options:
- `--dry-run` — preview mode, no real changes
- `--verbose, -v` — verbose output
| `teamai init` | Initialize (OAuth login, link repo, register member, inject hooks) |
| `teamai push` | Push local resources to a branch and open a Merge Request |
| `teamai pull` | Pull team resources and inject into local AI tools |
| `teamai status` | Show local vs team repo diff |
| `teamai recall <query>` | Search the team knowledge base (BM25 + graph-boost) |
| `teamai import --from-repo <url>` | Import a repo's code knowledge graph (`teamwiki/`) |
| `teamai import --from-org <org>` | Batch import all repos under an organization |
| `teamai import --from-repo-list <yaml>` | Batch import repos from a whitelist |
| `teamai import --from-mr <url>` | Extract learning from a merged MR/PR |
| `teamai import --from-iwiki <id>` | Import iWiki documents as learnings |
| `teamai codebase --lint` | Knowledge graph health check |
| `teamai contribute` | Share session experience to team repo |
| `teamai doctor` | Diagnose configuration issues |
| `teamai uninstall` | Remove all teamai resources and hooks |

Global options: `--dry-run`, `--verbose`

<details>
<summary>More commands (management, CI, analytics)</summary>

| Command | Description |
|---------|-------------|
| `teamai list [type]` | List resources (skills\|rules\|docs\|env\|wiki) |
| `teamai skill [show <name>]` | Inspect skill metadata and contributors |
| `teamai members` | List team members |
| `teamai remove <type> <name>` | Remove a resource and open MR |
| `teamai roles` | Manage team roles and namespaces |
| `teamai source` | Manage cross-team skill subscriptions |
| `teamai tags` | Manage tag-based resource filtering |
| `teamai env` | Manage team environment variables |
| `teamai hooks` | Manage AI-tool hooks |
| `teamai cache --gc` | Garbage-collect clone cache |
| `teamai digest` | Generate weekly team usage digest |
| `teamai ci extract-mr --url <url>` | CI: extract knowledge from MR, post comments, write after merge |

</details>

## How It Works

Expand Down Expand Up @@ -316,6 +323,42 @@ Author: alice | Score: 12.0 | Tags: fuse, deploy

The index is rebuilt automatically on every `teamai pull`. Indexes built by older versions (no `version` field or missing `type`) are detected and rebuilt transparently on first use.

### Codebase Knowledge Graph (teamwiki/)

`teamai codebase --extract` (or `teamai import --from-repo`) parses your source repos and writes a structured knowledge graph under `teamwiki/`:

```
teamwiki/
├── router.md # Navigation hub — lists every imported repo
├── index.md # Global index (auto-generated, with timestamp)
├── hot.md # Active working memory (reserved for Phase 4)
├── source-manifest.json # Per-file hash manifest for incremental extraction
├── .indices/
│ └── graph-index.json # Knowledge graph: nodes + edges (JSON)
├── evidence/
│ └── code/
│ └── <project>/ # One directory per imported repo
│ ├── index.md # Project summary (fact count + page list)
│ ├── component.md # Functions / classes / components
│ ├── interface.md # Interface and type definitions
│ ├── config.md # Config keys (env vars, TOML keys, etc.)
│ ├── error.md # Error-handling patterns
│ └── relation-<dir>.md # Import relationships grouped by top-level dir
└── gaps/
└── detected.md # Detected knowledge gaps (IMPL_MISSING, LOW_CONNECTIVITY, …)
```

**graph-index.json** stores the extracted graph. A real example: 11 HAI team repos → **2 218 nodes, 852 edges**.

| Field | Description |
|-------|-------------|
| `nodes[].kind` | `component` (function/class) or `config` (config key) |
| `edges[].relation` | `imports` — cross-file and cross-repo dependency |

Cross-repo edges are detected automatically by PascalCase label matching.

`teamai recall` uses this graph for **BM25 + graph-boost** retrieval: keyword hits are re-ranked by graph proximity, so you get structurally relevant results, not just textual matches.

### TodoWrite reminder hook

`teamai pull` registers a PostToolUse hook on the `TodoWrite` tool. The first time a session writes a TODO list, the hook injects a one-time reminder asking the agent to invoke `teamai-recall` if it has not already done so. Per-session deduplication uses `~/.teamai/sessions/<sid>-todowrite-hint.json` (24 h TTL).
Expand Down
95 changes: 69 additions & 26 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,42 @@ CLI 会根据用户传入的 repo URL 自动选择 provider:

| 命令 | 说明 |
|------|------|
| `teamai init [--scope <user\|project>] [--role <id>] [--force]` | 初始化(自动安装 gf CLI、OAuth 登录、关联仓库、注册成员、配置 reviewers、注入 hooks) |
| `teamai push [--all] [--role <id>]` | 推送本地新资源到独立分支并创建 Merge Request;新 skill 交互式选择目标命名空间,可用 `--role` 覆盖 |
| `teamai pull [--silent]` | 拉取团队资源并注入到本地 AI 工具(支持双 scope 依次拉取) |
| `teamai init` | 初始化(OAuth 登录、关联仓库、注册成员、注入 hooks) |
| `teamai push` | 推送本地资源到独立分支并创建 MR |
| `teamai pull` | 拉取团队资源并注入到本地 AI 工具 |
| `teamai status` | 查看本地 vs 团队仓库差异 |
| `teamai list [type] [--source repo\|local\|all] [--agent <id>]` | 列出资源(skills\|rules\|docs\|env\|wiki);`--source local` 或 `all` 时会扫描已安装 AI agent 下的 skills 目录,并标注每个 skill 的来源 (`[team]` / `[builtin]` / `[source:<name>]` / `[local-only]`) |
| `teamai skill [list\|show <name>]` | 默认列出全部 skill;`show <name>` 输出指定 skill 的来源、贡献者、已安装的 agent 列表与描述摘要 |
| `teamai members` | 列出已注册的团队成员 |
| `teamai remove <type> <name>` | 从团队仓库和本地删除资源并创建 MR(skills\|rules\|wiki) |
| `teamai roles` | 管理团队角色(`init`/`list`/`set`/`add`/`remove`/`update`) |
| `teamai source` | 管理跨团队 skill 订阅源(`add`/`remove`/`list`/`browse`) |
| `teamai contribute --file <path> [--scope <user\|project>]` | 将 AI 生成的经验文档推送到团队仓库 |
| `teamai recall <query>` | 搜索团队知识库,自动合并 user + project 双 scope 结果 |
| `teamai import --from-repo <url>` | 拉取远端仓库并生成单仓视图 `docs/team-codebase/repos/<slug>.md`;AI 推荐业务域并写入 `.teamai/domains.yaml` |
| `teamai import --from-repo-list <yaml>` | 按白名单批量导入多个仓库(支持并发),并按业务域聚合产出 |
| `teamai import --from-org <org> --bootstrap` | 列出组织/group 下所有仓库(GitHub / TGit),AI 聚类为业务域,交互式 review 后完成首次全量同步 |
| `teamai import --from-iwiki <id> [--iwiki-dual]` | 把 iWiki 文档导入为 learnings;dual 模式同时把业务接口 / 外部知识源 / 术语表抽取到 `docs/team-codebase/external-knowledge.md` |
| `teamai cache --status \| --gc` | 查看或回收 shallow-clone 缓存目录 `~/.teamai/cache/repos/`(LRU + 容量上限,默认 5GB) |
| `teamai codebase --lint [--fix]` | 对 `docs/team-codebase` 与 `.teamai/` 做跨文件一致性 lint;报告锚点 / 孤儿 / 源失效 / 同步陈旧等问题;`--fix` 应用低风险机械修复 |
| `teamai review [id] [--apply \| --reject \| --all-apply]` | 浏览并处理 `.teamai/pending-review.jsonl` 中的待审 codebase 变更;`--apply` 通过章节锚点原地写入 |
| `teamai domains drift [url] [--apply \| --lock \| --apply-all]` | 浏览并处理域漂移信号;`--apply` 把仓库重新归类到推荐域并刷新聚合视图 |
| `teamai digest` | 生成团队 AI 使用周报(skill 排行、新增/更新 skill、session 摘要) |
| `teamai hooks` | 管理 AI 工具 hooks(list / inject / remove) |
| `teamai ci extract-mr --url <url> [--mode comment\|write\|both] [--individual-comments]` | CI 流水线集成:从 MR/PR 中提取知识,发布为评论,合并后写入团队知识仓库。使用 `--individual-comments` 时每条建议单独发布,支持 reaction/reject 交互(GitHub 👎 / TGit ☝️) |
| `teamai uninstall [--force]` | 卸载 teamai:移除 hooks、rules、skills、env、docs、~/.teamai/ |
| `teamai recall <query>` | 搜索团队知识库(BM25 + 图谱加权) |
| `teamai import --from-repo <url>` | 导入仓库代码知识图谱(`teamwiki/`) |
| `teamai import --from-org <org>` | 批量导入组织下所有仓库 |
| `teamai import --from-repo-list <yaml>` | 按白名单批量导入 |
| `teamai import --from-mr <url>` | 从已合并 MR 提取 learning |
| `teamai import --from-iwiki <id>` | 从 iWiki 导入文档为 learnings |
| `teamai codebase --lint` | 知识图谱健康度检查 |
| `teamai contribute` | 分享本次 session 经验到团队仓库 |
| `teamai doctor` | 诊断配置问题 |
| `teamai uninstall` | 卸载所有 teamai 资源和 hooks |

全局选项:
- `--dry-run` — 预览模式,不做实际变更
- `--verbose, -v` — 详细输出
全局选项:`--dry-run`、`--verbose`

<details>
<summary>更多命令(管理、CI、分析)</summary>

| 命令 | 说明 |
|------|------|
| `teamai list [type]` | 列出资源(skills\|rules\|docs\|env\|wiki) |
| `teamai skill [show <name>]` | 查看 skill 元数据和贡献者 |
| `teamai members` | 列出团队成员 |
| `teamai remove <type> <name>` | 删除资源并创建 MR |
| `teamai roles` | 管理团队角色和命名空间 |
| `teamai source` | 管理跨团队 skill 订阅 |
| `teamai tags` | 管理基于标签的资源过滤 |
| `teamai env` | 管理团队环境变量 |
| `teamai hooks` | 管理 AI 工具 hooks |
| `teamai cache --gc` | 回收 clone 缓存 |
| `teamai digest` | 生成团队使用周报 |
| `teamai ci extract-mr --url <url>` | CI:从 MR 提取知识,发布评论,合并后写入团队仓库 |

</details>

## 工作原理

Expand Down Expand Up @@ -316,6 +323,42 @@ Author: alice | Score: 12.0 | Tags: fuse, deploy

索引在每次 `teamai pull` 时自动重建。旧版索引(无 `version` 字段或缺少 `type`)会在首次使用时被自动检测并重建,对调用方透明

### 代码库知识图谱(teamwiki/)

`teamai codebase --extract`(或 `teamai import --from-repo`)解析源码仓库,将结构化知识图谱写入 `teamwiki/` 目录:

```
teamwiki/
├── router.md # 导航枢纽,列出所有已导入仓库
├── index.md # 全局索引(自动生成,含时间戳)
├── hot.md # 活跃工作记忆(Phase 4 hot/cold 预留)
├── source-manifest.json # 源文件哈希清单(增量提取用)
├── .indices/
│ └── graph-index.json # 知识图谱:nodes + edges(JSON 格式)
├── evidence/
│ └── code/
│ └── <project>/ # 每个导入的仓库一个目录
│ ├── index.md # 项目摘要(facts 总数 + 页面列表)
│ ├── component.md # 函数 / 类 / 组件
│ ├── interface.md # 接口和类型定义
│ ├── config.md # 配置项(环境变量、TOML key 等)
│ ├── error.md # 错误处理模式
│ └── relation-<dir>.md # 按顶级目录分组的 import 依赖关系
└── gaps/
└── detected.md # 知识缺口检测结果(IMPL_MISSING / LOW_CONNECTIVITY / …)
```

**graph-index.json** 存储提取出的知识图谱。真实数据参考:HAI 团队 11 个仓库 → **2 218 个节点,852 条边**。

| 字段 | 说明 |
|------|------|
| `nodes[].kind` | `component`(函数/类)或 `config`(配置项) |
| `edges[].relation` | `imports` —— 跨文件或跨仓库依赖关系 |

跨仓 edge 通过 PascalCase 标签匹配自动检测,无需手动配置。

`teamai recall` 利用此图谱进行 **BM25 + graph-boost** 检索:关键词命中后按图结构邻近度重排序,结果兼具文本相关性和结构相关性。

### TodoWrite 提醒 hook

`teamai pull` 会在 `TodoWrite` 工具上注册一个 PostToolUse hook。当 session 第一次写 TODO 列表时,hook 会注入一次性提醒,要求 agent 在尚未调用 `teamai-recall` 时先调用一次。session 级去重通过 `~/.teamai/sessions/<sid>-todowrite-hint.json` 实现(TTL 24 小时)
Expand Down
Loading
Loading