summaryrefslogtreecommitdiff
path: root/packages/core
diff options
context:
space:
mode:
Diffstat (limited to 'packages/core')
-rw-r--r--packages/core/src/config/config.ts13
-rw-r--r--packages/core/src/core/client.ts30
2 files changed, 42 insertions, 1 deletions
diff --git a/packages/core/src/config/config.ts b/packages/core/src/config/config.ts
index edb24351..b2d5f387 100644
--- a/packages/core/src/config/config.ts
+++ b/packages/core/src/config/config.ts
@@ -197,7 +197,7 @@ export class Config {
private readonly embeddingModel: string;
private readonly sandbox: SandboxConfig | undefined;
private readonly targetDir: string;
- private readonly workspaceContext: WorkspaceContext;
+ private workspaceContext: WorkspaceContext;
private readonly debugMode: boolean;
private readonly question: string | undefined;
private readonly fullContext: boolean;
@@ -394,6 +394,17 @@ export class Config {
return this.sandbox;
}
+ isRestrictiveSandbox(): boolean {
+ const sandboxConfig = this.getSandbox();
+ const seatbeltProfile = process.env.SEATBELT_PROFILE;
+ return (
+ !!sandboxConfig &&
+ sandboxConfig.command === 'sandbox-exec' &&
+ !!seatbeltProfile &&
+ seatbeltProfile.startsWith('restrictive-')
+ );
+ }
+
getTargetDir(): string {
return this.targetDir;
}
diff --git a/packages/core/src/core/client.ts b/packages/core/src/core/client.ts
index 5b26e32c..be105971 100644
--- a/packages/core/src/core/client.ts
+++ b/packages/core/src/core/client.ts
@@ -171,6 +171,35 @@ export class GeminiClient {
this.chat = await this.startChat();
}
+ async addDirectoryContext(): Promise<void> {
+ if (!this.chat) {
+ return;
+ }
+
+ this.getChat().addHistory({
+ role: 'user',
+ parts: [{ text: await this.getDirectoryContext() }],
+ });
+ }
+
+ private async getDirectoryContext(): Promise<string> {
+ const workspaceContext = this.config.getWorkspaceContext();
+ const workspaceDirectories = workspaceContext.getDirectories();
+
+ const folderStructures = await Promise.all(
+ workspaceDirectories.map((dir) =>
+ getFolderStructure(dir, {
+ fileService: this.config.getFileService(),
+ }),
+ ),
+ );
+
+ const folderStructure = folderStructures.join('\n');
+ const dirList = workspaceDirectories.map((dir) => ` - ${dir}`).join('\n');
+ const workingDirPreamble = `I'm currently working in the following directories:\n${dirList}\n Folder structures are as follows:\n${folderStructure}`;
+ return workingDirPreamble;
+ }
+
private async getEnvironment(): Promise<Part[]> {
const today = new Date().toLocaleDateString(undefined, {
weekday: 'long',
@@ -208,6 +237,7 @@ export class GeminiClient {
Today's date is ${today}.
My operating system is: ${platform}
${workingDirPreamble}
+ Here is the folder structure of the current working directories:\n
${folderStructure}
`.trim();