Path: blob/main/extensions/copilot/src/extension/chatSessions/copilotcli/node/cliHelpers.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { homedir } from 'os';6import { join } from 'path';78const COPILOT_HOME_DIRECTORY = '.copilot';9const APP_DIRECTORY = join(COPILOT_HOME_DIRECTORY, 'ide');10const SESSION_STATE_DIRECTORY = join(COPILOT_HOME_DIRECTORY, 'session-state');1112export function getCopilotHome(): string {13const xdgHome = process.env.XDG_STATE_HOME;14return xdgHome ? join(xdgHome, COPILOT_HOME_DIRECTORY) : join(homedir(), COPILOT_HOME_DIRECTORY);15}1617export function getCopilotCliStateDir(): string {18const xdgHome = process.env.XDG_STATE_HOME;19return xdgHome ? join(xdgHome, APP_DIRECTORY) : join(homedir(), APP_DIRECTORY);20}2122export function getCopilotCLISessionStateDir(): string {23const xdgHome = process.env.XDG_STATE_HOME;24return xdgHome ? join(xdgHome, SESSION_STATE_DIRECTORY) : join(homedir(), SESSION_STATE_DIRECTORY);25}2627export function getCopilotCLISessionDir(sessionId: string): string {28return join(getCopilotCLISessionStateDir(), sessionId);29}3031export function getCopilotCLISessionEventsFile(sessionId: string) {32return join(getCopilotCLISessionDir(sessionId), 'events.jsonl');33}3435export function getCopilotCLIWorkspaceFile(sessionId: string) {36return join(getCopilotCLISessionDir(sessionId), 'workspace.yaml');37}3839/**40* Path of the shared bulk metadata cache file. This file is shared by all VS Code41* installs (Stable, Insiders, OSS, Exploration) and the Agents application.42*/43export function getCopilotBulkMetadataFile(): string {44return join(getCopilotHome(), 'vscode.session.metadata.cache.json');45}464748