@team-ai/teamai-cli 0.22.2 → 0.22.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
@@ -61231,44 +61231,6 @@ async function bindWorkspaceToProject(workspacePath, projectId) {
61231
61231
  log.success(`\u5DF2\u5C06\u5DE5\u4F5C\u533A\u7ED1\u5B9A\u5230\u9879\u76EE\uFF1A${project.name} [id=${project.id}]`);
61232
61232
  return binding;
61233
61233
  }
61234
- async function ensureWorkspaceBinding(config, workspacePath, sessionId, cwd) {
61235
- if (config.workspaceBindings[workspacePath]) return;
61236
- if (await inheritWorktreeBinding(config, cwd, workspacePath)) return;
61237
- const markerKey = sessionId || `ppid-${process.ppid}`;
61238
- const hintMarker = path74.join(os9.tmpdir(), `teamai-bind-session-${markerKey}`);
61239
- if (fs32.existsSync(hintMarker)) return;
61240
- try {
61241
- fs32.writeFileSync(hintMarker, "");
61242
- } catch {
61243
- }
61244
- let projects;
61245
- try {
61246
- projects = await fetchUserProjects(config);
61247
- } catch (e) {
61248
- log.debug(`local-agent: failed to load user projects: ${e.message}`);
61249
- return;
61250
- }
61251
- if (projects.length === 0) return;
61252
- const project = await promptForProjectBinding(workspacePath, projects);
61253
- if (project) {
61254
- await persistWorkspaceBinding(config, cwd, workspacePath, project.id, project.name);
61255
- return;
61256
- }
61257
- const projectList = projects.map((p2) => `${p2.name} (id=${p2.id})`).join(", ");
61258
- const context = [
61259
- "[teamai] \u5F53\u524D\u5DE5\u4F5C\u533A\u5C1A\u672A\u7ED1\u5B9A\u9879\u76EE\uFF0C\u65E0\u6CD5\u63A5\u6536\u9879\u76EE\u4E0B\u53D1\u7684 skills/rules/claudemd \u8D44\u6E90\u3002",
61260
- `\u53EF\u7528\u9879\u76EE: ${projectList}`,
61261
- `\u8BF7\u63D0\u793A\u7528\u6237\u8FD0\u884C: teamai bind-project`,
61262
- `\u6216\u6307\u5B9A\u9879\u76EE: teamai bind-project --project-id <id>`
61263
- ].join("\n");
61264
- const hookOutput = JSON.stringify({
61265
- hookSpecificOutput: {
61266
- hookEventName: "SessionStart",
61267
- additionalContext: context
61268
- }
61269
- });
61270
- process.stdout.write(hookOutput + "\n");
61271
- }
61272
61234
  function isBindPromptEnabled() {
61273
61235
  const flag = process.env.TEAMAI_BIND_PROMPT_ENABLED;
61274
61236
  if (flag === void 0) return true;
@@ -61276,10 +61238,10 @@ function isBindPromptEnabled() {
61276
61238
  return normalized !== "0" && normalized !== "false";
61277
61239
  }
61278
61240
  function resolveProjectPromptMode(config) {
61279
- if (config.projectPromptMode === "unset" || config.projectPromptMode === "manual") {
61241
+ if (config.projectPromptMode === "auto" || config.projectPromptMode === "manual") {
61280
61242
  return config.projectPromptMode;
61281
61243
  }
61282
- return "auto";
61244
+ return "unset";
61283
61245
  }
61284
61246
  async function emitPromptModeChooser(config, workspacePath, sessionId, cwd) {
61285
61247
  if (config.workspaceBindings[workspacePath]) return;
@@ -61297,12 +61259,12 @@ async function emitPromptModeChooser(config, workspacePath, sessionId, cwd) {
61297
61259
  "---",
61298
61260
  "\u5F53\u524D\u8BBE\u5907\u5C1A\u672A\u9009\u62E9 ClawPro \u9879\u76EE\u5173\u8054\u65B9\u5F0F\u3002\u8BF7\u56DE\u590D\u6570\u5B57\u9009\u62E9\uFF1A",
61299
61261
  "",
61300
- "1. \u81EA\u52A8\u63D0\u9192\uFF1A\u8FDB\u5165\u65B0\u7684\u672A\u7ED1\u5B9A\u5DE5\u4F5C\u533A\u65F6\u8BE2\u95EE\u662F\u5426\u5173\u8054",
61301
- "2. \u624B\u52A8\u5173\u8054\uFF1A\u5173\u95ED\u81EA\u52A8\u63D0\u9192",
61262
+ "1. \u81EA\u52A8\u63D0\u9192\uFF1A\u6BCF\u4E2A\u672A\u7ED1\u5B9A\u5DE5\u4F5C\u533A\u90FD\u63D0\u9192\u7ED1\u5B9A\u9879\u76EE\uFF08\u6709\u53EF\u7ED1\u5B9A\u9879\u76EE\u65F6\uFF09",
61263
+ "2. \u624B\u52A8\u5173\u8054\uFF1A\u4E4B\u540E\u81EA\u5DF1\u5173\u8054\u9879\u76EE\uFF0C\u4E0D\u518D\u81EA\u52A8\u63D0\u9192",
61302
61264
  "---",
61303
61265
  "",
61304
61266
  "\u6267\u884C\u89C4\u5219\uFF08\u4E0D\u8981\u5C55\u793A\u7ED9\u7528\u6237\uFF09\uFF1A",
61305
- '- \u7528\u6237\u56DE\u590D 1 \u2192 \u6267\u884C `teamai bind-project --prompt-mode auto`\uFF0C\u5B8C\u6210\u540E\u56DE\u590D"\u5DF2\u5F00\u542F\u81EA\u52A8\u63D0\u9192\u3002\u8FDB\u5165\u65B0\u7684\u672A\u7ED1\u5B9A\u5DE5\u4F5C\u533A\u65F6\u4F1A\u8BE2\u95EE\u662F\u5426\u5173\u8054\u3002"',
61267
+ '- \u7528\u6237\u56DE\u590D 1 \u2192 \u6267\u884C `teamai bind-project --prompt-mode auto`\uFF0C\u5B8C\u6210\u540E\u56DE\u590D"\u5DF2\u5F00\u542F\u81EA\u52A8\u63D0\u9192\u3002\u4E4B\u540E\u6BCF\u4E2A\u672A\u7ED1\u5B9A\u5DE5\u4F5C\u533A\uFF0C\u53EA\u8981\u6709\u53EF\u7ED1\u5B9A\u9879\u76EE\uFF0C\u90FD\u4F1A\u63D0\u9192\u7ED1\u5B9A\u3002"',
61306
61268
  "- \u7528\u6237\u56DE\u590D 2 \u2192 \u6267\u884C `teamai bind-project --prompt-mode manual`\uFF0C\u5B8C\u6210\u540E\u539F\u6837\u5C55\u793A\u4E0B\u9762\u8FD9\u6BB5\uFF1A",
61307
61269
  MANUAL_ASSOCIATION_COMMANDS
61308
61270
  ].join("\n");
@@ -61318,23 +61280,43 @@ function isBindPromptTool(tool) {
61318
61280
  const kind = modelAgentKind(tool);
61319
61281
  return kind === "codebuddy" || kind === "workbuddy";
61320
61282
  }
61321
- async function emitBindingHint(config, workspacePath, sessionId, cwd) {
61322
- if (config.workspaceBindings[workspacePath]) return;
61323
- if (await inheritWorktreeBinding(config, cwd, workspacePath)) return;
61283
+ function bindHintStatePath(sessionId) {
61324
61284
  const markerKey = sessionId || `ppid-${process.ppid}`;
61325
- const hintMarker = path74.join(os9.tmpdir(), `teamai-bind-hint-${markerKey}`);
61326
- if (fs32.existsSync(hintMarker)) return;
61285
+ return path74.join(os9.tmpdir(), `teamai-bind-hint-${markerKey}`);
61286
+ }
61287
+ function readBindHintState(file) {
61327
61288
  try {
61328
- fs32.writeFileSync(hintMarker, "");
61289
+ const parsed = JSON.parse(fs32.readFileSync(file, "utf8"));
61290
+ return parsed && typeof parsed === "object" ? parsed : {};
61329
61291
  } catch {
61292
+ return {};
61330
61293
  }
61294
+ }
61295
+ async function emitBindingHint(config, workspacePath, sessionId, cwd) {
61296
+ if (config.workspaceBindings[workspacePath]) return;
61297
+ if (await inheritWorktreeBinding(config, cwd, workspacePath)) return;
61298
+ const statePath = bindHintStatePath(sessionId);
61299
+ const state = readBindHintState(statePath);
61300
+ const reminded = new Set(state.workspaces ?? []);
61301
+ if (state.empty || reminded.has(workspacePath)) return;
61331
61302
  let projects;
61332
61303
  try {
61333
61304
  projects = await fetchUserProjects(config);
61334
61305
  } catch {
61335
61306
  return;
61336
61307
  }
61337
- if (projects.length === 0) return;
61308
+ if (projects.length === 0) {
61309
+ try {
61310
+ fs32.writeFileSync(statePath, JSON.stringify({ ...state, empty: true }));
61311
+ } catch {
61312
+ }
61313
+ return;
61314
+ }
61315
+ reminded.add(workspacePath);
61316
+ try {
61317
+ fs32.writeFileSync(statePath, JSON.stringify({ empty: false, workspaces: [...reminded] }));
61318
+ } catch {
61319
+ }
61338
61320
  const skipNum = projects.length + 1;
61339
61321
  const choices = projects.map((p2, i2) => `${i2 + 1}. \u7ED1\u5B9A\u5230\u300C${p2.name}\u300D\u9879\u76EE`);
61340
61322
  const actions = projects.map((p2, i2) => `- \u7528\u6237\u56DE\u590D ${i2 + 1} \u2192 \u6267\u884C \`teamai bind-project --project-id ${p2.id}\`\uFF0C\u5B8C\u6210\u540E\u56DE\u590D"\u7ED1\u5B9A\u5B8C\u6210\uFF0C\u8BF7\u5F00\u65B0\u4F1A\u8BDD\u751F\u6548"`);
@@ -63320,13 +63302,8 @@ async function syncLocalAgent(context) {
63320
63302
  const mode = resolveProjectPromptMode(config);
63321
63303
  if (mode === "unset" && context.event?.type === "prompt_submit") {
63322
63304
  await emitPromptModeChooser(config, workspacePath, sid, context.cwd);
63323
- } else if (mode === "auto") {
63324
- if (context.event?.type === "session_start") {
63325
- await ensureWorkspaceBinding(config, workspacePath, sid, context.cwd);
63326
- }
63327
- if (context.event?.type === "prompt_submit") {
63328
- await emitBindingHint(config, workspacePath, sid, context.cwd);
63329
- }
63305
+ } else if (mode === "auto" && context.event?.type === "prompt_submit") {
63306
+ await emitBindingHint(config, workspacePath, sid, context.cwd);
63330
63307
  }
63331
63308
  }
63332
63309
  }
@@ -63526,8 +63503,9 @@ async function initLocalAgentHttp(options2) {
63526
63503
  workspaceBindings: existing2?.workspaceBindings ?? {},
63527
63504
  userGroupId: existing2?.userGroupId,
63528
63505
  userGroupName: existing2?.userGroupName,
63529
- // A re-init keeps a choice the user already made. A first install asks once.
63530
- ...existing2?.projectPromptMode ? { projectPromptMode: existing2.projectPromptMode } : existing2 ? {} : { projectPromptMode: "unset" }
63506
+ // A re-init keeps auto/manual. A first install, and an older config that
63507
+ // never recorded a choice, both ask once.
63508
+ projectPromptMode: existing2?.projectPromptMode === "auto" || existing2?.projectPromptMode === "manual" ? existing2.projectPromptMode : "unset"
63531
63509
  };
63532
63510
  await ensureDir(getLocalAgentHome());
63533
63511
  await saveLocalAgentConfig(config);
@@ -63779,7 +63757,7 @@ async function bindCurrentProject(options2) {
63779
63757
  if (options2?.settings || options2?.promptMode === "manual") {
63780
63758
  process.stdout.write(MANUAL_ASSOCIATION_COMMANDS + "\n");
63781
63759
  } else if (options2?.promptMode === "auto") {
63782
- log.info("Project association reminders are on. A new unbound workspace will ask whether to bind.");
63760
+ log.info("Project association reminders are on. Each unbound workspace is reminded to bind when projects are available.");
63783
63761
  }
63784
63762
  }
63785
63763
  const bindRequested = !!options2?.skip || options2?.projectId !== void 0 || !wantsReminder;
@@ -136030,7 +136008,7 @@ program2.command("hook-dispatch <event> [hookArgs...]", { hidden: true }).descri
136030
136008
  process.exit(0);
136031
136009
  }
136032
136010
  });
136033
- program2.command("bind-project").description("Bind the current workspace to a ClawPro project for HTTP local-agent sync").option("--project-id <id>", "Project ID from /projects/mine").option("--skip", "Mark current workspace as skipped (never prompt again)").option("--prompt-mode <mode>", "Project association reminder: auto (ask in each new workspace) or manual (no automatic reminder)").option("--settings", "Show the project association reminder mode and how to change it").action(async (cmdOpts) => {
136011
+ program2.command("bind-project").description("Bind the current workspace to a ClawPro project for HTTP local-agent sync").option("--project-id <id>", "Project ID from /projects/mine").option("--skip", "Mark current workspace as skipped (never prompt again)").option("--prompt-mode <mode>", "Project association reminder: auto (remind each unbound workspace to bind when projects exist) or manual (no automatic reminder)").option("--settings", "Show the project association reminder mode and how to change it").action(async (cmdOpts) => {
136034
136012
  const { bindCurrentProject: bindCurrentProject2 } = await Promise.resolve().then(() => (init_local_agent(), local_agent_exports));
136035
136013
  await bindCurrentProject2({
136036
136014
  projectId: cmdOpts.projectId ? Number.parseInt(cmdOpts.projectId, 10) : void 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-ai/teamai-cli",
3
- "version": "0.22.2",
3
+ "version": "0.22.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": {
@@ -364,7 +364,7 @@ Generated: do not edit by hand. Regenerate with
364
364
  - `teamai bind-project` — Bind the current workspace to a ClawPro project for HTTP local-agent sync
365
365
  - `--project-id <id>` — Project ID from /projects/mine
366
366
  - `--skip` — Mark current workspace as skipped (never prompt again)
367
- - `--prompt-mode <mode>` — Project association reminder: auto (ask in each new workspace) or manual (no automatic reminder)
367
+ - `--prompt-mode <mode>` — Project association reminder: auto (remind each unbound workspace to bind when projects exist) or manual (no automatic reminder)
368
368
  - `--settings` — Show the project association reminder mode and how to change it
369
369
 
370
370
  ## contribute