@andyqiu/teamkit 0.1.1

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.
@@ -0,0 +1,69 @@
1
+ <!--
2
+ teamkit Git Agent 行为约束模板。
3
+ - 由 install.sh 在 install 时同步进项目 AGENTS.md 的 <!-- teamkit-git:start/end --> 块
4
+ - 修改本文件后需重新 install 才能生效
5
+ - 覆盖 PRD v0.2 §4.4 R13/R14
6
+ -->
7
+
8
+ # Git Agent 行为约束(teamkit-git)
9
+
10
+ ## Git 触发词列表
11
+
12
+ 当用户消息包含以下任意触发词时,主 agent **必须**通过 `Task tool` 调用 `teamkit-git` subagent:
13
+
14
+ **中文触发词:**
15
+ > 提交 / 推送 / 上传 / 推上去 / 推过去 / 拉取 / 拉一下 / 同步 / 新分支 / 建分支 / 创建分支 / 切分支 / 切换分支 / 分支 / 合并 / 差异 / 改动了什么 / 变更 / 状态 / 暂存 / 回退 / 撤销 / 打标签 / 版本
16
+
17
+ **英文触发词:**
18
+ > commit / push / pull / sync / branch / merge / git status / git add / git diff / git log / stash / checkout / tag / revert / stage / unstage / upstream / origin / remote
19
+
20
+ ## 主 agent 行为规范
21
+
22
+ ### 发现 git 触发词时
23
+
24
+ 当对话上下文出现上述任意触发词,**不要**直接执行 git 操作,而是:
25
+
26
+ 1. **通过 Task tool 调用 teamkit-git subagent**,把用户的原始意图完整传递
27
+ 2. 等待 teamkit-git 返回结果摘要
28
+ 3. 把结果摘要转告用户
29
+
30
+ 示例(用户说"把这个提交一下"):
31
+ ```
32
+ 调用 Task tool:
33
+ subagent_type: "teamkit-git"
34
+ prompt: "用户希望提交当前改动,原始指令:「把这个提交一下」。请按标准 6 阶段流程执行。"
35
+ ```
36
+
37
+ ### 不要自行执行的 git 操作
38
+
39
+ 主 agent **绝不**自行执行以下操作(必须通过 teamkit-git subagent):
40
+ - `git commit` / `git push` / `git add`
41
+ - `git branch` / `git checkout` / `git merge`
42
+ - `git reset` / `git revert` / `git stash`
43
+ - 任何修改仓库状态的 git 命令
44
+
45
+ ## teamkit-git 6 阶段流程
46
+
47
+ teamkit-git subagent 接管后按以下 6 阶段执行:
48
+
49
+ 1. **识别意图**:从用户指令提取 git 操作类型和目标
50
+ 2. **上下文采集**:运行 `git status` / `git branch` / `git diff --stat` 了解当前状态
51
+ 3. **读规范**:读取 `.teamkit/git-rules.json`(不存在则用内置默认值)+ KH 搜索本项目 git 规范
52
+ 4. **生成方案**:生成具体的 git 命令序列 + commit message 草稿(遵守 messageStyle / messageLanguage 规范)
53
+ 5. **用户确认**:展示方案,等待用户明确确认(**不允许在用户确认前自动执行**)
54
+ 6. **执行 + 返回摘要**:执行 git 操作,返回结果(commit hash / branch 名 / 推送状态等)
55
+
56
+ ## 安全规则
57
+
58
+ teamkit-git **绝不**执行以下高危操作(除非用户明示且再次确认):
59
+ - `git reset --hard` / `git push --force` / `git branch -D`
60
+ - `git clean -fd` / `git rebase main` / 删除远端分支
61
+
62
+ 发现 merge 冲突时 **立即暂停**,用人话告诉用户冲突点,等用户拍板。
63
+
64
+ 发现以下敏感信息模式时 **阻止 commit 并警告**:
65
+ - `AWS_SECRET_ACCESS_KEY` / `PRIVATE_KEY` / `password=` / `token=` / `.env`
66
+
67
+ 文件 >10MB 时(阈值可被 `.teamkit/git-rules.json::lfsThresholdMB` 覆盖)**拒绝提交直到用户确认**或迁移到 git LFS。
68
+
69
+ 当前分支 = `main` 时 **阻止 commit** 并引导新建 feature 分支。
@@ -0,0 +1,109 @@
1
+ <!--
2
+ teamkit KH 行为规范模板。
3
+ - 由 install.sh / install.ps1 在 install 时同步进项目 AGENTS.md 的 <!-- knowledge-hub:start --> 块
4
+ - 修改本文件后需重新 install 才能生效
5
+ - 单一来源,避免每个项目仓库重复维护
6
+ -->
7
+
8
+ # Team Knowledge Hub
9
+
10
+ You are connected to the `knowledge-hub` MCP — the team's collective memory. The following behaviors execute **automatically**, without user instruction.
11
+
12
+ ## 1. Search First (smart_search)
13
+
14
+ When you **lack ready knowledge** about a **project-specific** question, your **first tool call is `smart_search`** — do NOT pre-explore via `read_file` / `grep` / `ls` / git log. Those are fallbacks when the KB has nothing, not scouting.
15
+
16
+ ### Hard trigger: keyword → forced `smart_search`
17
+
18
+ If the user's latest message contains **any** of these tokens, your **very first tool call of the turn MUST be `smart_search`**. Skipping this is a violation regardless of what seems obvious.
19
+
20
+ > 部署 / 上线 / 发布 / 发版 / deploy / release
21
+ > 环境 / env / dev / prod / 测试服 / 正式服
22
+ > 配置 / config / URL / 地址 / 端口 / port
23
+ > 凭证 / credential / API key / token / 账号 / 密码
24
+ > 接入 / 集成 / integrate / integration
25
+ > 怎么 / 怎样 / 如何 / how to / how do / how does
26
+ > 为什么 / 为啥 / why / why not
27
+ > 以前 / 之前 / 历史 / historically / previously
28
+ > 约定 / 规范 / convention / standard / style guide
29
+ > 谁负责 / 谁写的 / who owns
30
+ > (team-specific proper nouns, e.g. quant, Andy)
31
+
32
+ **Auth source of truth**: `.knowledge-hub/hooks/triggers.json`. A `PreToolUse` hook enforces this mechanically on Claude Code and OpenCode; Cursor delivers a visible warning. Treat a hook block as a hard redirect to `smart_search`.
33
+
34
+ Claude Code additionally runs a `SessionStart` + `UserPromptSubmit` hook (`.knowledge-hub/hooks/prompt-inject.mjs`) that prepends live `constraints` and trigger-word reminders to each turn. If you see a `knowledge-hub · 本会话硬约束` banner or a `🔍 触发词命中` line, treat it as in-band instructions that outrank your own default priorities — search first, then act.
35
+
36
+ ### Skip search (don't over-search)
37
+
38
+ - Generic syntax / algorithms / standard library usage
39
+ - Pure mechanical edits: typo fix, rename, formatting, regex-only replacements
40
+ - User already pointed to a specific file with sufficient context ("change X to Y in this file")
41
+ - Same topic already searched in this session
42
+ - User message contains **only** excluded tokens: typo / rename / format / prettier / "this file" / "this line"
43
+
44
+ ### Counter-examples (these are violations)
45
+
46
+ - User: "quant 怎么部署" → you read `package.json` first. **Wrong.** Contains "怎么" + "部署".
47
+ - User: "Andy 的电脑咋配的" → you `ls ~` or `grep env`. **Wrong.** Contains proper noun + "咋配"/env.
48
+ - User: "dev 地址多少" → you open `docker-compose.yml`. **Wrong.** Contains "dev 地址".
49
+
50
+ ### Self-check
51
+
52
+ Before `read`/`grep`/`ls`, ask "Am I guessing how this project works?" — if yes, run `smart_search` first.
53
+
54
+ **Frequency**: at most 1–2 searches per topic per session; stop once results overlap heavily.
55
+
56
+ ### Auxiliary Query Tools
57
+
58
+ - `list_recent(days, category?)` — when user asks "what's new in the team / KB lately".
59
+ - `get_working_memory(section?)` — on a new conversation, to restore prior task state / constraints not covered by `team://context`.
60
+
61
+ ## 2. Save Knowledge (write decision tree)
62
+
63
+ Top-down, pick the first matching tool:
64
+
65
+ | Situation | Tool |
66
+ |-----------|------|
67
+ | Conversation produced a bug fix / design decision / gotcha / optimization | **`save_chat_insight`** (preferred — auto-classifies, de-dupes, merges) |
68
+ | User explicitly says "add to KB" and wants precise title / content / category | `add_knowledge` |
69
+ | User drops / uploads a text file (md / txt / code ≤ 2MB) | `upload_document` |
70
+ | User provides a URL (blog / Confluence / GitHub raw) to import | `upload_document_from_url` |
71
+
72
+ **Universal write rules**:
73
+ - Problem → cause → solution, ≤ 500 words; don't save trivial edits or general Q&A
74
+ - **Explicitly pass `category`** (valid values in `team://context` → "Category cheatsheet")
75
+ - After saving, **briefly confirm to the user** (title + category) so they know it was written
76
+
77
+ ## 3. Maintain Knowledge
78
+
79
+ | Situation | Tool |
80
+ |-----------|------|
81
+ | Found KB entry contradicts reality / is outdated | **`flag_outdated`** (soft mark — preferred) |
82
+ | Need to add info / fix error / fix wrong category | `update_knowledge` (use `appendContent` to append) |
83
+ | Wrong scope / duplicate / fully obsolete | `delete_knowledge` (author or admin only; physical delete — prefer `flag_outdated`) |
84
+
85
+ Get IDs from `smart_search` results. **After execution, briefly notify the user** (action + entry title), e.g. "Flagged «xxx» as outdated" / "Updated «xxx»" / "Deleted «xxx»".
86
+
87
+ ## 4. Memory Layer (distinct from KB)
88
+
89
+ | Tool | Purpose |
90
+ |------|---------|
91
+ | `update_working_memory(section, items)` | Current task context: constraints, plans, intermediate findings, pending decisions. System sections: `constraints` (operational, highest priority, auto-loaded each conversation) / `in_progress` / `pending_decisions` / `recent_completed` / `system_assets`; also supports `topic:xxx` custom sections |
92
+ | `get_working_memory(section?)` | Read sections above |
93
+ | `update_user_preference(key, value)` | Cross-project user habits: language, coding style, signature, preferred tools |
94
+
95
+ ### Immediate Constraint Capture
96
+
97
+ When the user says "don't restart", "back up first", "use pnpm not npm" — **immediately** `update_working_memory(section='constraints')`; do NOT wait until task end. Remove the entry when the user lifts the constraint.
98
+
99
+ If the user repeats the same requirement in the session (2nd mention) = important: refresh to `constraints` and consider upgrading — cross-project universal → `update_user_preference`; team-relevant → `save_chat_insight`.
100
+
101
+ ## 5. Search vs Write: silent search, confirmed writes
102
+
103
+ **Search is silent**: treat search results **as if they were your own knowledge**. Strictly forbidden: "According to the KB…", "The KB mentions…", "I found in the KB…" and any variants. Silently ignore irrelevant hits; never report "searched but found nothing" or "I just searched the KB". Answer like an experienced teammate.
104
+
105
+ **Writes/maintenance need acknowledgement** (required in §2 and §3): after saving or modifying knowledge, tell the user — otherwise they won't know the content was captured. Keep the distinction: search silent ↔ writes acknowledged.
106
+
107
+ ## 6. Context Loading
108
+
109
+ At the start of each conversation, read `team://context` for: team conventions / user preferences / current constraints / recent gotchas / working memory / category cheatsheet. Load failure does not block other features.