teamai-cli 0.17.3 → 0.17.4
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 +85 -488
- package/README.zh-CN.md +88 -491
- package/agents/teamai-recall.md +1 -0
- package/dist/index.js +872 -135
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,572 +11,169 @@
|
|
|
11
11
|
[](https://www.npmjs.com/package/teamai-cli)
|
|
12
12
|
[](LICENSE)
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Git-native management of skills, rules, and docs across 20+ AI tools — for you or your whole team.
|
|
14
|
+
[](https://discord.gg/gervEZm58g)
|
|
15
|
+
[](https://discord.gg/DeHHxPnfZF)
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
Make every AI coding agent work by the same harness.
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
Git-native management of skills, rules, and docs across Claude Code / Codex / CodeBuddy / WorkBuddy and more.
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
For you or your whole team.
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
## Quick Start
|
|
25
24
|
|
|
26
|
-
|
|
25
|
+
### Install
|
|
27
26
|
|
|
28
27
|
```bash
|
|
29
28
|
npm install -g teamai-cli
|
|
30
29
|
```
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
<summary>Tencent internal users: install <code>@tencent/teamai-cli</code> via tnpm</summary>
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
npm install -g @tencent/teamai-cli --registry=http://r.tnpm.oa.com
|
|
37
|
-
```
|
|
31
|
+
### Team admin / solo user
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
</details>
|
|
33
|
+
Create a shared-experience repo on your git host (GitHub or TGit), **grant write access to team members**, then have them run `teamai init --repo https://github.com/yourorg/yourrepo`.
|
|
41
34
|
|
|
42
|
-
|
|
35
|
+
> Solo use needs no separate repo setup: `teamai init` checks the target repo and creates it automatically if it doesn't exist.
|
|
43
36
|
|
|
44
37
|
### Team members
|
|
45
38
|
|
|
46
39
|
```bash
|
|
47
40
|
# User-scope init (default, resources installed under ~/)
|
|
48
|
-
teamai init --repo
|
|
41
|
+
teamai init --repo https://github.com/yourorg/yourrepo
|
|
49
42
|
|
|
50
43
|
# Project-scope init (resources installed under the project directory)
|
|
51
44
|
cd /path/to/my-project
|
|
52
|
-
teamai init --repo
|
|
53
|
-
|
|
54
|
-
# Non-interactive mode (for CI/CD or AI-agent automation)
|
|
55
|
-
teamai init --repo yourteam/yourproject --scope user --role hai_dev --force
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Admins
|
|
59
|
-
|
|
60
|
-
First create the shared-experience repo on your git host (GitHub by default; TGit also supported) and grant write access to every team member.
|
|
61
|
-
|
|
62
|
-
- **GitHub:** create with `gh repo create yourorg/yourproject --private` or via the UI. Then use Settings → Collaborators to add members, and set `master`/`main` as the default branch.
|
|
63
|
-
- **TGit (Tencent Gongfeng):** create on [git.woa.com](https://git.woa.com/) and grant master permissions in bulk via user groups.
|
|
64
|
-
|
|
65
|
-
The CLI picks a provider automatically from the repo URL:
|
|
66
|
-
|
|
67
|
-
- `yourorg/yourrepo` or `https://github.com/yourorg/yourrepo` → GitHub
|
|
68
|
-
- `https://git.woa.com/yourteam/yourrepo` → TGit
|
|
69
|
-
|
|
70
|
-
### Read-only consumers (HTTP team repo, no git)
|
|
71
|
-
|
|
72
|
-
Some users or agents only need to *consume* a team's skills/rules — no git clone, no push. Onboard them over plain HTTP with just an API key:
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
teamai init --http https://your-team-host/api --token <api-key>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
- **Read-only:** `push` / `contribute` / `remove` are disabled for HTTP repos.
|
|
79
|
-
- The API key is stored `0600` (never written to config, never committed); `TEAMAI_API_TOKEN` is also honored.
|
|
80
|
-
- No git clone: skills/rules/CLAUDE.md are delivered per-session over the report/sync/ack lifecycle. Hooks and status reporting are wired at init time.
|
|
81
|
-
|
|
82
|
-
#### Agent status reporting
|
|
83
|
-
|
|
84
|
-
Once initialized, supported agents (CodeBuddy / WorkBuddy) report their installed-skill state on session start and pull down server-managed skill install / update / uninstall commands, driven by the existing hook dispatch (`session-start` → report + sync, `prompt-submit` → sync). Failed deliveries are buffered to an offline queue and retried next time.
|
|
85
|
-
|
|
86
|
-
> **Privacy.** The install path and machine id are only hashed *locally* to derive a stable `local_agent_id` — neither is ever uploaded.
|
|
87
|
-
|
|
88
|
-
<details>
|
|
89
|
-
<summary><b>HTTP contract</b> (for backend implementers) — what the <code>--http</code> endpoint must serve</summary>
|
|
90
|
-
|
|
91
|
-
The value you pass to `--http <baseUrl>` is the base; every endpoint is relative to it and authenticated with `Authorization: Bearer <api-key>`.
|
|
92
|
-
|
|
93
|
-
| Endpoint | Method | Purpose | Path |
|
|
94
|
-
|----------|--------|---------|------|
|
|
95
|
-
| `{baseUrl}/api/local-agent/report` | POST | Session start: upsert agent + installed skills | default, configurable |
|
|
96
|
-
| `{baseUrl}/api/local-agent/sync` | POST | Report status + return pending skill commands | default, configurable |
|
|
97
|
-
| `{baseUrl}/api/local-agent/commands/ack` | POST | Ack one command (`{ id, status, error }`) | default, configurable |
|
|
98
|
-
|
|
99
|
-
`POST /api/local-agent/sync` returns pending commands that install/update/uninstall skills:
|
|
100
|
-
|
|
101
|
-
```json
|
|
102
|
-
{
|
|
103
|
-
"ok": true,
|
|
104
|
-
"commands": [{ "id": 1, "type": "install_skill", "skill_slug": "x", "skill_version": "1.0.0", "download_url": "https://signed-url/..." }]
|
|
105
|
-
}
|
|
45
|
+
teamai init --repo https://github.com/yourorg/yourrepo --scope project
|
|
106
46
|
```
|
|
107
47
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
**Configurable paths.** The three reporter paths are defaults you can override. The JSON shapes above are the contract. Knobs (env vars):
|
|
111
|
-
|
|
112
|
-
| Variable | Effect |
|
|
113
|
-
|----------|--------|
|
|
114
|
-
| `TEAMAI_API_TOKEN` | API key (alternative to `--token`) |
|
|
115
|
-
| `TEAMAI_REPORT_ENDPOINT` | Reporter base URL (defaults to the `--http` URL) |
|
|
116
|
-
| `TEAMAI_REPORT_PATHS` | JSON `{ "report", "sync", "ack" }` to override the three reporter paths |
|
|
117
|
-
| `TEAMAI_REPORT_AGENTS` | Comma-separated agents that report (default `workbuddy,codebuddy`) |
|
|
118
|
-
| `TEAMAI_SKILL_DOWNLOAD_HOSTS` | Comma-separated host allowlist for skill `download_url` (empty = allow all) |
|
|
119
|
-
| `TEAMAI_BIND_PROMPT_ENABLED` | Set to `1` to enable the org-binding prompt (TTY prompt + injected hook hint). Off by default; `teamai bind-project` works regardless |
|
|
120
|
-
|
|
121
|
-
</details>
|
|
122
|
-
|
|
123
|
-
## Commands
|
|
124
|
-
|
|
125
|
-
| Command | Description |
|
|
126
|
-
|---------|-------------|
|
|
127
|
-
| `teamai init` | Initialize (OAuth login, link repo, register member, inject hooks) |
|
|
128
|
-
| `teamai push` | Push local resources to a branch and open a Merge Request |
|
|
129
|
-
| `teamai pull` | Pull team resources and inject into local AI tools |
|
|
130
|
-
| `teamai status` | Show local vs team repo diff |
|
|
131
|
-
| `teamai recall <query>` | Search the team knowledge base (BM25 + graph-boost) |
|
|
132
|
-
| `teamai recall enable/disable/status` | Toggle or check recall state (controls auto-recall hooks + subagent deployment) |
|
|
133
|
-
| `teamai import --dir <path>` | Extract code knowledge graph from a local directory |
|
|
134
|
-
| `teamai import --from-repo <url>` | Import a repo's code knowledge graph (`teamwiki/`) |
|
|
135
|
-
| `teamai import --from-org <org>` | Batch import all repos under an organization |
|
|
136
|
-
| `teamai import --from-repo-list <yaml>` | Batch import repos from a whitelist |
|
|
137
|
-
| `teamai import --from-mr <url>` | Extract learning from a merged MR/PR |
|
|
138
|
-
| `teamai import --from-iwiki <id>` | Import iWiki documents as learnings |
|
|
139
|
-
| `teamai codebase --lint` | Knowledge graph health check |
|
|
140
|
-
| `teamai contribute` | Share session experience to team repo |
|
|
141
|
-
| `teamai members` | List team members |
|
|
142
|
-
| `teamai roles` | Manage team roles and namespaces |
|
|
143
|
-
| `teamai remove <type> <name>` | Remove a resource and open MR |
|
|
144
|
-
| `teamai digest` | Generate weekly team usage digest |
|
|
145
|
-
| `teamai doctor` | Diagnose configuration issues |
|
|
146
|
-
| `teamai uninstall` | Remove all teamai resources and hooks |
|
|
147
|
-
|
|
148
|
-
Global options: `--dry-run`, `--verbose`
|
|
149
|
-
|
|
150
|
-
Import options: `--incremental`, `--skip-enrich` (skip AI calls, only extract + graph)
|
|
48
|
+
Once initialized, every AI session automatically pulls the latest skills / rules and other Harness updates published by admins — no manual sync needed.
|
|
151
49
|
|
|
152
|
-
|
|
153
|
-
<summary>More commands (management, CI, analytics)</summary>
|
|
50
|
+
> **Full usage guide:** [docs/usage-guide.md](docs/usage-guide.md) ([中文版](docs/usage-guide.zh-CN.md)) — covers everything from team creation to day-to-day use.
|
|
154
51
|
|
|
155
|
-
|
|
156
|
-
|---------|-------------|
|
|
157
|
-
| `teamai list [type]` | List resources (skills\|rules\|docs\|env\|wiki) |
|
|
158
|
-
| `teamai skill [show <name>]` | Inspect skill metadata and contributors |
|
|
159
|
-
| `teamai source` | Manage cross-team skill subscriptions |
|
|
160
|
-
| `teamai tags` | Manage tag-based resource filtering |
|
|
161
|
-
| `teamai env` | Manage team environment variables |
|
|
162
|
-
| `teamai hooks` | Manage AI-tool hooks |
|
|
163
|
-
| `teamai cache --gc` | Garbage-collect clone cache |
|
|
164
|
-
| `teamai ci extract-mr --url <url>` | CI: extract knowledge from MR, post comments, write after merge |
|
|
52
|
+
## Harness Management & Distribution
|
|
165
53
|
|
|
166
|
-
|
|
54
|
+
TeamAI keeps skills, rules, docs, and hooks in a shared git repo and distributes them to every member's local AI tools through a "push → review & merge → pull" flow — with support for subscribing to other teams' Harness.
|
|
167
55
|
|
|
168
|
-
|
|
56
|
+
### How It Works
|
|
169
57
|
|
|
170
58
|
```
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
▼ ▼
|
|
175
|
-
teamai push teamai push
|
|
176
|
-
│ │
|
|
177
|
-
▼ ▼
|
|
178
|
-
create branch + MR create branch + MR
|
|
179
|
-
│ │
|
|
180
|
-
└──────► team git repo ◄─────────────┘
|
|
181
|
-
│ ▲
|
|
182
|
-
│ │ reviewer approves + merges MR
|
|
183
|
-
▼
|
|
184
|
-
SessionStart hook → teamai pull
|
|
185
|
-
auto-synced to every member's local
|
|
59
|
+
teamai push → create branch + MR → reviewer approves + merges
|
|
60
|
+
↓
|
|
61
|
+
SessionStart hook → teamai pull → synced to local AI tools
|
|
186
62
|
```
|
|
187
63
|
|
|
188
|
-
|
|
189
|
-
- `teamai init` lets you configure default reviewers (stored in the `reviewers` field of `teamai.yaml`).
|
|
190
|
-
- `teamai init` injects hooks tailored to each tool's format (`SessionStart`, `Stop`, `PostToolUse`, `UserPromptSubmit`, etc.). During sessions the hooks run `teamai pull`, `teamai update`, tracking, dashboard updates, and so on (supports Claude Code, Codex, Claude Code Internal, Codex Internal, Cursor, CodeBuddy IDE, OpenClaw, WorkBuddy).
|
|
191
|
-
- Skills sync to `~/.claude/skills/`, `~/.codex/skills/`, `~/.codex-internal/skills/`, `~/.claude-internal/skills/`, `~/.cursor/skills/`, `~/.codebuddy/skills/`.
|
|
192
|
-
- Rules sync to each tool's rules directory and are merged into `CLAUDE.md` via marker comments (supported for claude, claude-internal, codebuddy).
|
|
193
|
-
- Knowledge syncs to `~/.teamai/docs/`.
|
|
194
|
-
- Learnings sync to `~/.teamai/learnings/` and back the recall index (shared team-wide, not partitioned by role).
|
|
195
|
-
- Culture syncs the team culture file (`culture.md`): its frontmatter and body are compiled and injected into every AI tool's `CLAUDE.md`.
|
|
196
|
-
|
|
197
|
-
## Role-scoped Skills
|
|
198
|
-
|
|
199
|
-
When the team resource repo enables role-scoped directories, skills are organized under role namespaces. During `teamai init`, the CLI asks you to pick a `primaryRole` and optional `additionalRoles` and writes them to your local `config.yaml`.
|
|
200
|
-
|
|
201
|
-
Remote repo layout convention:
|
|
202
|
-
|
|
203
|
-
```text
|
|
204
|
-
manifest/roles.yaml # role definitions
|
|
205
|
-
skills/<namespace>/<skill>/ # skills organized by namespace
|
|
206
|
-
rules/ # global, not role-scoped
|
|
207
|
-
```
|
|
64
|
+
Members push changes via `teamai push`, which opens a Merge Request for review. Once merged, `teamai pull` (triggered automatically on session start via the SessionStart hook) syncs the latest resources locally. Skills sync to `~/.claude/skills/`, `~/.codex/skills/`, `~/.cursor/skills/`, `~/.codebuddy/skills/`, etc.
|
|
208
65
|
|
|
209
|
-
|
|
210
|
-
- Skills install flat from `skills/<namespace>/<skill-name>/` into `<tool>/skills/<skill-name>/` — the namespace layout is invisible to users.
|
|
211
|
-
- If two activated namespaces contain a skill with the same name, `pull` fails outright to prevent silent overrides.
|
|
212
|
-
- Skills outside both activated namespaces and tag-filter results are cleaned up automatically.
|
|
213
|
-
- `rules/`, `docs/`, `learnings/` keep their original behavior and are not role-scoped (learnings are shared team-wide).
|
|
66
|
+
### Team Hooks
|
|
214
67
|
|
|
215
|
-
|
|
68
|
+
Declare custom hooks in `hooks/hooks.yaml` and `teamai pull` delivers them to every AI tool:
|
|
216
69
|
|
|
217
70
|
```yaml
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
71
|
+
hooks:
|
|
72
|
+
- id: block-secret
|
|
73
|
+
description: Scan for secrets before commit
|
|
74
|
+
event: PreToolUse
|
|
75
|
+
matcher: Bash
|
|
76
|
+
command: 'bash -lc "~/.teamai/team-scripts/scan-secret.sh" || true'
|
|
77
|
+
tools: [claude, cursor]
|
|
222
78
|
```
|
|
223
79
|
|
|
224
|
-
This syncs every skill from `skills/common/`, `skills/hai/`, and `skills/pm/`.
|
|
225
|
-
|
|
226
|
-
## Role-scoped Pushing
|
|
227
|
-
|
|
228
|
-
In a role-scoped repo, when you push a new skill the CLI auto-detects available namespaces and prompts:
|
|
229
|
-
|
|
230
80
|
```bash
|
|
231
|
-
#
|
|
232
|
-
teamai
|
|
233
|
-
#
|
|
234
|
-
# Which namespace should new skills be pushed to?
|
|
235
|
-
# 1. common
|
|
236
|
-
# 2. hai
|
|
237
|
-
# 3. pm
|
|
238
|
-
# Choose namespace [1-3] (default: 1 = common):
|
|
239
|
-
|
|
240
|
-
# Explicit target namespace
|
|
241
|
-
teamai push --role pm
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
- With a `primaryRole`, the list expands from `manifest/roles.yaml`.
|
|
245
|
-
- Without a `primaryRole`, namespaces are discovered by scanning the team repo's directory structure.
|
|
246
|
-
- When only one namespace exists, it's selected automatically — no prompt.
|
|
247
|
-
- `--role <id>` temporarily overrides the target namespace.
|
|
248
|
-
- Modifying an existing skill keeps its original namespace — no reselection needed.
|
|
249
|
-
|
|
250
|
-
On push, the CLI checks `SKILL.md`'s YAML frontmatter (`name`/`description`) and auto-fills anything missing, so you don't have to maintain it by hand.
|
|
251
|
-
|
|
252
|
-
## Team Culture
|
|
253
|
-
|
|
254
|
-
Create `culture.md` at the root of the team repo. Use YAML frontmatter for company/team info and the body for cultural guidelines:
|
|
255
|
-
|
|
256
|
-
```markdown
|
|
257
|
-
---
|
|
258
|
-
company:
|
|
259
|
-
name: Acme Corp
|
|
260
|
-
mission: Build great things
|
|
261
|
-
values:
|
|
262
|
-
- Innovation
|
|
263
|
-
- Integrity
|
|
264
|
-
team:
|
|
265
|
-
name: Platform
|
|
266
|
-
mission: Enable developers
|
|
267
|
-
goals:
|
|
268
|
-
- Ship v2.0
|
|
269
|
-
- Improve test coverage
|
|
270
|
-
---
|
|
271
|
-
|
|
272
|
-
## Coding Guidelines
|
|
273
|
-
|
|
274
|
-
- Every PR needs at least one reviewer approval
|
|
275
|
-
- Direct pushes to master are forbidden
|
|
276
|
-
- Test coverage must stay above 80%
|
|
81
|
+
teamai hooks list # list effective hooks
|
|
82
|
+
teamai hooks inject # force-reconcile into all tools
|
|
83
|
+
teamai hooks remove # remove all teamai-managed hooks
|
|
277
84
|
```
|
|
278
85
|
|
|
279
|
-
|
|
86
|
+
### Cross-team Skill Subscription
|
|
280
87
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
Use `teamai source` to subscribe to other teams' public skill repos. Their skills sync automatically on `pull`:
|
|
88
|
+
Subscribe to other teams' public skill repos:
|
|
284
89
|
|
|
285
90
|
```bash
|
|
286
|
-
# Add a subscription source
|
|
287
91
|
teamai source add https://github.com/other-team/teamai-public.git --name other-team
|
|
288
|
-
|
|
289
|
-
# List subscribed sources
|
|
290
92
|
teamai source list
|
|
291
|
-
|
|
292
|
-
# Browse skills from a source
|
|
293
|
-
teamai source browse other-team
|
|
294
|
-
|
|
295
|
-
# Remove a subscription (and clean up its skills)
|
|
93
|
+
teamai source browse other-team # browse available skills
|
|
296
94
|
teamai source remove other-team
|
|
297
95
|
```
|
|
298
96
|
|
|
299
|
-
Subscribed skills sync
|
|
300
|
-
|
|
301
|
-
### HTTP source (report/sync/ack)
|
|
302
|
-
|
|
303
|
-
The subscriptions above are **git** sources. You can additionally attach a single **HTTP** source that uses the report/sync/ack lifecycle — the same one an `init --http` consumer gets — **alongside your existing git main repo**, without changing it:
|
|
304
|
-
|
|
305
|
-
```bash
|
|
306
|
-
# Attach an HTTP source (git main repo stays untouched)
|
|
307
|
-
teamai source add-http https://your-team-host/api --token <api-key>
|
|
308
|
-
|
|
309
|
-
# See it listed under "HTTP source"
|
|
310
|
-
teamai source list
|
|
311
|
-
|
|
312
|
-
# Detach it (uninstalls its resources, clears its config)
|
|
313
|
-
teamai source remove-http
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
The HTTP source reports status and pulls down skills/rules/CLAUDE.md commands on each AI session, driven by the `hook-dispatch` hook that `teamai init` already installs. Users who never run `add-http` are unaffected.
|
|
317
|
-
|
|
318
|
-
Only one HTTP source is supported, and it is meant for **git-based** main repos: if your main repo is itself an HTTP backend (`init --http`), it already owns the HTTP config, so `add-http` is rejected.
|
|
319
|
-
|
|
320
|
-
## Scope
|
|
321
|
-
|
|
322
|
-
TeamAI supports two scopes that can coexist:
|
|
323
|
-
|
|
324
|
-
| Dimension | User Scope (default) | Project Scope |
|
|
325
|
-
|-----------|---------------------|---------------|
|
|
326
|
-
| **Install location** | under `~/` (e.g. `~/.claude/skills/`) | under the project (e.g. `<project>/.claude/skills/`) |
|
|
327
|
-
| **Config file** | `~/.teamai/config.yaml` | `<project>/.teamai/config.yaml` |
|
|
328
|
-
| **Use case** | general team norms, cross-project skills | project-specific skills and rules |
|
|
329
|
-
| **Init** | `teamai init --repo <group>/<repo>` | `cd <project> && teamai init --repo <group>/<repo> --scope project` |
|
|
97
|
+
Subscribed skills sync automatically on `teamai pull`.
|
|
330
98
|
|
|
331
|
-
|
|
332
|
-
- `teamai pull` pulls user and project scopes sequentially; they don't conflict.
|
|
333
|
-
- `teamai contribute --scope user/project` lets you pick which repo to push to.
|
|
334
|
-
- `teamai recall` merges knowledge bases from both scopes into a single ranking and tags each result with its origin `[user]` / `[project]`.
|
|
335
|
-
- The `scope` field in the remote `teamai.yaml` locks the repo's type; member init must match.
|
|
336
|
-
|
|
337
|
-
## Automatic Experience Sharing
|
|
338
|
-
|
|
339
|
-
When an AI coding session ends, the Stop hook evaluates session value and prompts you to share:
|
|
340
|
-
|
|
341
|
-
```
|
|
342
|
-
AI coding session (ongoing...)
|
|
343
|
-
│
|
|
344
|
-
▼ PostToolUse hook continuously tracks tool calls and skill usage
|
|
345
|
-
│
|
|
346
|
-
▼ session ends (Stop hook fires)
|
|
347
|
-
│
|
|
348
|
-
├─ Smart scoring: tool-call count + tool diversity + skill usage + error retries + session duration
|
|
349
|
-
│ (extracted from dashboard events.jsonl, one-shot, out of 100)
|
|
350
|
-
│
|
|
351
|
-
├─ Score < 35 → stay silent (too few or too uniform calls, not worth summarizing)
|
|
352
|
-
│
|
|
353
|
-
▼ Score ≥ 35
|
|
354
|
-
│
|
|
355
|
-
AI: "This session was productive — consider running /teamai-share-learnings to share."
|
|
356
|
-
│
|
|
357
|
-
▼ user accepts
|
|
358
|
-
│
|
|
359
|
-
/teamai-share-learnings (AI sub-agent)
|
|
360
|
-
├─ AI summarizes the session's lessons
|
|
361
|
-
├─ Generates a Markdown document
|
|
362
|
-
└─ teamai contribute --file <path> → pushes directly to the team repo's learnings/
|
|
363
|
-
```
|
|
99
|
+
## Knowledge Base
|
|
364
100
|
|
|
365
|
-
|
|
366
|
-
- Each session is prompted at most once (de-duplicated); you can always ignore it.
|
|
367
|
-
- The document lands directly in `learnings/` and is visible to teammates on their next `pull`.
|
|
101
|
+
Beyond distributing the Harness, TeamAI organizes accumulated team experience and code structure into a searchable knowledge base that the AI recalls automatically when needed.
|
|
368
102
|
|
|
369
|
-
|
|
103
|
+
### Automatic Experience Sharing
|
|
370
104
|
|
|
371
|
-
|
|
105
|
+
When a session ends, the Stop hook scores it by **friction** — signals that the session hit something worth remembering: you interrupted or corrected the AI, denied a tool call, or the AI had to retry failing tools. A long-but-routine session (lots of tool calls, no friction) does not trigger; a session where you actually fought a problem does. If the score is high enough, the AI suggests:
|
|
372
106
|
|
|
373
107
|
```
|
|
374
|
-
|
|
108
|
+
建议运行 /teamai-share-learnings 总结本次 session 的经验并分享给团队。
|
|
375
109
|
```
|
|
376
110
|
|
|
377
|
-
|
|
378
|
-
$ teamai recall "fuse port"
|
|
379
|
-
[1/2] MR review caught a FUSE port-conflict bug ★1 [user]
|
|
380
|
-
Author: jeffyxu | Score: 18.5 | Tags: troubleshooting, fuse, k8s
|
|
381
|
-
|
|
382
|
-
[2/2] FUSE deployment configuration best practices [project]
|
|
383
|
-
Author: alice | Score: 12.0 | Tags: fuse, deploy
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
- **Dual-scope merged search:** automatically merges user and project scope knowledge bases, each result tagged with its origin.
|
|
387
|
-
- Hybrid CJK + English search (Intl.Segmenter + CJK bigrams).
|
|
388
|
-
- Searches implicitly upvote matched docs; good docs naturally float up over time.
|
|
389
|
-
- Votes are written to each scope's own repo, so attribution stays correct.
|
|
390
|
-
|
|
391
|
-
`teamai recall` results carry a `[<type>]` tag so callers can quickly tell which knowledge bucket a hit came from. The shared search index covers four categories:
|
|
111
|
+
The `/teamai-share-learnings` skill summarizes the session and pushes a learning document directly to the team repo. Each session is prompted at most once.
|
|
392
112
|
|
|
393
|
-
|
|
394
|
-
|------|--------|-------|
|
|
395
|
-
| `[learnings]` | `~/.teamai/learnings/*.md` | session experience documents |
|
|
396
|
-
| `[docs]` | team repo `docs/**/*.md` | shared project knowledge |
|
|
397
|
-
| `[rules]` | team repo `rules/**/*.md` | coding rules and conventions |
|
|
398
|
-
| `[skills]` | team repo `skills/<name>/SKILL.md` | reusable AI skills |
|
|
113
|
+
### Team Knowledge Recall
|
|
399
114
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
### Recall Enable / Disable
|
|
403
|
-
|
|
404
|
-
Recall is controlled at two levels — team admin sets the default, individual users can override:
|
|
405
|
-
|
|
406
|
-
| Layer | File | Field | Effect |
|
|
407
|
-
|-------|------|-------|--------|
|
|
408
|
-
| Team default | `teamai.yaml` | `sharing.recall.enabled` | `true` / `false` (default: `false`) |
|
|
409
|
-
| User override | `~/.teamai/config.yaml` | `recallEnabled` | `true` / `false` — wins over team default |
|
|
410
|
-
| Env var | shell | `TEAMAI_RECALL_DISABLED=1` | Force-disable all recall hooks (quick kill-switch) |
|
|
115
|
+
Let the AI automatically search accumulated team knowledge before a task. This feature is **off by default** and must be enabled explicitly — teams can set `sharing.recall.enabled: true` in `teamai.yaml` as the default, and members can override locally:
|
|
411
116
|
|
|
412
117
|
```bash
|
|
413
|
-
teamai recall enable #
|
|
414
|
-
teamai recall disable #
|
|
118
|
+
teamai recall enable # on: deploy the teamai-recall subagent + inject guidance rules
|
|
119
|
+
teamai recall disable # off: remove the subagent and rules
|
|
415
120
|
teamai recall status # show effective state (team default + user override)
|
|
416
121
|
```
|
|
417
122
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
### Codebase Knowledge Graph (teamwiki/)
|
|
421
|
-
|
|
422
|
-
`teamai codebase --extract` (or `teamai import --from-repo`) parses your source repos and writes a structured knowledge graph under `teamwiki/`:
|
|
423
|
-
|
|
424
|
-
```
|
|
425
|
-
teamwiki/
|
|
426
|
-
├── router.md # Navigation hub — lists every imported repo
|
|
427
|
-
├── index.md # Global index (auto-generated, with timestamp)
|
|
428
|
-
├── hot.md # Active working memory (reserved for Phase 4)
|
|
429
|
-
├── source-manifest.json # Per-file hash manifest for incremental extraction
|
|
430
|
-
├── .indices/
|
|
431
|
-
│ └── graph-index.json # Knowledge graph: nodes + edges (JSON)
|
|
432
|
-
├── evidence/
|
|
433
|
-
│ └── code/
|
|
434
|
-
│ └── <project>/ # One directory per imported repo
|
|
435
|
-
│ ├── index.md # Project summary (fact count + page list)
|
|
436
|
-
│ ├── component.md # Functions / classes / components
|
|
437
|
-
│ ├── interface.md # Interface and type definitions
|
|
438
|
-
│ ├── config.md # Config keys (env vars, TOML keys, etc.)
|
|
439
|
-
│ ├── error.md # Error-handling patterns
|
|
440
|
-
│ └── relation-<dir>.md # Import relationships grouped by top-level dir
|
|
441
|
-
└── gaps/
|
|
442
|
-
└── detected.md # Detected knowledge gaps (IMPL_MISSING, LOW_CONNECTIVITY, …)
|
|
443
|
-
```
|
|
444
|
-
|
|
445
|
-
**graph-index.json** stores the extracted graph. A real example: 11 HAI team repos → **2 218 nodes, 852 edges**.
|
|
446
|
-
|
|
447
|
-
| Field | Description |
|
|
448
|
-
|-------|-------------|
|
|
449
|
-
| `nodes[].kind` | `component` (function/class) or `config` (config key) |
|
|
450
|
-
| `edges[].relation` | `imports` — cross-file and cross-repo dependency |
|
|
451
|
-
|
|
452
|
-
Cross-repo edges are detected automatically by PascalCase label matching.
|
|
453
|
-
|
|
454
|
-
`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.
|
|
455
|
-
|
|
456
|
-
### TodoWrite reminder hook
|
|
457
|
-
|
|
458
|
-
`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).
|
|
459
|
-
|
|
460
|
-
To disable the reminder globally, set:
|
|
461
|
-
|
|
462
|
-
```bash
|
|
463
|
-
export TEAMAI_RECALL_DISABLED=1
|
|
464
|
-
```
|
|
465
|
-
|
|
466
|
-
The same env var also disables `teamai recall`'s quality tracking (used by contribute-check's knowledge-gap detection).
|
|
467
|
-
|
|
468
|
-
### `agents` resource type
|
|
469
|
-
|
|
470
|
-
The team repo can ship custom subagent definitions under a flat `agents/` directory (one `*.md` file per agent). They follow the same push / pull / remove semantics as `rules`:
|
|
471
|
-
|
|
472
|
-
```text
|
|
473
|
-
team-repo/
|
|
474
|
-
agents/
|
|
475
|
-
code-reviewer.md # team-authored subagent
|
|
476
|
-
.removed # tombstone (auto-managed by `teamai remove agents <name>`)
|
|
477
|
-
```
|
|
478
|
-
|
|
479
|
-
`teamai pull` copies them into every Tier-1 tool's `agents/` directory (e.g. `~/.claude/agents/`). The CLI built-in `teamai-recall.md` is deployed alongside team agents and is **excluded** from `teamai push` (it is CLI-managed, not team-managed).
|
|
480
|
-
|
|
481
|
-
### `hooks` resource type (team-declared hooks)
|
|
482
|
-
|
|
483
|
-
Beyond the built-in operational hooks the CLI injects, a team can declare its **own** hooks once in the repo and have `teamai pull` adapt and deliver them to every AI tool (Claude Code, CodeBuddy, Cursor, …). Declare them in `hooks/hooks.yaml`:
|
|
484
|
-
|
|
485
|
-
```yaml
|
|
486
|
-
hooks:
|
|
487
|
-
- id: block-secret # unique, ^[a-z0-9-]+$ — used for the marker + manifest
|
|
488
|
-
description: 提交前扫描密钥 # written into the hook description
|
|
489
|
-
event: PreToolUse # Claude PascalCase event name (the cross-tool lingua franca)
|
|
490
|
-
matcher: Bash # optional tool matcher
|
|
491
|
-
command: 'bash -lc "~/.teamai/team-scripts/scan-secret.sh" || true'
|
|
492
|
-
timeout: 15 # optional, seconds
|
|
493
|
-
tools: [claude, cursor] # optional; default = all hook-capable tools
|
|
494
|
-
|
|
495
|
-
# Optional: tune the CLI's own built-in hooks (whitelisted fields only)
|
|
496
|
-
builtin:
|
|
497
|
-
disabled: [Hook dispatch post-tool-use TodoWrite] # drop a built-in hook
|
|
498
|
-
overrides:
|
|
499
|
-
Hook dispatch stop: { timeout: 20 } # only `timeout` may be overridden
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
- `teamai pull` reconciles built-in (A) + team (B) hooks into each tool on every session start (it bypasses the "already synced" fast-path, so new/changed hooks self-heal automatically).
|
|
503
|
-
- Team hooks are isolated from built-in hooks by a `[teamai:hook:<id>]` marker and tracked in `~/.teamai/managed-hooks.json`, so removing one from `hooks.yaml` cleanly removes it from every tool on the next pull — built-in hooks are never disturbed.
|
|
504
|
-
- Disk format is unchanged and byte-identical for built-in hooks, so upgrading the CLI is a zero-diff, zero-regression operation for already-installed machines.
|
|
505
|
-
|
|
506
|
-
Audit, force-apply, or strip the effective hooks:
|
|
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:
|
|
507
124
|
|
|
508
125
|
```bash
|
|
509
|
-
teamai
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
```
|
|
513
|
-
|
|
514
|
-
> **Security.** Team hooks are arbitrary shell commands that run automatically on session events — treat the repo's write access as an execution surface (governed by MR review, same as `env.yaml`). Guards:
|
|
515
|
-
> - Commands are printed for transparency when applied (unless `--silent`).
|
|
516
|
-
> - `sharing.hooks.autoApply: false` (in `teamai.yaml`) holds team hooks during `pull` and only hints — the user must run `teamai hooks inject` to consent.
|
|
517
|
-
> - `sharing.hooks.requireTeamScripts: true` rejects any team hook whose command is not under `~/.teamai/team-scripts/`.
|
|
518
|
-
> - Set `TEAMAI_HOOKS_DISABLED=1` to veto all team hooks locally (built-in hooks still apply).
|
|
126
|
+
$ teamai recall "port conflict"
|
|
127
|
+
[1/2] MR review caught a port-conflict bug ★1 [user]
|
|
128
|
+
Author: member-a | Score: 18.5 | Tags: troubleshooting, networking
|
|
519
129
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
```bash
|
|
523
|
-
teamai update # auto-detect and upgrade to latest
|
|
524
|
-
npm update -g teamai-cli # or trigger an npm upgrade manually
|
|
130
|
+
[2/2] Deployment configuration best practices [project]
|
|
131
|
+
Author: member-b | Score: 12.0 | Tags: deploy, config
|
|
525
132
|
```
|
|
526
133
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
- `teamai-cli` → public npm (`https://registry.npmjs.org`)
|
|
530
|
-
- `@tencent/teamai-cli` → internal tnpm (`http://r.tnpm.oa.com`)
|
|
531
|
-
|
|
532
|
-
To override the registry manually, set `TEAMAI_NPM_REGISTRY=<url>`.
|
|
533
|
-
|
|
534
|
-
### Auto-update Control
|
|
134
|
+
**Coverage spans two parts:**
|
|
535
135
|
|
|
536
|
-
|
|
136
|
+
- **Shared search index** (`search-index.json`): four categories — learnings (session experience), docs (team docs), rules (coding rules), and skills (each `SKILL.md`) — sourced from the corresponding team-repo directories, (re)built on `teamai pull` / `teamai contribute`.
|
|
137
|
+
- **Codebase knowledge graph** (`teamwiki/`): produced by `teamai import`, queried live at search time.
|
|
537
138
|
|
|
538
|
-
|
|
539
|
-
|-------|------|-------|----------------|
|
|
540
|
-
| Team default | `teamai.yaml` | `autoUpdate` | `true` (default) / `false` |
|
|
541
|
-
| User override | `~/.teamai/config.yaml` | `updatePolicy` | `auto` / `prompt` / `skip` |
|
|
139
|
+
Ranking uses BM25 + graph-boost, merges dual-scope (user + project) results tagged with origin, and implicitly upvotes matched docs so good content floats up over time.
|
|
542
140
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
## CI Integration
|
|
546
|
-
|
|
547
|
-
TeamAI can integrate into your CI pipeline to automatically extract knowledge from every MR/PR:
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
MR opened/updated → CI extracts learning + codebase suggestions → posts as comments
|
|
551
|
-
→ Reviewer rejects unwanted suggestions (GitHub 👎 / TGit ☝️)
|
|
552
|
-
→ MR merged → CI writes approved items to team knowledge repo
|
|
553
|
-
```
|
|
141
|
+
### Codebase Knowledge Graph
|
|
554
142
|
|
|
555
|
-
|
|
143
|
+
`teamai import` parses source repos into a structured graph under `teamwiki/`, enabling structurally-aware retrieval:
|
|
556
144
|
|
|
557
145
|
```bash
|
|
558
|
-
|
|
559
|
-
teamai
|
|
560
|
-
|
|
561
|
-
# Write mode: write approved items to knowledge repo (run after merge)
|
|
562
|
-
teamai ci extract-mr --url "$MR_URL" --mode write --team-repo ./team-repo --individual-comments
|
|
146
|
+
teamai import --from-repo https://github.com/org/repo
|
|
147
|
+
teamai import --from-org myorg # batch import all repos
|
|
148
|
+
teamai codebase --lint # health check
|
|
563
149
|
```
|
|
564
150
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
Ready-to-use templates in `examples/ci/`:
|
|
151
|
+
The graph stores components, interfaces, configs, and cross-repo import edges. `teamai recall` uses it for graph-boosted re-ranking.
|
|
568
152
|
|
|
569
|
-
|
|
570
|
-
|------|----------|
|
|
571
|
-
| `github-actions-mr-extract.yml` | GitHub Actions |
|
|
572
|
-
| `coding-ci-mr-extract.yaml` | Coding CI (TGit + ZhiYan QCI) |
|
|
153
|
+
## Commands
|
|
573
154
|
|
|
574
|
-
|
|
155
|
+
| Command | Description |
|
|
156
|
+
|---------|-------------|
|
|
157
|
+
| `teamai init` | Initialize: OAuth login, link repo, register member, inject hooks |
|
|
158
|
+
| `teamai pull` | Pull team resources and inject into local AI tools |
|
|
159
|
+
| `teamai push` | Push local resources to a branch and open a Merge Request |
|
|
160
|
+
| `teamai status` | Show local vs team repo diff |
|
|
161
|
+
| `teamai contribute` | Share session experience to team repo |
|
|
162
|
+
| `teamai recall <query>` | Search the team knowledge base (BM25 + graph-boost) |
|
|
163
|
+
| `teamai recall enable/disable/status` | Toggle or check recall state |
|
|
164
|
+
| `teamai import` | Import knowledge (`--dir`, `--from-repo`, `--from-org`, `--from-repo-list`, `--from-mr`, `--from-iwiki`) |
|
|
165
|
+
| `teamai codebase --lint` | Knowledge graph health check |
|
|
166
|
+
| `teamai ci extract-mr --url <url>` | CI: extract knowledge from MR, post comments, write after merge |
|
|
167
|
+
| `teamai members` | List team members |
|
|
168
|
+
| `teamai roles` | Manage team roles and namespaces |
|
|
169
|
+
| `teamai skill exclude add/remove/list` | Manage skills excluded from local sync ([usage guide](docs/usage-guide.md#excluding-skills-you-dont-need)) |
|
|
170
|
+
| `teamai source` | Manage cross-team skill subscriptions |
|
|
171
|
+
| `teamai remove <type> <name>` | Remove a resource and open MR |
|
|
172
|
+
| `teamai digest` | Generate weekly team usage digest |
|
|
173
|
+
| `teamai doctor` | Diagnose configuration issues |
|
|
174
|
+
| `teamai uninstall` | Remove all teamai resources and hooks |
|
|
575
175
|
|
|
576
|
-
|
|
577
|
-
|----------|--------------|---------|
|
|
578
|
-
| GitHub | Add 👎 reaction to the suggestion comment | Write all |
|
|
579
|
-
| TGit | Add ☝️ emoji to the suggestion note | Write all |
|
|
176
|
+
Global options: `--dry-run`, `--verbose`
|
|
580
177
|
|
|
581
178
|
## License
|
|
582
179
|
|