@team-ai/teamai-cli 0.30.3 → 0.30.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +15 -98
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -61809,7 +61809,7 @@ async function canonicalizeWorkspacePath(value) {
61809
61809
  }
61810
61810
  function mergeWorkspaceBindings(existing2, incoming, canonicalKey) {
61811
61811
  if (!existing2) return incoming;
61812
- const rank2 = (binding) => (binding.projectId ?? 0) > 0 ? 2 : binding.projectId === 0 ? 1 : 0;
61812
+ const rank2 = (binding) => binding.projectId > 0 ? 2 : binding.projectName === "__skipped__" ? 1 : 0;
61813
61813
  const existingRank = rank2(existing2);
61814
61814
  const incomingRank = rank2(incoming);
61815
61815
  const existingReal = existingRank === 2;
@@ -61828,80 +61828,14 @@ function isWorkspaceEnrolled(config, workspacePath) {
61828
61828
  return config.workspaceBindings[workspacePath]?.enrolledAt !== void 0;
61829
61829
  }
61830
61830
  function hasWorkspaceBindingDecision(binding) {
61831
- return binding?.projectId !== void 0;
61832
- }
61833
- async function inferWorkspaceEnrollments(config) {
61834
- const inferred = {};
61835
- const add = async (workspacePath, enrolledAt = config.createdAt, ideType) => {
61836
- const canonical2 = await canonicalizeWorkspacePath(workspacePath);
61837
- inferred[canonical2] ??= { enrolledAt, ...ideType ? { ideType } : {} };
61838
- };
61839
- const inheritedAnchors = /* @__PURE__ */ new Set();
61840
- const missingBindings = /* @__PURE__ */ new Set();
61841
- const anchorsByPath = /* @__PURE__ */ new Map();
61842
- const positiveBindings = Object.entries(config.workspaceBindings).filter(([, binding]) => (binding.projectId ?? 0) > 0);
61843
- for (const [workspacePath] of positiveBindings) {
61844
- try {
61845
- await fs35.promises.stat(workspacePath);
61846
- } catch (error2) {
61847
- if (error2.code === "ENOENT") missingBindings.add(workspacePath);
61848
- continue;
61849
- }
61850
- const anchors = await resolveAnchors(workspacePath);
61851
- anchorsByPath.set(workspacePath, anchors);
61852
- if (anchors && anchors.projectAnchor !== anchors.workspaceRoot) {
61853
- inheritedAnchors.add(await canonicalizeWorkspacePath(anchors.projectAnchor));
61854
- }
61855
- }
61856
- const bindingTransactions = /* @__PURE__ */ new Map();
61857
- for (const [workspacePath, binding] of positiveBindings) {
61858
- if (!binding.boundAt) continue;
61859
- const key = `${binding.projectId}\0${binding.boundAt}`;
61860
- const paths = bindingTransactions.get(key) ?? [];
61861
- paths.push(workspacePath);
61862
- bindingTransactions.set(key, paths);
61863
- }
61864
- for (const paths of bindingTransactions.values()) {
61865
- if (!paths.some((workspacePath) => missingBindings.has(workspacePath))) continue;
61866
- for (const workspacePath of paths) {
61867
- if (missingBindings.has(workspacePath)) continue;
61868
- const anchors = anchorsByPath.get(workspacePath);
61869
- if (anchors && anchors.projectAnchor === anchors.workspaceRoot) inheritedAnchors.add(workspacePath);
61870
- }
61871
- }
61872
- for (const [workspacePath, binding] of Object.entries(config.workspaceBindings)) {
61873
- if ((binding.projectId ?? 0) > 0 && !missingBindings.has(workspacePath) && !inheritedAnchors.has(workspacePath)) {
61874
- await add(workspacePath, binding.boundAt ?? config.createdAt, binding.ideType);
61875
- }
61876
- }
61877
- const manifest = await readJson(getManifestPath());
61878
- for (const key of Object.keys(manifest?.scopes ?? {})) {
61879
- const parsed = parseScopeKey(key);
61880
- if (parsed.scope === "project" && parsed.workspacePath) await add(parsed.workspacePath);
61881
- }
61882
- const models = await readJson(getModelManifestPath());
61883
- for (const workspacePath of Object.keys(models?.workspaceModels ?? {})) await add(workspacePath);
61884
- const projectHomes = await listDirs(path76.join(getTeamaiHomePath(), "projects")).catch(() => []);
61885
- const mcpOwnershipFiles = [
61886
- path76.join(getTeamaiHomePath(), "managed-local-mcp.json"),
61887
- ...projectHomes.map((dir) => path76.join(getTeamaiHomePath(), "projects", dir, "managed-local-mcp.json"))
61888
- ];
61889
- for (const file of mcpOwnershipFiles) {
61890
- const records2 = await readJson(file);
61891
- for (const [key, owned] of Object.entries(records2 ?? {})) {
61892
- const match = /^[^:]+:local:(.+)$/.exec(key);
61893
- if (match?.[1] && owned.length > 0) await add(match[1]);
61894
- }
61895
- }
61896
- return inferred;
61831
+ return Boolean(binding && (binding.projectId > 0 || binding.projectName === "__skipped__"));
61897
61832
  }
61898
61833
  async function loadLocalAgentConfig(options2 = {}) {
61899
61834
  const fileConfig = await readJson(getConfigPath());
61900
61835
  if (fileConfig && "disabled" in fileConfig && fileConfig.disabled === true) return null;
61901
61836
  if (fileConfig && "endpoint" in fileConfig && fileConfig.endpoint) {
61902
- const { workspaceEnrollments: legacyEnrollments, ...storedConfig } = fileConfig;
61903
61837
  const config = {
61904
- ...storedConfig,
61838
+ ...fileConfig,
61905
61839
  endpoint: normalizeEndpoint(fileConfig.endpoint),
61906
61840
  workspaceBindings: fileConfig.workspaceBindings ?? {}
61907
61841
  };
@@ -61929,15 +61863,8 @@ async function loadLocalAgentConfig(options2 = {}) {
61929
61863
  }
61930
61864
  config.workspaceBindings = migrated;
61931
61865
  if (fileConfig.workspaceStateVersion !== 1) {
61932
- const enrollments = legacyEnrollments ?? await inferWorkspaceEnrollments(config);
61933
- for (const [wsPath, enrollment] of Object.entries(enrollments)) {
61934
- const canonicalKey = await canonicalizeWorkspacePath(wsPath);
61935
- const binding = config.workspaceBindings[canonicalKey] ?? {};
61936
- config.workspaceBindings[canonicalKey] = {
61937
- ...binding,
61938
- enrolledAt: binding.enrolledAt ?? enrollment.enrolledAt,
61939
- ideType: enrollment.ideType ?? binding.ideType
61940
- };
61866
+ for (const binding of Object.values(config.workspaceBindings)) {
61867
+ if (binding.projectId > 0) binding.enrolledAt ??= binding.boundAt;
61941
61868
  }
61942
61869
  config.workspaceStateVersion = 1;
61943
61870
  migrationChanged = true;
@@ -62391,11 +62318,9 @@ async function persistWorkspaceBinding(config, cwd, resolvedPath, projectId, pro
62391
62318
  await saveLocalAgentConfig(config);
62392
62319
  }
62393
62320
  async function enrollWorkspace(config, resolvedPath) {
62394
- const binding = config.workspaceBindings[resolvedPath] ?? {};
62395
- config.workspaceBindings[resolvedPath] = {
62396
- ...binding,
62397
- enrolledAt: binding.enrolledAt ?? (/* @__PURE__ */ new Date()).toISOString()
62398
- };
62321
+ const enrolledAt = (/* @__PURE__ */ new Date()).toISOString();
62322
+ const binding = config.workspaceBindings[resolvedPath];
62323
+ config.workspaceBindings[resolvedPath] = binding ? { ...binding, enrolledAt: binding.enrolledAt ?? enrolledAt } : { projectId: 0, boundAt: enrolledAt, enrolledAt };
62399
62324
  }
62400
62325
  async function inheritWorktreeBinding(config, cwd, resolvedPath) {
62401
62326
  const anchors = await resolveAnchors(cwd);
@@ -62709,11 +62634,9 @@ function stampWorkspaceTool(config, currentPath, tool) {
62709
62634
  const binding = config.workspaceBindings[currentPath];
62710
62635
  if (!binding?.enrolledAt) return false;
62711
62636
  const normalized = normalizeAgentType(tool);
62712
- if (binding.ideType !== normalized) {
62713
- binding.ideType = normalized;
62714
- return true;
62715
- }
62716
- return false;
62637
+ if (binding.ideType === normalized) return false;
62638
+ binding.ideType = normalized;
62639
+ return true;
62717
62640
  }
62718
62641
  function selectToolWorkspaces(config, currentPath, currentTool) {
62719
62642
  return Object.keys(config.workspaceBindings).filter((wsPath) => {
@@ -62781,7 +62704,7 @@ async function buildReportPayload(config, context) {
62781
62704
  name: path76.basename(wsPath),
62782
62705
  ide_type: currentTool
62783
62706
  };
62784
- if ((wsBinding?.projectId ?? 0) > 0) workspace.project_id = wsBinding.projectId;
62707
+ if (wsBinding.projectId > 0) workspace.project_id = wsBinding.projectId;
62785
62708
  if (wsScope.skills.length > 0) workspace.skills = wsScope.skills;
62786
62709
  if (wsScope.rules.length > 0) workspace.rules = wsScope.rules;
62787
62710
  const wsMcps = await scanMcpFromManifest("project", tool, wsPath);
@@ -62810,7 +62733,7 @@ async function buildSyncPayload(config, context) {
62810
62733
  path: wsPath,
62811
62734
  name: path76.basename(wsPath),
62812
62735
  ide_type: currentTool,
62813
- ...(wsBinding?.projectId ?? 0) > 0 ? { project_id: wsBinding.projectId } : {}
62736
+ ...wsBinding.projectId > 0 ? { project_id: wsBinding.projectId } : {}
62814
62737
  };
62815
62738
  });
62816
62739
  }
@@ -64738,7 +64661,7 @@ async function pullLocalAgentForCwd(context) {
64738
64661
  async function describeLocalAgent(options2 = {}) {
64739
64662
  const config = await loadLocalAgentConfig(options2);
64740
64663
  if (!config) return null;
64741
- const boundProjects = Object.entries(config.workspaceBindings).filter(([, b2]) => (b2.projectId ?? 0) > 0).map(([workspacePath, b2]) => ({ path: workspacePath, projectName: b2.projectName, projectId: b2.projectId }));
64664
+ const boundProjects = Object.entries(config.workspaceBindings).filter(([, b2]) => b2.projectId !== 0).map(([workspacePath, b2]) => ({ path: workspacePath, projectName: b2.projectName, projectId: b2.projectId }));
64742
64665
  const manifest = await loadManifest2();
64743
64666
  const counts = { skills: 0, rules: 0, claudemd: 0 };
64744
64667
  for (const scope of Object.values(manifest.scopes)) {
@@ -64957,13 +64880,7 @@ async function bindCurrentProject(options2) {
64957
64880
  "Current workspace is not enrolled. Run `teamai init --http <ENDPOINT> --token <API_TOKEN>` here first."
64958
64881
  );
64959
64882
  }
64960
- await persistWorkspaceBinding(
64961
- config,
64962
- options2?.cwd ?? process.cwd(),
64963
- workspacePath,
64964
- 0,
64965
- "__skipped__"
64966
- );
64883
+ await persistWorkspaceBinding(config, options2?.cwd ?? process.cwd(), workspacePath, 0, "__skipped__");
64967
64884
  log.info(`\u5DF2\u8DF3\u8FC7\u7ED1\u5B9A\uFF0C\u4EE5\u540E\u4E0D\u518D\u63D0\u793A\u6B64\u5DE5\u4F5C\u533A\u3002`);
64968
64885
  return;
64969
64886
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-ai/teamai-cli",
3
- "version": "0.30.3",
3
+ "version": "0.30.4",
4
4
  "description": "TeamAI — Make Every Team AI Native (skill sync + shared knowledge base, powered by Git)",
5
5
  "type": "module",
6
6
  "bin": {