teamai-cli 0.17.6 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -79,10 +79,27 @@ hooks:
79
79
 
80
80
  ```bash
81
81
  teamai hooks list # list effective hooks
82
- teamai hooks inject # force-reconcile into all tools
82
+ teamai hooks inject # re-reconcile into every installed tool
83
83
  teamai hooks remove # remove all teamai-managed hooks
84
84
  ```
85
85
 
86
+ ### Team MCP Servers
87
+
88
+ Declare once in `mcp/mcp.yaml`; `teamai pull` writes each tool's native config. Use `${VAR}` for secrets.
89
+
90
+ ```yaml
91
+ servers:
92
+ - name: gpu-analysis
93
+ transport: http # stdio | http | sse
94
+ url: https://example.com/api/mcp
95
+ headers:
96
+ Authorization: Bearer ${GPU_ANALYSIS_TOKEN}
97
+ ```
98
+
99
+ ```bash
100
+ teamai mcp list | inject | remove
101
+ ```
102
+
86
103
  ### Cross-team Skill Subscription
87
104
 
88
105
  Subscribe to other teams' public skill repos:
@@ -120,7 +137,7 @@ teamai recall disable # off: remove the subagent and rules
120
137
  teamai recall status # show effective state (team default + user override)
121
138
  ```
122
139
 
123
- **Search runs via a subagent**: once enabled, `teamai pull` deploys the built-in `teamai-recall` subagent into each AI tool's `agents/` directory. The AI invokes it before a task — the subagent extracts keywords, runs the search, reads the matched source files, and returns a structured summary of team knowledge. Under the hood it shells out to the `teamai recall` command, which you can also run manually:
140
+ **Search runs via a subagent**: once enabled, `teamai pull` deploys the built-in `teamai-recall` subagent into each AI tool's `agents/` directory. The AI invokes it before a task — the subagent extracts keywords, runs the search, reads the matched source files, and returns a structured summary of team knowledge. The subagent first runs a relevance precheck (`teamai recall --check`) and skips retrieval entirely when the task is unrelated to team knowledge. Under the hood it shells out to the `teamai recall` command, which you can also run manually:
124
141
 
125
142
  ```bash
126
143
  $ teamai recall "port conflict"
@@ -149,6 +166,7 @@ teamai codebase --lint # health check
149
166
  ```
150
167
 
151
168
  The graph stores components, interfaces, configs, and cross-repo import edges. `teamai recall` uses it for graph-boosted re-ranking.
169
+ When a recall hit comes from a codebase page, the result includes a `Sources:` line listing the relevant source file paths — giving agents a direct starting point for code changes instead of re-exploring the repo.
152
170
 
153
171
  ## Commands
154
172
 
package/README.zh-CN.md CHANGED
@@ -79,10 +79,27 @@ hooks:
79
79
 
80
80
  ```bash
81
81
  teamai hooks list # 查看生效的 hooks
82
- teamai hooks inject # 强制重新注入到所有工具
82
+ teamai hooks inject # 重新注入到每个已安装的工具
83
83
  teamai hooks remove # 移除所有 teamai 管理的 hooks
84
84
  ```
85
85
 
86
+ ### 团队 MCP Server
87
+
88
+ 在 `mcp/mcp.yaml` 中声明一次,`teamai pull` 按各工具原生格式写入。密钥用 `${VAR}`。
89
+
90
+ ```yaml
91
+ servers:
92
+ - name: gpu-analysis
93
+ transport: http # stdio | http | sse
94
+ url: https://example.com/api/mcp
95
+ headers:
96
+ Authorization: Bearer ${GPU_ANALYSIS_TOKEN}
97
+ ```
98
+
99
+ ```bash
100
+ teamai mcp list | inject | remove
101
+ ```
102
+
86
103
  ### 跨团队 Skill 订阅
87
104
 
88
105
  订阅其他团队的公开 skill 仓库:
@@ -120,7 +137,7 @@ teamai recall disable # 关闭:移除子 agent 和规则
120
137
  teamai recall status # 查看生效状态(团队默认 + 用户覆盖)
121
138
  ```
122
139
 
123
- **通过子 agent 检索**:开启后 `teamai pull` 会把内置的 `teamai-recall` 子 agent 部署到各 AI 工具的 `agents/` 目录。AI 在任务开始前调用它——由子 agent 提取关键词、执行检索、读取命中的源文件,最后返回结构化的团队知识摘要。子 agent 底层调用的仍是 `teamai recall` 命令,也可手动直接运行:
140
+ **通过子 agent 检索**:开启后 `teamai pull` 会把内置的 `teamai-recall` 子 agent 部署到各 AI 工具的 `agents/` 目录。AI 在任务开始前调用它——由子 agent 提取关键词、执行检索、读取命中的源文件,最后返回结构化的团队知识摘要。subagent 会先做相关性预检(`teamai recall --check`),当任务与团队知识无关时直接跳过检索。子 agent 底层调用的仍是 `teamai recall` 命令,也可手动直接运行:
124
141
 
125
142
  ```bash
126
143
  $ teamai recall "port conflict"
@@ -149,6 +166,7 @@ teamai codebase --lint # 健康检查
149
166
  ```
150
167
 
151
168
  图谱存储组件、接口、配置和跨仓库依赖边。`teamai recall` 利用图谱进行增强排名。
169
+ 当召回命中 codebase 页面时,结果会附带一行 `Sources:`,列出相关源文件路径,供 agent 直接作为代码改动的入口,无需重新探索代码库。
152
170
 
153
171
  ## 命令一览
154
172
 
@@ -20,6 +20,22 @@ upstream API"). Treat this as your query.
20
20
 
21
21
  ## What you must do — step by step
22
22
 
23
+ ### Step 0 — Relevance precheck (fail fast)
24
+
25
+ Before any classification or search, run a single lightweight precheck:
26
+
27
+ ```bash
28
+ teamai recall --check "<3-6 keywords from the task>"
29
+ ```
30
+
31
+ - If the output starts with `NOT_RELEVANT`: the team knowledge base has no
32
+ meaningful coverage for this task. Emit exactly one line
33
+ `No relevant team knowledge found for: <query>` and **stop** — do not
34
+ proceed to Step 1–5, do not read any files, do not run a full recall.
35
+ - If the output starts with `RELEVANT`: continue to Step 1.
36
+ - If the command fails or `teamai` is not on PATH: skip the precheck and
37
+ continue to Step 1 (do not block on precheck failure).
38
+
23
39
  ### Step 1 — Classify question type and choose retrieval depth
24
40
 
25
41
  Determine if the query matches a G-document category:
@@ -41,6 +57,13 @@ corresponding file and extract relevant sections. Skip BM25 search.
41
57
  > - `--depth lookup`: searches ALL evidence pages including raw symbol lists (for precise file:line lookups)
42
58
  > - `--depth route`: returns the router table only (use when you need to discover what projects exist)
43
59
 
60
+ **Edit/change queries** (keywords: 新增/添加/修改/如何改/重构/实现; how to add/change/modify/implement): use `--depth lookup` in Step 3 so facts/relation pages are visible. After BM25 recall, also read these directly (bypassing BM25 ranking uncertainty):
61
+ 1. `teamwiki/evidence/code/<project>/.indices/graph-index.json` (priority; fall back to `teamwiki/.indices/graph-index.json` if absent) — when surfacing edges, pick 1–3 entry files most relevant to the task and read only their forward direct-dep edges (`from` == entry file); skip reverse expansion (each edge: `{from, to, relation}` — from/to are file paths, relation is type e.g. DEPENDS_ON)
62
+ 2. `Sources:` file anchors listed in any matching facts pages (component.md / interface.md)
63
+ 3. `dependency-paths.md` in the same project docs dir when line-level call anchors are needed
64
+
65
+ (`<project>` extracted from recall result file paths, or from `router.md`.)
66
+
44
67
  Fallback: if no `teamwiki/`, check `~/.teamai/docs/codebase.md`. If
45
68
  none exists, silently skip.
46
69
 
@@ -80,7 +103,10 @@ For each hit returned by `teamai recall`, read the source file directly
80
103
  **For codebase hits** (path contains `teamwiki/evidence/`):
81
104
  - If the hit is a raw facts page (component.md, interface.md), prefer
82
105
  reading the corresponding **module summary** (`modules/<dir>.md`) instead —
83
- it's more concise and shows dependencies.
106
+ it's more concise and shows dependencies. **Exception for edit queries**:
107
+ retain the `Sources:` file anchors from the facts page (do not discard them
108
+ in favour of the module summary alone); cross-reference those anchor files
109
+ against graph-index.json edges to surface dependency relationships.
84
110
  - If you need architectural context (why a module exists, design decisions),
85
111
  check `overview.md` in the same project directory.
86
112
  - If the hit mentions a knowledge gap (from `gaps/detected.md`), relay
@@ -113,6 +139,16 @@ Return your output in **this exact format** to the main conversation:
113
139
  - Core components: `Foo`, `Bar`, `Baz` (top 5 by reference count)
114
140
  - Architecture: <one sentence from overview.md if available>
115
141
 
142
+ ### Change entry points (edit queries only)
143
+
144
+ Relevant files (from graph-index.json: first pick 1–3 entry files most relevant to the query from Sources anchors + keywords; then list only their forward direct-dep edges where `from` == entry file; skip self-edges (from == to); do not expand reverse edges — they blow up):
145
+ - `<file_a>` ──<RELATION>──> `<file_b>`
146
+ - ...
147
+
148
+ Suggested reading order: <contract/types first> → <impl> → ...
149
+
150
+ > Edges capped at 10; see graph-index.json for full graph. Keep this section ≤ 300 characters. Omit this section for non-edit queries.
151
+
116
152
  ### Gaps (if relevant)
117
153
 
118
154
  ⚠️ <gap description> — do not guess answers for this area.
@@ -153,3 +189,5 @@ Return your output in **this exact format** to the main conversation:
153
189
  Gaps section so the main conversation does not hallucinate.
154
190
  - When zero hits are found but `teamwiki/` exists, check if the query
155
191
  relates to a known gap before returning "no knowledge found".
192
+ - When `teamai recall --check` returns `NOT_RELEVANT`, do not continue — return the no-knowledge line and stop. The precheck exists to avoid wasted retrieval on unrelated tasks.
193
+ - **Do not invent call relationships.** The "Change entry points" section must be derived solely from graph-index.json edges and dependency-paths.md. If those files are absent or do not cover the queried files, write `relation data not covered` and omit the section — do not guess.