2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import * as fs from 'fs/promises';
7
>
import { joinPath } from '../../../base/common/resources.js';
8
>
import { URI } from '../../../base/common/uri.js';
9
>
10
>
/**
11
>
* Stable, deterministic per-session scratch directory for a workspace-less
12
>
* (workspace-less chat) session: `<userHome>/.copilot/chats/<sessionId>`. Shared by the
13
>
* Copilot and Claude agents so both resolve the same cwd for a session that was
14
>
* created with no `workingDirectory`.
15
>
*/
16
>
export function workspacelessScratchDir(userHome: URI, sessionId: string): URI {
17
return joinPath(userHome, '.copilot', 'chats', sessionId);
18
}
20
>
/** Ensures the workspace-less scratch dir exists (mkdir -p), returning it. */
21
export async function ensureWorkspacelessScratchDir(userHome: URI, sessionId: string): Promise<URI> {
22
const dir = workspacelessScratchDir(userHome, sessionId);