@team-ai/teamai-cli 0.40.1 → 0.40.2

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/dist/cli.js CHANGED
@@ -63119,6 +63119,19 @@ async function inheritWorktreeBinding(config, cwd, resolvedPath) {
63119
63119
  await saveLocalAgentConfig(config);
63120
63120
  return true;
63121
63121
  }
63122
+ async function deliveredToWorkspace(workspacePath) {
63123
+ if ((await loadManifest2()).scopes[scopeKey("project", workspacePath)]) return true;
63124
+ const models = await readJson(getModelManifestPath());
63125
+ return Boolean(models?.workspaceModels?.[workspacePath]);
63126
+ }
63127
+ async function enrollWorkspace(config, cwd, workspacePath) {
63128
+ if (config.workspaceBindings[workspacePath]) return true;
63129
+ if (await inheritWorktreeBinding(config, cwd, workspacePath)) return true;
63130
+ if (!await deliveredToWorkspace(workspacePath)) return false;
63131
+ await persistWorkspaceBinding(config, cwd, workspacePath, 0, PENDING_BINDING_NAME);
63132
+ log.debug(`[local-agent] enrolled a workspace an earlier release delivered to: ${workspacePath}`);
63133
+ return true;
63134
+ }
63122
63135
  async function bindWorkspaceToProject(workspacePath, projectId) {
63123
63136
  const config = await loadLocalAgentConfig();
63124
63137
  if (!config) {
@@ -63224,6 +63237,25 @@ async function emitBindingHint(config, workspacePath, sessionId, tool) {
63224
63237
  });
63225
63238
  process.stdout.write(hookOutput + "\n");
63226
63239
  }
63240
+ async function noticeUnenrolledWorkspace(workspacePath, event) {
63241
+ const markerKey = event?.sessionId || `ppid-${process.ppid}`;
63242
+ const marker = path76.join(os9.tmpdir(), `teamai-unenrolled-${markerKey}`);
63243
+ if (fs35.existsSync(marker)) return;
63244
+ try {
63245
+ fs35.writeFileSync(marker, "");
63246
+ } catch {
63247
+ }
63248
+ const message = `[teamai] This workspace is not enrolled, so nothing is reported or synced here. Run \`teamai bind-project\` in ${workspacePath} to enroll it.`;
63249
+ log.info(message);
63250
+ if (event?.type !== "session_start" && event?.type !== "prompt_submit") return;
63251
+ const hookOutput = JSON.stringify({
63252
+ hookSpecificOutput: {
63253
+ hookEventName: event.type === "session_start" ? "SessionStart" : "UserPromptSubmit",
63254
+ additionalContext: message
63255
+ }
63256
+ });
63257
+ process.stdout.write(hookOutput + "\n");
63258
+ }
63227
63259
  function isEphemeralTaskDir(dir) {
63228
63260
  const segments2 = dir.split(path76.sep);
63229
63261
  const wbIdx = segments2.lastIndexOf("WorkBuddy");
@@ -64050,6 +64082,12 @@ async function cachedClaudemdBlock(repoPath) {
64050
64082
  async function localAgentInstructionText(cwd, tool = "") {
64051
64083
  const workspacePath = await resolveWorkspacePath(cwd);
64052
64084
  if (!workspacePath) return "";
64085
+ const config = await loadLocalAgentConfig({ dryRun: true });
64086
+ if (!config) return "";
64087
+ if (!config.workspaceBindings[workspacePath]) {
64088
+ const anchors = await resolveAnchors(cwd);
64089
+ if (!(anchors && config.workspaceBindings[anchors.projectAnchor]) && !await deliveredToWorkspace(workspacePath)) return "";
64090
+ }
64053
64091
  const native = await nativeProjectInstructions(tool, workspacePath);
64054
64092
  if (native.includes(TEAMAI_CLAUDEMD_START) || native.includes(TEAMAI_CLAUDEMD_END)) return "";
64055
64093
  const { block } = await cachedClaudemdBlock(await getResourceRepoPath("project", workspacePath));
@@ -65181,7 +65219,8 @@ async function syncLocalAgent(context) {
65181
65219
  const config = await loadLocalAgentConfig();
65182
65220
  if (!config) return false;
65183
65221
  const currentPath = await resolveWorkspacePath(context.cwd);
65184
- if (currentPath && !config.workspaceBindings[currentPath] && !await inheritWorktreeBinding(config, context.cwd, currentPath)) {
65222
+ if (currentPath && !await enrollWorkspace(config, context.cwd, currentPath)) {
65223
+ if (isBindPromptEnabled()) await noticeUnenrolledWorkspace(currentPath, context.event);
65185
65224
  log.debug(`[local-agent] workspace not enrolled, skipping: ${currentPath}`);
65186
65225
  return false;
65187
65226
  }
@@ -65396,11 +65435,8 @@ async function chooseAgentToken(existing2, agent, current, incoming) {
65396
65435
  log.info(`Keeping the ${agent} access token already on this machine; the new one is not used.`);
65397
65436
  return current;
65398
65437
  }
65399
- function isUserToken(token) {
65400
- return token.startsWith("hk-");
65401
- }
65402
65438
  function legacyTokenAgent(config) {
65403
- if (!config.token || isUserToken(config.token)) return void 0;
65439
+ if (!config.token) return void 0;
65404
65440
  const agents = new Set(Object.values(config.workspaceBindings).map((binding) => binding.ideType).filter((t2) => Boolean(t2)).map(normalizeAgentType));
65405
65441
  return agents.size === 1 ? [...agents][0] : void 0;
65406
65442
  }
@@ -65410,13 +65446,20 @@ async function initLocalAgentHttp(options2) {
65410
65446
  throw new Error("HTTP endpoint is required.");
65411
65447
  }
65412
65448
  const existing2 = await loadLocalAgentConfig();
65413
- const agent = options2.filterAgents?.length === 1 ? normalizeAgentType(options2.filterAgents[0]) : void 0;
65414
65449
  const token = options2.token?.trim() || void 0;
65415
- const perAgent = Boolean(agent && token && !isUserToken(token));
65416
65450
  const sameEndpoint = existing2 !== null && normalizeEndpoint(existing2.endpoint) === endpoint;
65451
+ const named = options2.filterAgents ?? [];
65452
+ const held = sameEndpoint ? Object.keys(existing2?.agentTokens ?? {}) : [];
65453
+ const agent = named.length === 1 ? normalizeAgentType(named[0]) : token && held.length === 1 ? held[0] : void 0;
65454
+ const perAgent = Boolean(agent && token);
65417
65455
  if (existing2 && !options2.force && !(perAgent && sameEndpoint)) {
65418
65456
  throw new Error("HTTP local agent is already initialized. Re-run with --force to overwrite.");
65419
65457
  }
65458
+ if (token && !agent && (named.length > 1 || held.length > 1)) {
65459
+ throw new Error(
65460
+ `An access token works for one agent only. Re-run with --agent <tool> naming the agent it is for${held.length > 1 ? `; this machine already holds credentials for ${held.join(", ")}` : ""}.`
65461
+ );
65462
+ }
65420
65463
  const agentTokens = { ...sameEndpoint ? existing2?.agentTokens : void 0 };
65421
65464
  let sharedToken = perAgent ? sameEndpoint ? existing2?.token : void 0 : token;
65422
65465
  if (perAgent && sharedToken === token) sharedToken = void 0;
@@ -65424,7 +65467,6 @@ async function initLocalAgentHttp(options2) {
65424
65467
  let current = agentTokens[agent];
65425
65468
  if (!current && sameEndpoint && legacyTokenAgent(existing2) === agent) {
65426
65469
  current = existing2.token;
65427
- sharedToken = void 0;
65428
65470
  }
65429
65471
  agentTokens[agent] = sameEndpoint ? await chooseAgentToken(existing2, agent, current, token) : token;
65430
65472
  }
@@ -65452,6 +65494,7 @@ async function initLocalAgentHttp(options2) {
65452
65494
  await memberCodexTrust()
65453
65495
  );
65454
65496
  log.success(`HTTP local agent initialized at ${getConfigPath()}`);
65497
+ log.info("Run `teamai bind-project` once in each workspace it should sync; it leaves any other workspace alone.");
65455
65498
  }
65456
65499
  async function pullLocalAgentForCwd(context) {
65457
65500
  return reportAndSyncLocalAgent({
@@ -66906,11 +66949,11 @@ async function initHttp(url, options2) {
66906
66949
  try {
66907
66950
  await initLocalAgentHttp2({ endpoint: url, token: options2.token, force: options2.force, filterAgents: filterAgents2 });
66908
66951
  } catch (e) {
66909
- log.debug(`Local agent init: ${e.message}`);
66952
+ log.warn(`Local agent init: ${e.message}`);
66910
66953
  }
66911
66954
  await runInitScript(localConfig2, "postInit", options2.dryRun, true);
66912
66955
  log.success("teamai initialized (HTTP read-only)!");
66913
- log.info("Skills/rules will auto-sync on each session start via report/sync. This team is read-only (no push).");
66956
+ log.info("Skills/rules will auto-sync on each session start in an enrolled workspace via report/sync. This team is read-only (no push).");
66914
66957
  closePrompt();
66915
66958
  }
66916
66959
  async function reconcileHooksForInit(teamConfig, localConfig2, filterAgents2) {
@@ -108209,8 +108252,9 @@ async function sourceAddHttp(endpoint, options2) {
108209
108252
  return;
108210
108253
  }
108211
108254
  const { initLocalAgentHttp: initLocalAgentHttp2 } = await Promise.resolve().then(() => (init_local_agent(), local_agent_exports));
108212
- const agent = options2.agent?.trim();
108213
- await initLocalAgentHttp2({ endpoint: trimmed2, token: options2.token, force: true, filterAgents: agent ? [agent] : void 0 });
108255
+ const { normalizeAgentList: normalizeAgentList2 } = await Promise.resolve().then(() => (init_known_agents(), known_agents_exports));
108256
+ const agents = normalizeAgentList2(options2.agent);
108257
+ await initLocalAgentHttp2({ endpoint: trimmed2, token: options2.token, force: true, filterAgents: agents.length > 0 ? agents : void 0 });
108214
108258
  log.success(`HTTP source added (${trimmed2}).`);
108215
108259
  log.info("It will report/sync on the next AI session (via the hook-dispatch hook already installed).");
108216
108260
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-ai/teamai-cli",
3
- "version": "0.40.1",
3
+ "version": "0.40.2",
4
4
  "description": "TeamAI — Make Every Team AI Native (skill sync + shared knowledge base, powered by Git)",
5
5
  "type": "module",
6
6
  "bin": {
@@ -111,7 +111,11 @@ An agent access token (`sk-`) works for one agent only: pass that agent with
111
111
  `--agent <tool>` (see `teamai init --help`).
112
112
 
113
113
  This is a read-only consumer mode — `push` / `contribute` are not available, but
114
- skills and rules still sync.
114
+ skills and rules still sync, in each workspace where `teamai bind-project` ran once
115
+ (run it in the user's project). Binding a ClawPro project is optional:
116
+ `teamai bind-project --skip` enrolls the workspace without one and stops the
117
+ prompt. A worktree inherits its main checkout's choice, so run it once per
118
+ project, not per worktree.
115
119
 
116
120
  **Claude Code or Codex kept in a different directory (`CLAUDE_CONFIG_DIR`,
117
121
  `CODEX_HOME`):** `init` records that directory (as `toolRoots.claude` /