Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/__tests__/local-agent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ beforeEach(async () => {
origHome = process.env.HOME;
process.env.HOME = tmpDir;
origPpid = process.ppid;
// Bind prompt is off by default — start each test from that baseline.
// Bind prompt is on by default — start each test from that baseline.
delete process.env.TEAMAI_BIND_PROMPT_ENABLED;
// Clean hint markers
const markerPath = path.join(os.tmpdir(), `teamai-bind-hint-${process.ppid}`);
Expand Down Expand Up @@ -232,10 +232,11 @@ describe('local-agent: emitBindingHint via reportAndSyncLocalAgent', () => {
expect(ctx).toContain('teamai bind-project --skip');
});

it('does NOT emit hint by default when TEAMAI_BIND_PROMPT_ENABLED is unset', async () => {
// No process.env.TEAMAI_BIND_PROMPT_ENABLED — bind prompt is off by default.
it('does NOT emit hint when TEAMAI_BIND_PROMPT_ENABLED is explicitly disabled', async () => {
// Explicitly disable the bind prompt via TEAMAI_BIND_PROMPT_ENABLED=0.
process.env.TEAMAI_BIND_PROMPT_ENABLED = '0';
await setupConfig();
const projectDir = path.join(tmpDir, 'default-off-project');
const projectDir = path.join(tmpDir, 'disabled-project');
await fse.ensureDir(projectDir);
const { execFileSync } = await import('node:child_process');
execFileSync('git', ['init'], { cwd: projectDir, stdio: 'ignore' });
Expand Down
11 changes: 7 additions & 4 deletions src/local-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,12 +816,15 @@ async function ensureWorkspaceBinding(

/**
* The organization-binding prompt (TTY prompt + injected hook context) is
* off by default. Enable it explicitly with `TEAMAI_BIND_PROMPT_ENABLED=1`.
* The manual `teamai bind-project` command is always available regardless.
* on by default. Disable it explicitly with `TEAMAI_BIND_PROMPT_ENABLED=0`
* (or `false`). The manual `teamai bind-project` command is always available
* regardless.
*/
function isBindPromptEnabled(): boolean {
const flag = process.env.TEAMAI_BIND_PROMPT_ENABLED;
return flag === '1' || flag === 'true';
if (flag === undefined) return true;
const normalized = flag.toLowerCase();
return normalized !== '0' && normalized !== 'false';
}

async function emitBindingHint(
Expand Down Expand Up @@ -1650,7 +1653,7 @@ export async function reportAndSyncLocalAgent(context: LocalAgentContext): Promi
// Binding prompt is injected via stdout hook context (not HTTP), so it must run
// even inside the CloudStudio sandbox — the sandbox guard below only skips the
// HTTP report/sync that would produce a duplicate card. Resolve the workspace
// only when the prompt is enabled, so the default-off path forks no git process.
// only when the prompt is enabled, so the disabled path forks no git process.
if (isBindPromptEnabled()) {
const workspacePath = await resolveWorkspacePath(context.cwd);
if (workspacePath) {
Expand Down
Loading