feat(auth): add opt-in shared context groups across accounts

This commit is contained in:
Tam Nhu Tran committed 2026-02-24 23:54:03 +07:00
1 parent 1dae52014b
commit 4fed74c64b
21 files changed
+787 -25

No files matched your search

+7 -3
View File
@@ -9,6 +9,7 @@
import * as fs from 'fs';
import * as path from 'path';
import SharedManager from './shared-manager';
import { AccountContextPolicy, DEFAULT_ACCOUNT_CONTEXT_MODE } from '../auth/account-context';
import { getCcsDir } from '../utils/config-manager';
/**
@@ -26,7 +27,10 @@ class InstanceManager {
/**
* Ensure instance exists for profile (lazy init only)
*/
async ensureInstance(profileName: string): Promise<string> {
async ensureInstance(
profileName: string,
contextPolicy: AccountContextPolicy = { mode: DEFAULT_ACCOUNT_CONTEXT_MODE }
): Promise<string> {
const instancePath = this.getInstancePath(profileName);
// Lazy initialization
@@ -37,8 +41,8 @@ class InstanceManager {
// Validate structure (auto-fix missing dirs)
this.validateInstance(instancePath);
// Keep project memory shared across instances.
await this.sharedManager.syncProjectMemories(instancePath);
// Apply context policy (isolated by default, optional shared group).
await this.sharedManager.syncProjectContext(instancePath, contextPolicy);
return instancePath;
}