teamai-cli 0.22.0-beta.5 → 0.22.0
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/index.js +42 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8655,6 +8655,38 @@ async function promptForProjectBinding(workspacePath, projects) {
|
|
|
8655
8655
|
if (Number.isNaN(index) || index < 1 || index > projects.length) return null;
|
|
8656
8656
|
return projects[index - 1];
|
|
8657
8657
|
}
|
|
8658
|
+
async function persistWorkspaceBinding(config, cwd, resolvedPath, projectId, projectName) {
|
|
8659
|
+
const anchors = await resolveAnchors(cwd);
|
|
8660
|
+
const keys = /* @__PURE__ */ new Set([resolvedPath]);
|
|
8661
|
+
if (anchors) {
|
|
8662
|
+
keys.add(anchors.projectAnchor);
|
|
8663
|
+
keys.add(anchors.workspaceRoot);
|
|
8664
|
+
}
|
|
8665
|
+
const boundAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
8666
|
+
for (const key of keys) {
|
|
8667
|
+
config.workspaceBindings[key] = {
|
|
8668
|
+
...config.workspaceBindings[key] ?? {},
|
|
8669
|
+
projectId,
|
|
8670
|
+
projectName,
|
|
8671
|
+
boundAt
|
|
8672
|
+
};
|
|
8673
|
+
}
|
|
8674
|
+
await saveLocalAgentConfig(config);
|
|
8675
|
+
}
|
|
8676
|
+
async function inheritWorktreeBinding(config, cwd, resolvedPath) {
|
|
8677
|
+
const anchors = await resolveAnchors(cwd);
|
|
8678
|
+
if (!anchors || anchors.projectAnchor === anchors.workspaceRoot) return false;
|
|
8679
|
+
const anchorBinding = config.workspaceBindings[anchors.projectAnchor];
|
|
8680
|
+
if (!anchorBinding) return false;
|
|
8681
|
+
config.workspaceBindings[resolvedPath] = {
|
|
8682
|
+
...config.workspaceBindings[resolvedPath] ?? {},
|
|
8683
|
+
projectId: anchorBinding.projectId,
|
|
8684
|
+
projectName: anchorBinding.projectName,
|
|
8685
|
+
boundAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8686
|
+
};
|
|
8687
|
+
await saveLocalAgentConfig(config);
|
|
8688
|
+
return true;
|
|
8689
|
+
}
|
|
8658
8690
|
async function bindWorkspaceToProject(workspacePath, projectId) {
|
|
8659
8691
|
const config = await loadLocalAgentConfig();
|
|
8660
8692
|
if (!config) {
|
|
@@ -8668,13 +8700,13 @@ async function bindWorkspaceToProject(workspacePath, projectId) {
|
|
|
8668
8700
|
projectName: project.name,
|
|
8669
8701
|
boundAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8670
8702
|
};
|
|
8671
|
-
config
|
|
8672
|
-
await saveLocalAgentConfig(config);
|
|
8703
|
+
await persistWorkspaceBinding(config, workspacePath, workspacePath, project.id, project.name);
|
|
8673
8704
|
log.success(`\u5DF2\u5C06\u5DE5\u4F5C\u533A\u7ED1\u5B9A\u5230\u9879\u76EE\uFF1A${project.name} [id=${project.id}]`);
|
|
8674
8705
|
return binding;
|
|
8675
8706
|
}
|
|
8676
|
-
async function ensureWorkspaceBinding(config, workspacePath, sessionId) {
|
|
8707
|
+
async function ensureWorkspaceBinding(config, workspacePath, sessionId, cwd) {
|
|
8677
8708
|
if (config.workspaceBindings[workspacePath]) return;
|
|
8709
|
+
if (await inheritWorktreeBinding(config, cwd, workspacePath)) return;
|
|
8678
8710
|
const markerKey = sessionId || `ppid-${process.ppid}`;
|
|
8679
8711
|
const hintMarker = path25.join(os7.tmpdir(), `teamai-bind-session-${markerKey}`);
|
|
8680
8712
|
if (fs12.existsSync(hintMarker)) return;
|
|
@@ -8692,12 +8724,7 @@ async function ensureWorkspaceBinding(config, workspacePath, sessionId) {
|
|
|
8692
8724
|
if (projects.length === 0) return;
|
|
8693
8725
|
const project = await promptForProjectBinding(workspacePath, projects);
|
|
8694
8726
|
if (project) {
|
|
8695
|
-
config
|
|
8696
|
-
projectId: project.id,
|
|
8697
|
-
projectName: project.name,
|
|
8698
|
-
boundAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
8699
|
-
};
|
|
8700
|
-
await saveLocalAgentConfig(config);
|
|
8727
|
+
await persistWorkspaceBinding(config, cwd, workspacePath, project.id, project.name);
|
|
8701
8728
|
return;
|
|
8702
8729
|
}
|
|
8703
8730
|
const projectList = projects.map((p) => `${p.name} (id=${p.id})`).join(", ");
|
|
@@ -8721,8 +8748,9 @@ function isBindPromptEnabled() {
|
|
|
8721
8748
|
const normalized = flag.toLowerCase();
|
|
8722
8749
|
return normalized !== "0" && normalized !== "false";
|
|
8723
8750
|
}
|
|
8724
|
-
async function emitBindingHint(config, workspacePath, sessionId) {
|
|
8751
|
+
async function emitBindingHint(config, workspacePath, sessionId, cwd) {
|
|
8725
8752
|
if (config.workspaceBindings[workspacePath]) return;
|
|
8753
|
+
if (await inheritWorktreeBinding(config, cwd, workspacePath)) return;
|
|
8726
8754
|
const markerKey = sessionId || `ppid-${process.ppid}`;
|
|
8727
8755
|
const hintMarker = path25.join(os7.tmpdir(), `teamai-bind-hint-${markerKey}`);
|
|
8728
8756
|
if (fs12.existsSync(hintMarker)) return;
|
|
@@ -9695,10 +9723,10 @@ async function reportAndSyncLocalAgent(context) {
|
|
|
9695
9723
|
if (workspacePath) {
|
|
9696
9724
|
const sid = context.event?.sessionId;
|
|
9697
9725
|
if (context.event?.type === "session_start") {
|
|
9698
|
-
await ensureWorkspaceBinding(config, workspacePath, sid);
|
|
9726
|
+
await ensureWorkspaceBinding(config, workspacePath, sid, context.cwd);
|
|
9699
9727
|
}
|
|
9700
9728
|
if (context.event?.type === "prompt_submit") {
|
|
9701
|
-
await emitBindingHint(config, workspacePath, sid);
|
|
9729
|
+
await emitBindingHint(config, workspacePath, sid, context.cwd);
|
|
9702
9730
|
}
|
|
9703
9731
|
}
|
|
9704
9732
|
}
|
|
@@ -9907,8 +9935,7 @@ async function bindCurrentProject(options) {
|
|
|
9907
9935
|
if (!config) {
|
|
9908
9936
|
throw new Error("Local agent not initialized. Run `teamai init --http` first.");
|
|
9909
9937
|
}
|
|
9910
|
-
config
|
|
9911
|
-
await saveLocalAgentConfig(config);
|
|
9938
|
+
await persistWorkspaceBinding(config, options?.cwd ?? process.cwd(), workspacePath, 0, "__skipped__");
|
|
9912
9939
|
log.info(`\u5DF2\u8DF3\u8FC7\u7ED1\u5B9A\uFF0C\u4EE5\u540E\u4E0D\u518D\u63D0\u793A\u6B64\u5DE5\u4F5C\u533A\u3002`);
|
|
9913
9940
|
return;
|
|
9914
9941
|
}
|
|
@@ -9943,6 +9970,7 @@ var init_local_agent = __esm({
|
|
|
9943
9970
|
init_plugin_lifecycle();
|
|
9944
9971
|
init_types();
|
|
9945
9972
|
init_home();
|
|
9973
|
+
init_git2();
|
|
9946
9974
|
execFileAsync = promisify(execFile2);
|
|
9947
9975
|
LOCAL_AGENT_DIR = "local-agent";
|
|
9948
9976
|
CONFIG_FILE = "config.json";
|