@team-ai/teamai-cli 0.40.1 → 0.40.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/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,26 @@ async function emitBindingHint(config, workspacePath, sessionId, tool) {
63224
63237
  });
63225
63238
  process.stdout.write(hookOutput + "\n");
63226
63239
  }
63240
+ function unenrolledNotice(context, workspacePath) {
63241
+ const markerKey = context.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 text2 = [
63249
+ `[teamai] This workspace is not enrolled, so teamai reports and syncs nothing here: ${workspacePath}`,
63250
+ "Run `teamai bind-project` once in it to enroll \u2014 bind a ClawPro project, or `--skip` to enroll without one."
63251
+ ].join("\n");
63252
+ const hookOutput = JSON.stringify({
63253
+ hookSpecificOutput: {
63254
+ hookEventName: context.event?.type === "prompt_submit" ? "UserPromptSubmit" : "SessionStart",
63255
+ additionalContext: text2
63256
+ }
63257
+ });
63258
+ process.stdout.write(hookOutput + "\n");
63259
+ }
63227
63260
  function isEphemeralTaskDir(dir) {
63228
63261
  const segments2 = dir.split(path76.sep);
63229
63262
  const wbIdx = segments2.lastIndexOf("WorkBuddy");
@@ -64050,6 +64083,12 @@ async function cachedClaudemdBlock(repoPath) {
64050
64083
  async function localAgentInstructionText(cwd, tool = "") {
64051
64084
  const workspacePath = await resolveWorkspacePath(cwd);
64052
64085
  if (!workspacePath) return "";
64086
+ const config = await loadLocalAgentConfig({ dryRun: true });
64087
+ if (!config) return "";
64088
+ if (!config.workspaceBindings[workspacePath]) {
64089
+ const anchors = await resolveAnchors(cwd);
64090
+ if (!(anchors && config.workspaceBindings[anchors.projectAnchor]) && !await deliveredToWorkspace(workspacePath)) return "";
64091
+ }
64053
64092
  const native = await nativeProjectInstructions(tool, workspacePath);
64054
64093
  if (native.includes(TEAMAI_CLAUDEMD_START) || native.includes(TEAMAI_CLAUDEMD_END)) return "";
64055
64094
  const { block } = await cachedClaudemdBlock(await getResourceRepoPath("project", workspacePath));
@@ -65181,8 +65220,9 @@ async function syncLocalAgent(context) {
65181
65220
  const config = await loadLocalAgentConfig();
65182
65221
  if (!config) return false;
65183
65222
  const currentPath = await resolveWorkspacePath(context.cwd);
65184
- if (currentPath && !config.workspaceBindings[currentPath] && !await inheritWorktreeBinding(config, context.cwd, currentPath)) {
65223
+ if (currentPath && !await enrollWorkspace(config, context.cwd, currentPath)) {
65185
65224
  log.debug(`[local-agent] workspace not enrolled, skipping: ${currentPath}`);
65225
+ if (isBindPromptEnabled()) unenrolledNotice(context, currentPath);
65186
65226
  return false;
65187
65227
  }
65188
65228
  if (currentPath && isBindPromptEnabled() && isBindPromptTool(context.tool)) {
@@ -65410,13 +65450,21 @@ async function initLocalAgentHttp(options2) {
65410
65450
  throw new Error("HTTP endpoint is required.");
65411
65451
  }
65412
65452
  const existing2 = await loadLocalAgentConfig();
65413
- const agent = options2.filterAgents?.length === 1 ? normalizeAgentType(options2.filterAgents[0]) : void 0;
65414
65453
  const token = options2.token?.trim() || void 0;
65415
- const perAgent = Boolean(agent && token && !isUserToken(token));
65416
65454
  const sameEndpoint = existing2 !== null && normalizeEndpoint(existing2.endpoint) === endpoint;
65455
+ const namedCount = options2.filterAgents?.length ?? 0;
65456
+ const namedAgent = namedCount === 1 ? normalizeAgentType(options2.filterAgents[0]) : void 0;
65457
+ const held = sameEndpoint ? Object.keys(existing2?.agentTokens ?? {}) : [];
65458
+ const agent = namedAgent ?? (token && !isUserToken(token) && held.length === 1 ? held[0] : void 0);
65459
+ const perAgent = Boolean(agent && token && !isUserToken(token));
65417
65460
  if (existing2 && !options2.force && !(perAgent && sameEndpoint)) {
65418
65461
  throw new Error("HTTP local agent is already initialized. Re-run with --force to overwrite.");
65419
65462
  }
65463
+ if (token && !agent && !isUserToken(token) && (namedCount > 1 || held.length > 1)) {
65464
+ throw new Error(
65465
+ `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(", ")}` : ""}.`
65466
+ );
65467
+ }
65420
65468
  const agentTokens = { ...sameEndpoint ? existing2?.agentTokens : void 0 };
65421
65469
  let sharedToken = perAgent ? sameEndpoint ? existing2?.token : void 0 : token;
65422
65470
  if (perAgent && sharedToken === token) sharedToken = void 0;
@@ -65424,7 +65472,6 @@ async function initLocalAgentHttp(options2) {
65424
65472
  let current = agentTokens[agent];
65425
65473
  if (!current && sameEndpoint && legacyTokenAgent(existing2) === agent) {
65426
65474
  current = existing2.token;
65427
- sharedToken = void 0;
65428
65475
  }
65429
65476
  agentTokens[agent] = sameEndpoint ? await chooseAgentToken(existing2, agent, current, token) : token;
65430
65477
  }
@@ -65452,6 +65499,7 @@ async function initLocalAgentHttp(options2) {
65452
65499
  await memberCodexTrust()
65453
65500
  );
65454
65501
  log.success(`HTTP local agent initialized at ${getConfigPath()}`);
65502
+ log.info("Run `teamai bind-project` once in each workspace it should sync; it leaves any other workspace alone.");
65455
65503
  }
65456
65504
  async function pullLocalAgentForCwd(context) {
65457
65505
  return reportAndSyncLocalAgent({
@@ -66906,11 +66954,11 @@ async function initHttp(url, options2) {
66906
66954
  try {
66907
66955
  await initLocalAgentHttp2({ endpoint: url, token: options2.token, force: options2.force, filterAgents: filterAgents2 });
66908
66956
  } catch (e) {
66909
- log.debug(`Local agent init: ${e.message}`);
66957
+ log.warn(`Local agent init: ${e.message}`);
66910
66958
  }
66911
66959
  await runInitScript(localConfig2, "postInit", options2.dryRun, true);
66912
66960
  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).");
66961
+ 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
66962
  closePrompt();
66915
66963
  }
66916
66964
  async function reconcileHooksForInit(teamConfig, localConfig2, filterAgents2) {
@@ -108209,10 +108257,11 @@ async function sourceAddHttp(endpoint, options2) {
108209
108257
  return;
108210
108258
  }
108211
108259
  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 });
108260
+ const { normalizeAgentList: normalizeAgentList2 } = await Promise.resolve().then(() => (init_known_agents(), known_agents_exports));
108261
+ const agents = normalizeAgentList2(options2.agent);
108262
+ await initLocalAgentHttp2({ endpoint: trimmed2, token: options2.token, force: true, filterAgents: agents.length > 0 ? agents : void 0 });
108214
108263
  log.success(`HTTP source added (${trimmed2}).`);
108215
- log.info("It will report/sync on the next AI session (via the hook-dispatch hook already installed).");
108264
+ log.info("It will report/sync on the next AI session in each workspace where `teamai bind-project` ran once (via the hook-dispatch hook already installed).");
108216
108265
  }
108217
108266
  async function sourceRemoveHttp(options2) {
108218
108267
  if (options2.dryRun) {
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.3",
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` /