Skip to content

Commit adc04a5

Browse files
author
Marvin Zhang
committed
feat: Implement AI chat history models and parsers for GitHub Copilot
1 parent e7a9af5 commit adc04a5

File tree

9 files changed

+429
-218
lines changed

9 files changed

+429
-218
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Application and workspace hierarchy models for AI Chat processing
3+
*
4+
* Defines the three-level hierarchy:
5+
* Application (VS Code app) -> Workspace (project) -> Session (chat)
6+
*/
7+
8+
export interface ApplicationMetadata {
9+
discovered_workspaces_count?: number;
10+
parsing_errors?: string[];
11+
total_sessions_discovered?: number;
12+
discovery_timestamp?: string;
13+
[key: string]: unknown; // Allow additional properties
14+
}
15+
16+
/**
17+
* Application information (VS Code app type)
18+
* Top level of the hierarchy: Application -> Workspace -> Session
19+
*/
20+
export interface ApplicationInfo {
21+
/** Unique application identifier */
22+
id: string;
23+
/** Human-readable application name */
24+
name: string;
25+
/** Path to the application's data directory */
26+
path: string;
27+
/** Name of the AI agent */
28+
agent: string;
29+
/** Optional: number of workspaces in this application */
30+
workspaceCount?: number;
31+
/** Additional metadata */
32+
metadata?: ApplicationMetadata;
33+
}
34+
35+
/**
36+
* Lightweight workspace information (without sessions)
37+
* Used for workspace discovery and listing within an application
38+
*/
39+
export interface WorkspaceInfo {
40+
/** Unique workspace identifier (within the application) */
41+
id: string;
42+
/** Human-readable workspace name */
43+
name: string;
44+
/** Path to the workspace */
45+
path?: string;
46+
/** Parent application identifier */
47+
applicationId: string;
48+
/** Optional: number of sessions in this workspace */
49+
sessionCount?: number;
50+
/** Additional metadata */
51+
metadata?: ApplicationMetadata;
52+
}

packages/ai/src/models/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
// Re-export all models from their respective files
12-
export * from './chat-message.js';
13-
export * from './chat-session.js';
12+
export * from './application.js';
1413
export * from './workspace.js';
14+
export * from './chat-session.js';
15+
export * from './chat-message.js';

packages/ai/src/models/workspace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface WorkspaceMetadata {
1313
[key: string]: unknown; // Allow additional properties
1414
}
1515

16-
// TypeScript interface
16+
// TypeScript interface for full workspace with sessions
1717
export interface Workspace {
1818
/** Name of the AI agent */
1919
agent: string;

packages/ai/src/parsers/base.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Abstract base class for AI assistant chat history parsers
3+
*
4+
* Provides a common interface for parsing chat history from various AI coding assistants
5+
* like GitHub Copilot, Cursor, Claude Code, etc.
6+
*
7+
* Supports three-level hierarchy: Application -> Workspace -> Session
8+
*/
9+
10+
import type { ChatSession, ApplicationInfo, WorkspaceInfo } from '../models/index.js';
11+
import { Logger, ConsoleLogger } from './utils.js';
12+
13+
/**
14+
* Abstract base class for AI assistant parsers
15+
*/
16+
export abstract class BaseParser {
17+
protected logger: Logger;
18+
19+
protected constructor(logger?: Logger) {
20+
this.logger = logger || new ConsoleLogger();
21+
}
22+
23+
/**
24+
* Get all available applications (VS Code installations) for this AI assistant
25+
* Returns lightweight application info without workspaces or sessions
26+
*/
27+
abstract getApplications(): Promise<ApplicationInfo[]>;
28+
29+
/**
30+
* Get all workspaces from a specific application
31+
* Returns lightweight workspace info without sessions
32+
*/
33+
abstract getWorkspaces(applicationId: string): Promise<WorkspaceInfo[]>;
34+
35+
/**
36+
* Get all chat sessions from a specific workspace within an application
37+
*/
38+
abstract getChatSessions(applicationId: string, workspaceId: string): Promise<ChatSession[]>;
39+
40+
/**
41+
* Parse a single chat session by session ID
42+
*/
43+
protected abstract parseChatSession(applicationId: string, workspaceId: string, sessionId: string): Promise<ChatSession | null>;
44+
}

packages/ai/src/parsers/base/base-parser.ts

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)