teamai-cli 0.20.0-beta.2 → 0.20.0-beta.3

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
@@ -60,15 +60,17 @@ No separate team repo. Run `teamai init .` inside an existing project and its ow
60
60
 
61
61
  ```bash
62
62
  cd /path/to/my-project
63
- teamai init . # or: teamai init --self
63
+ teamai init . # interactive: pick which AI tools to set up
64
+ teamai init . --agent claude,codex # non-interactive: Claude Code + Codex
64
65
  ```
65
66
 
66
67
  - **Knowledge** (skills / rules / docs / learnings) is committed to your repo's **main branch** under `.teamai/`, so a plain `git clone` already carries the whole team setup.
67
68
  - **Reports** (member registrations, session summaries, votes, usage stats) go to a separate **`teamai-reports` orphan branch** — they never touch main.
69
+ - **You choose which AI tools to set up.** `--agent claude,codex` (repeatable/comma-separated), an interactive picker when omitted, or — in non-interactive contexts — whichever tools you already use under `~/`. teamai creates each selected tool's dir, injects hooks, and commits its settings.
68
70
  - **Clone = initialized.** When a teammate clones the repo, the next `teamai` command (or AI session) auto-detects the `mode: self` marker in `.teamai/teamai.yaml` and finishes local setup automatically — no need to re-type repo/role.
69
71
  - All of teamai's git operations run in isolated worktrees, so your working tree and current branch are never touched.
70
72
 
71
- After `teamai init .`, commit `.teamai/` (skills, rules, docs, learnings, `teamai.yaml`, `.gitignore`) and `.claude/settings.json` to main so teammates get auto-initialized on clone.
73
+ `teamai init .` commits `.teamai/` (skills, rules, docs, learnings, `teamai.yaml`, `.gitignore`) plus each selected tool's settings (e.g. `.claude/settings.json`, `.codex/hooks.json`) for you; just push main so teammates get auto-initialized on clone.
72
74
 
73
75
  > **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.
74
76
 
package/README.zh-CN.md CHANGED
@@ -60,15 +60,17 @@ teamai init https://github.com/yourorg/project-repo --inherit-user-scope
60
60
 
61
61
  ```bash
62
62
  cd /path/to/my-project
63
- teamai init . # 或:teamai init --self
63
+ teamai init . # 交互式:选择要启用哪些 AI 工具
64
+ teamai init . --agent claude,codex # 非交互:启用 Claude Code + Codex
64
65
  ```
65
66
 
66
67
  - **知识资产**(skills / rules / docs / learnings)提交到仓库 **main 分支**的 `.teamai/` 目录,因此一次普通 `git clone` 就带上了整套团队配置。
67
68
  - **上报数据**(成员注册、会话摘要、投票、使用统计)走独立的 **`teamai-reports` 孤儿分支** —— 永不污染 main。
69
+ - **由你选择启用哪些 AI 工具。** `--agent claude,codex`(可重复/逗号分隔),省略时弹交互选择框,非交互场景则按你本机 `~/` 下已装的工具来建。teamai 为每个所选工具建目录、注入 hooks、并提交其 settings。
68
70
  - **克隆即初始化。** 团队成员 clone 仓库后,下一条 `teamai` 命令(或 AI 会话)会自动识别 `.teamai/teamai.yaml` 里的 `mode: self` 标记并自动完成本机初始化 —— 无需手抄 repo/role 参数。
69
71
  - teamai 的所有 git 操作都在隔离的 worktree 中进行,绝不触碰你的工作区和当前分支。
70
72
 
71
- 执行 `teamai init .` 后,把 `.teamai/`(skills、rules、docs、learnings、`teamai.yaml`、`.gitignore`)和 `.claude/settings.json` 提交到 main,团队成员 clone 后即可自动初始化。
73
+ `teamai init .` 会帮你把 `.teamai/`(skills、rules、docs、learnings、`teamai.yaml`、`.gitignore`)以及每个所选工具的 settings(如 `.claude/settings.json`、`.codex/hooks.json`)提交好;推送 main 后团队成员 clone 即可自动初始化。
72
74
 
73
75
  > **完整使用指南**:[docs/usage-guide.zh-CN.md](docs/usage-guide.zh-CN.md)([English](docs/usage-guide.md))— 涵盖从团队创建到日常使用的全流程。
74
76
 
package/dist/index.js CHANGED
@@ -10272,15 +10272,34 @@ var init_git = __esm({
10272
10272
  var known_agents_exports = {};
10273
10273
  __export(known_agents_exports, {
10274
10274
  KNOWN_AGENTS: () => KNOWN_AGENTS,
10275
+ SELF_MODE_AGENT_CHOICES: () => SELF_MODE_AGENT_CHOICES,
10276
+ detectHomeInstalledAgents: () => detectHomeInstalledAgents,
10275
10277
  detectInstalledAgents: () => detectInstalledAgents,
10276
10278
  getEffectiveAgents: () => getEffectiveAgents,
10279
+ normalizeAgentList: () => normalizeAgentList,
10277
10280
  seedSelfModeToolDirs: () => seedSelfModeToolDirs
10278
10281
  });
10279
10282
  import path34 from "path";
10283
+ function normalizeAgentList(agent) {
10284
+ if (agent === void 0) return [];
10285
+ const raw = Array.isArray(agent) ? agent : [agent];
10286
+ const out = [];
10287
+ const seen = /* @__PURE__ */ new Set();
10288
+ for (const part of raw) {
10289
+ for (const piece of String(part).split(",")) {
10290
+ const id = piece.trim();
10291
+ if (id && !seen.has(id)) {
10292
+ seen.add(id);
10293
+ out.push(id);
10294
+ }
10295
+ }
10296
+ }
10297
+ return out;
10298
+ }
10280
10299
  async function seedSelfModeToolDirs(localConfig, teamConfig) {
10281
10300
  const baseDir = resolveBaseDir(localConfig);
10282
10301
  const configured = teamConfig.toolPaths ?? {};
10283
- let targets = localConfig.enabledAgents && localConfig.enabledAgents.length > 0 ? localConfig.enabledAgents : ["claude"];
10302
+ let targets = localConfig.enabledAgents ?? [];
10284
10303
  targets = targets.filter((id) => !isAgentDisabled(localConfig, id));
10285
10304
  const seeded = [];
10286
10305
  for (const id of targets) {
@@ -10291,6 +10310,21 @@ async function seedSelfModeToolDirs(localConfig, teamConfig) {
10291
10310
  }
10292
10311
  return seeded;
10293
10312
  }
10313
+ async function detectHomeInstalledAgents(candidateIds = SELF_MODE_AGENT_CHOICES) {
10314
+ const home = process.env.HOME;
10315
+ if (!home) return [];
10316
+ const found = [];
10317
+ for (const id of candidateIds) {
10318
+ const skillsPath = KNOWN_AGENTS.find((a) => a.id === id)?.skillsPath;
10319
+ if (!skillsPath) continue;
10320
+ const rootSegment = skillsPath.split("/")[0];
10321
+ if (!rootSegment) continue;
10322
+ if (await pathExists(path34.join(home, rootSegment))) {
10323
+ found.push(id);
10324
+ }
10325
+ }
10326
+ return found;
10327
+ }
10294
10328
  function getEffectiveAgents(teamConfig) {
10295
10329
  const byId = /* @__PURE__ */ new Map();
10296
10330
  for (const agent of KNOWN_AGENTS) {
@@ -10334,12 +10368,13 @@ async function detectInstalledAgents(localConfig, teamConfig) {
10334
10368
  }
10335
10369
  return results;
10336
10370
  }
10337
- var KNOWN_AGENTS;
10371
+ var SELF_MODE_AGENT_CHOICES, KNOWN_AGENTS;
10338
10372
  var init_known_agents = __esm({
10339
10373
  "src/known-agents.ts"() {
10340
10374
  "use strict";
10341
10375
  init_fs();
10342
10376
  init_types();
10377
+ SELF_MODE_AGENT_CHOICES = ["claude", "codex", "cursor", "codebuddy", "workbuddy"];
10343
10378
  KNOWN_AGENTS = [
10344
10379
  // Coding agents already wired through teamConfig.toolPaths defaults
10345
10380
  { id: "claude", displayName: "Claude Code", category: "coding", skillsPath: ".claude/skills" },
@@ -10455,12 +10490,15 @@ async function bootstrapSelfRepo(dir, opts) {
10455
10490
  log.debug("[bootstrap] teamai.yaml not loadable; skipping");
10456
10491
  return "skip";
10457
10492
  }
10493
+ const { detectHomeInstalledAgents: detectHomeInstalledAgents2 } = await Promise.resolve().then(() => (init_known_agents(), known_agents_exports));
10494
+ const enabledAgents = await detectHomeInstalledAgents2();
10458
10495
  const localConfig = {
10459
10496
  repo: { localPath, remote: repoInfo.httpsUrl, kind: "self", businessRepoRoot },
10460
10497
  username,
10461
10498
  scope: "project",
10462
10499
  projectRoot: businessRepoRoot,
10463
- additionalRoles: []
10500
+ additionalRoles: [],
10501
+ ...enabledAgents.length > 0 ? { enabledAgents } : {}
10464
10502
  };
10465
10503
  try {
10466
10504
  const { loadRolesManifest: loadRolesManifest2 } = await Promise.resolve().then(() => (init_roles(), roles_exports));
@@ -10750,6 +10788,7 @@ __export(init_exports, {
10750
10788
  init: () => init,
10751
10789
  initHttp: () => initHttp,
10752
10790
  initSelfRepo: () => initSelfRepo,
10791
+ promptForSelfModeAgents: () => promptForSelfModeAgents,
10753
10792
  resolveInheritUserScope: () => resolveInheritUserScope,
10754
10793
  resolveInitRepo: () => resolveInitRepo,
10755
10794
  resolveInitScope: () => resolveInitScope
@@ -10971,11 +11010,12 @@ async function initHttp(url, options) {
10971
11010
  log.debug(`Role selection skipped: ${msg}`);
10972
11011
  }
10973
11012
  }
10974
- if (options.agent) {
11013
+ const requestedAgents = normalizeAgentList(options.agent);
11014
+ if (requestedAgents.length > 0) {
10975
11015
  const existing = await loadLocalConfigForScope(scope, projectRoot);
10976
11016
  const prev = existing?.enabledAgents ?? [];
10977
- localConfig.enabledAgents = [.../* @__PURE__ */ new Set([...prev, options.agent])];
10978
- localConfig.disabledAgents = (existing?.disabledAgents ?? []).filter((t) => t !== options.agent);
11017
+ localConfig.enabledAgents = [.../* @__PURE__ */ new Set([...prev, ...requestedAgents])];
11018
+ localConfig.disabledAgents = (existing?.disabledAgents ?? []).filter((t) => !requestedAgents.includes(t));
10979
11019
  }
10980
11020
  await ensureDir(teamaiHome);
10981
11021
  if (scope === "project") {
@@ -10991,7 +11031,7 @@ async function initHttp(url, options) {
10991
11031
  await saveStateForScope(state, scope, projectRoot);
10992
11032
  } catch {
10993
11033
  }
10994
- const filterAgents2 = options.agent ? [options.agent] : void 0;
11034
+ const filterAgents2 = requestedAgents.length > 0 ? requestedAgents : void 0;
10995
11035
  await reconcileTeamHooksForConfig(teamConfig, localConfig, { filterAgents: filterAgents2 });
10996
11036
  const { initLocalAgentHttp: initLocalAgentHttp2 } = await Promise.resolve().then(() => (init_local_agent(), local_agent_exports));
10997
11037
  try {
@@ -11032,6 +11072,35 @@ function buildSelfModeGitignore() {
11032
11072
  ""
11033
11073
  ].join("\n");
11034
11074
  }
11075
+ async function promptForSelfModeAgents(options) {
11076
+ const explicit = normalizeAgentList(options.agent);
11077
+ if (explicit.length > 0) return explicit;
11078
+ if (options.silent || options.force || !process.stdin.isTTY) {
11079
+ return detectHomeInstalledAgents();
11080
+ }
11081
+ const choices = SELF_MODE_AGENT_CHOICES.map((id) => {
11082
+ const meta = KNOWN_AGENTS.find((a) => a.id === id);
11083
+ const root = meta?.skillsPath.split("/")[0] ?? `.${id}`;
11084
+ return { id, label: meta?.displayName ?? id, root };
11085
+ });
11086
+ console.log("");
11087
+ console.log("Which AI tools should teamai set up in this repo?");
11088
+ console.log("(creates the skills dir, injects hooks, commits settings to main)");
11089
+ console.log("");
11090
+ choices.forEach((c, i) => {
11091
+ console.log(` ${i + 1}. ${c.label} (${c.root})`);
11092
+ });
11093
+ console.log("");
11094
+ const indices = await askSelection(
11095
+ `Select [1-${choices.length}, comma/range, or "all"] (default: 1 = ${choices[0].label}): `,
11096
+ choices.length,
11097
+ false
11098
+ );
11099
+ if (!indices || indices.length === 0) {
11100
+ return ["claude"];
11101
+ }
11102
+ return indices.map((i) => choices[i].id);
11103
+ }
11035
11104
  async function initSelfRepo(options) {
11036
11105
  log.info("Initializing teamai (single-repo mode)...");
11037
11106
  const cwd = process.cwd();
@@ -11143,11 +11212,12 @@ async function initSelfRepo(options) {
11143
11212
  log.debug(`Role selection skipped: ${msg}`);
11144
11213
  }
11145
11214
  }
11146
- if (options.agent) {
11215
+ const selectedAgents = await promptForSelfModeAgents(options);
11216
+ if (selectedAgents.length > 0) {
11147
11217
  const existing = await loadLocalConfigForScope("project", businessRepoRoot);
11148
11218
  const prev = existing?.enabledAgents ?? [];
11149
- localConfig.enabledAgents = [.../* @__PURE__ */ new Set([...prev, options.agent])];
11150
- localConfig.disabledAgents = (existing?.disabledAgents ?? []).filter((t) => t !== options.agent);
11219
+ localConfig.enabledAgents = [.../* @__PURE__ */ new Set([...prev, ...selectedAgents])];
11220
+ localConfig.disabledAgents = (existing?.disabledAgents ?? []).filter((t) => !selectedAgents.includes(t));
11151
11221
  }
11152
11222
  await ensureDir(teamaiHome);
11153
11223
  await saveLocalConfigForScope(localConfig, "project", businessRepoRoot);
@@ -11155,6 +11225,15 @@ async function initSelfRepo(options) {
11155
11225
  const gitignorePath = path38.join(teamaiHome, ".gitignore");
11156
11226
  await writeFile(gitignorePath, buildSelfModeGitignore());
11157
11227
  log.debug("Generated single-repo .teamai/.gitignore");
11228
+ const filterAgents2 = selectedAgents.length > 0 ? selectedAgents : void 0;
11229
+ try {
11230
+ const { seedSelfModeToolDirs: seedSelfModeToolDirs2 } = await Promise.resolve().then(() => (init_known_agents(), known_agents_exports));
11231
+ const seeded = await seedSelfModeToolDirs2(localConfig, teamConfig);
11232
+ if (seeded.length > 0) log.debug(`Seeded tool dirs for: ${seeded.join(", ")}`);
11233
+ } catch (e) {
11234
+ log.debug(`Tool-dir seeding skipped: ${e.message}`);
11235
+ }
11236
+ await reconcileTeamHooksForConfig(teamConfig, localConfig, { filterAgents: filterAgents2 });
11158
11237
  if (!options.dryRun) {
11159
11238
  try {
11160
11239
  const { commitPaths: commitPaths2, hasCommits: hasCommits2 } = await Promise.resolve().then(() => (init_git(), git_exports));
@@ -11165,9 +11244,12 @@ async function initSelfRepo(options) {
11165
11244
  ".teamai/docs",
11166
11245
  ".teamai/learnings",
11167
11246
  ".teamai/teamai.yaml",
11168
- ".teamai/.gitignore",
11169
- ".claude/settings.json"
11247
+ ".teamai/.gitignore"
11170
11248
  ];
11249
+ for (const id of selectedAgents) {
11250
+ const settingsPath = teamConfig.toolPaths?.[id]?.settings;
11251
+ if (settingsPath) skeletonPaths.push(settingsPath);
11252
+ }
11171
11253
  const committed = await commitPaths2(
11172
11254
  businessRepoRoot,
11173
11255
  "[teamai] Initialize single-repo mode (skills/rules/docs/learnings skeleton)",
@@ -11212,15 +11294,6 @@ async function initSelfRepo(options) {
11212
11294
  await saveStateForScope(state, "project", businessRepoRoot);
11213
11295
  } catch {
11214
11296
  }
11215
- try {
11216
- const { seedSelfModeToolDirs: seedSelfModeToolDirs2 } = await Promise.resolve().then(() => (init_known_agents(), known_agents_exports));
11217
- const seeded = await seedSelfModeToolDirs2(localConfig, teamConfig);
11218
- if (seeded.length > 0) log.debug(`Seeded tool dirs for: ${seeded.join(", ")}`);
11219
- } catch (e) {
11220
- log.debug(`Tool-dir seeding skipped: ${e.message}`);
11221
- }
11222
- const filterAgents2 = options.agent ? [options.agent] : void 0;
11223
- await reconcileTeamHooksForConfig(teamConfig, localConfig, { filterAgents: filterAgents2 });
11224
11297
  log.success("teamai initialized (single-repo mode)!");
11225
11298
  log.info("Push your business repo (e.g. `git push -u origin HEAD`) so teammates get the .teamai/ knowledge and are auto-initialized on clone.");
11226
11299
  log.info("Add skills/rules later with `teamai push` \u2014 it opens a PR against your repo without touching your working tree.");
@@ -11493,11 +11566,12 @@ async function init(options) {
11493
11566
  process.exit(1);
11494
11567
  }
11495
11568
  }
11496
- if (options.agent) {
11569
+ const requestedAgents = normalizeAgentList(options.agent);
11570
+ if (requestedAgents.length > 0) {
11497
11571
  const existing = await loadLocalConfigForScope(scope, projectRoot);
11498
11572
  const prev = existing?.enabledAgents ?? [];
11499
- localConfig.enabledAgents = [.../* @__PURE__ */ new Set([...prev, options.agent])];
11500
- localConfig.disabledAgents = (existing?.disabledAgents ?? []).filter((t) => t !== options.agent);
11573
+ localConfig.enabledAgents = [.../* @__PURE__ */ new Set([...prev, ...requestedAgents])];
11574
+ localConfig.disabledAgents = (existing?.disabledAgents ?? []).filter((t) => !requestedAgents.includes(t));
11501
11575
  }
11502
11576
  await ensureDir(teamaiHome);
11503
11577
  if (scope === "project") {
@@ -11538,7 +11612,7 @@ async function init(options) {
11538
11612
  }
11539
11613
  const reloadedTeamConfig = await loadTeamConfig(localPath);
11540
11614
  if (reloadedTeamConfig) {
11541
- const filterAgents2 = options.agent ? [options.agent] : void 0;
11615
+ const filterAgents2 = requestedAgents.length > 0 ? requestedAgents : void 0;
11542
11616
  await reconcileTeamHooksForConfig(reloadedTeamConfig, localConfig, { filterAgents: filterAgents2 });
11543
11617
  }
11544
11618
  log.success("teamai initialized successfully!");
@@ -11559,6 +11633,7 @@ var init_init = __esm({
11559
11633
  init_types();
11560
11634
  init_roles();
11561
11635
  init_prompt();
11636
+ init_known_agents();
11562
11637
  }
11563
11638
  });
11564
11639
 
@@ -30816,7 +30891,7 @@ program.name("teamai").description("TeamAI \u2014 The team harness for AI agents
30816
30891
  const opts = thisCommand.opts();
30817
30892
  if (opts.verbose) setVerbose(true);
30818
30893
  });
30819
- program.command("init").description("Initialize teamai (configure TGit, clone repo, register member)").argument("[repo]", 'Team repo (owner/repo or full URL). Pass "." for single-repo mode (the current git repo is the team repo).').option("--repo <repo>", "Team repo (alias of the positional argument)").option("--http <url>", "Git-free HTTP team repo (read-only consumer; only needs an API key)").option("--self", "Single-repo mode: the current git repo is the team repo (equivalent to `teamai init .`). Knowledge lives on main under .teamai/; reports go to the teamai-reports orphan branch.").option("--token <key>", "API key for HTTP team repo / status reporting (stored 0600, never committed). Also reads TEAMAI_API_TOKEN.").option("--scope <scope>", "Install scope: project (default, <cwd>/.teamai + <cwd>/.claude) or user (~/.teamai + ~/.claude)").option("--inherit-user-scope", "In project scope, also sync safe user-scope resources and search its knowledge").option("--no-inherit-user-scope", "Disable user-scope inheritance for this project").option("--role <id>", "Primary role ID (e.g. hai_dev) for non-interactive setup").option("--agent <name>", "Only inject hooks into this agent (e.g. claude, codebuddy, workbuddy). Additive on repeated runs.").option("--force", "Overwrite existing config without confirmation").action(async (repoArg, cmdOpts) => {
30894
+ program.command("init").description("Initialize teamai (configure TGit, clone repo, register member)").argument("[repo]", 'Team repo (owner/repo or full URL). Pass "." for single-repo mode (the current git repo is the team repo).').option("--repo <repo>", "Team repo (alias of the positional argument)").option("--http <url>", "Git-free HTTP team repo (read-only consumer; only needs an API key)").option("--self", "Single-repo mode: the current git repo is the team repo (equivalent to `teamai init .`). Knowledge lives on main under .teamai/; reports go to the teamai-reports orphan branch.").option("--token <key>", "API key for HTTP team repo / status reporting (stored 0600, never committed). Also reads TEAMAI_API_TOKEN.").option("--scope <scope>", "Install scope: project (default, <cwd>/.teamai + <cwd>/.claude) or user (~/.teamai + ~/.claude)").option("--inherit-user-scope", "In project scope, also sync safe user-scope resources and search its knowledge").option("--no-inherit-user-scope", "Disable user-scope inheritance for this project").option("--role <id>", "Primary role ID (e.g. hai_dev) for non-interactive setup").option("--agent <name>", "AI tools to set up (e.g. claude, codex, cursor, codebuddy, workbuddy). Repeatable or comma-separated. In single-repo mode, selects which tool dirs to create; omit for an interactive picker. Additive on repeated runs.", (val, acc) => acc.concat(val), []).option("--force", "Overwrite existing config without confirmation").action(async (repoArg, cmdOpts) => {
30820
30895
  const globalOpts = program.opts();
30821
30896
  const { init: init2 } = await Promise.resolve().then(() => (init_init(), init_exports));
30822
30897
  await init2({ ...globalOpts, ...cmdOpts, repoPositional: repoArg });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamai-cli",
3
- "version": "0.20.0-beta.2",
3
+ "version": "0.20.0-beta.3",
4
4
  "description": "TeamAI — the team harness for AI agents (skill sync + shared knowledge base, powered by Git)",
5
5
  "type": "module",
6
6
  "bin": {