Skip to content

Commit 7468e5f

Browse files
committed
refactor: Update references from 'codehist' to 'AI chat' across the codebase and enhance type safety in chat import tools
1 parent ba09c56 commit 7468e5f

File tree

6 files changed

+78
-40
lines changed

6 files changed

+78
-40
lines changed

.devlog/entries/278-fix-chat-system-build-errors-and-integration-issue.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"title": "Fix: Chat System Build Errors and Integration Issues",
55
"type": "bugfix",
66
"description": "Multiple compilation errors and integration issues in the chat system implementation affecting core package build, TypeORM entity definitions, API endpoints, and MCP tool integration. Build failures are blocking development and testing of the chat feature.",
7-
"status": "new",
7+
"status": "cancelled",
88
"priority": "high",
99
"createdAt": "2025-07-24T13:52:08.420Z",
10-
"updatedAt": "2025-07-24T13:52:08.420Z",
10+
"updatedAt": "2025-07-24T14:26:52.365Z",
1111
"notes": [],
1212
"files": [],
1313
"relatedDevlogs": [],
@@ -36,5 +36,6 @@
3636
"suggestedNextSteps": [],
3737
"lastAIUpdate": "2025-07-24T13:52:08.420Z",
3838
"contextVersion": 1
39-
}
39+
},
40+
"closedAt": "2025-07-24T14:26:52.365Z"
4041
}

.devlog/entries/279-remove-legacy-codehist-references-from-codebase.json

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"title": "Remove legacy 'codehist' references from codebase",
55
"type": "refactor",
66
"description": "Clean up remaining references to \"codehist\" throughout the codebase, replacing them with more appropriate terms like \"GitHub Copilot\", \"VS Code\", or generic chat import terminology. The package was renamed from @devlog/codehist → @devlog/ai-chat → @devlog/ai, but many comments, descriptions, method names, and configurations still reference the old \"codehist\" name which is confusing and outdated.",
7-
"status": "in-progress",
7+
"status": "done",
88
"priority": "medium",
99
"createdAt": "2025-07-24T13:59:47.120Z",
10-
"updatedAt": "2025-07-24T14:22:20.666Z",
10+
"updatedAt": "2025-07-24T14:26:09.069Z",
1111
"notes": [
1212
{
1313
"id": "0f7318d0-40dc-4111-bca5-5a5949cc6e46",
@@ -66,6 +66,24 @@
6666
"packages/ai/src/services/chat-hub-service.ts",
6767
"packages/web/app/api/workspaces/[id]/chat/import/route.ts"
6868
]
69+
},
70+
{
71+
"id": "5a7ba6ae-70a2-447e-9bd9-b1e69dcf12e7",
72+
"timestamp": "2025-07-24T14:25:57.287Z",
73+
"category": "progress",
74+
"content": "🎯 **Final Cleanup Complete**:\n\n✅ **MCP Tools Updated**:\n- Updated source enum to use new ChatSource types: 'github-copilot', 'cursor', 'claude-code', 'windsurf', 'manual'\n- Updated descriptions to remove 'codehist' references\n- Default source changed to 'github-copilot'\n\n✅ **Comments Cleaned**:\n- Updated model comments: \"CodeHist\"\"AI Chat processing\"\n- Updated exporter comments: \"CodeHist chat data\"\"AI chat data\"\n- All legacy terminology removed from active codebase\n\n✅ **Build Verification**:\n- ✅ @devlog/ai builds successfully\n- ✅ @devlog/web builds successfully \n- ✅ @devlog/mcp builds successfully\n- ✅ All packages compile without errors\n\n**Status**: All legacy 'codehist' references removed. ChatHub architecture complete!",
75+
"files": [
76+
"packages/mcp/src/tools/chat-tools.ts",
77+
"packages/ai/src/models/index.ts",
78+
"packages/ai/src/exporters/markdown.ts",
79+
"packages/ai/src/exporters/json.ts"
80+
]
81+
},
82+
{
83+
"id": "69ad8872-d30e-4319-8782-ea2a7084b287",
84+
"timestamp": "2025-07-24T14:26:09.068Z",
85+
"category": "progress",
86+
"content": "Completed: Successfully completed the removal of legacy 'codehist' references and transformed the architecture to use ChatHub as the central data receiver service. \n\n**Key Accomplishments**:\n- **Architectural Transformation**: Changed from local file import to client-server data streaming\n- **Service Redesign**: Created ChatHubService with data ingestion methods (ingestChatSessions, ingestChatMessages, processBulkChatData)\n- **Type Safety**: Introduced ChatSource type with proper AI assistant names\n- **API Modernization**: Updated endpoints to receive structured chat data from clients\n- **Complete Cleanup**: Removed all legacy 'codehist' references from active codebase\n- **Build Verification**: All packages compile successfully\n\n**Impact**: \n- Much cleaner client-server separation\n- Ready for @devlog/cli integration (devlog #280)\n- Scalable architecture for multiple AI assistant integrations\n- Eliminated complex cross-platform file system logic from server"
6987
}
7088
],
7189
"files": [],
@@ -105,5 +123,6 @@
105123
],
106124
"lastAIUpdate": "2025-07-24T14:04:58.728Z",
107125
"contextVersion": 2
108-
}
126+
},
127+
"closedAt": "2025-07-24T14:26:09.069Z"
109128
}

packages/ai/src/exporters/json.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Simple JSON exporter for CodeHist chat data
3-
*
2+
* Simple JSON exporter for AI chat data
3+
*
44
* TypeScript implementation without complex configuration.
55
*/
66

@@ -15,13 +15,17 @@ export interface JSONExportOptions {
1515
export class JSONExporter {
1616
private defaultOptions: JSONExportOptions = {
1717
indent: 2,
18-
ensureAscii: false
18+
ensureAscii: false,
1919
};
2020

2121
/**
2222
* Export arbitrary data to JSON file
2323
*/
24-
async exportData(data: Record<string, any>, outputPath: string, options?: JSONExportOptions): Promise<void> {
24+
async exportData(
25+
data: Record<string, any>,
26+
outputPath: string,
27+
options?: JSONExportOptions,
28+
): Promise<void> {
2529
const exportOptions = { ...this.defaultOptions, ...options };
2630

2731
// Ensure output directory exists
@@ -37,7 +41,11 @@ export class JSONExporter {
3741
/**
3842
* Export chat data specifically
3943
*/
40-
async exportChatData(data: Record<string, any>, outputPath: string, options?: JSONExportOptions): Promise<void> {
44+
async exportChatData(
45+
data: Record<string, any>,
46+
outputPath: string,
47+
options?: JSONExportOptions,
48+
): Promise<void> {
4149
return this.exportData(data, outputPath, options);
4250
}
4351

packages/ai/src/exporters/markdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Simple Markdown exporter for CodeHist chat data
2+
* Simple Markdown exporter for AI chat data
33
*
44
* TypeScript implementation without complex configuration.
55
*/

packages/ai/src/models/index.ts

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
2-
* Data models for CodeHist
3-
*
4-
* TypeScript interfaces and classes for representing chat histories
2+
* Data models for AI Chat processing
3+
*
4+
* TypeScript interfaces and classes for representing chat histories
55
* focused on core chat functionality.
66
*/
77

@@ -55,7 +55,7 @@ export const MessageSchema = z.object({
5555
role: z.enum(['user', 'assistant']),
5656
content: z.string(),
5757
timestamp: z.string().datetime(),
58-
metadata: z.record(z.unknown()).default({})
58+
metadata: z.record(z.unknown()).default({}),
5959
});
6060

6161
export const ChatSessionSchema = z.object({
@@ -64,15 +64,15 @@ export const ChatSessionSchema = z.object({
6464
messages: z.array(MessageSchema).default([]),
6565
workspace: z.string().optional(),
6666
session_id: z.string().optional(),
67-
metadata: z.record(z.unknown()).default({})
67+
metadata: z.record(z.unknown()).default({}),
6868
});
6969

7070
export const WorkspaceDataSchema = z.object({
7171
agent: z.string(),
7272
version: z.string().optional(),
7373
workspace_path: z.string().optional(),
7474
chat_sessions: z.array(ChatSessionSchema).default([]),
75-
metadata: z.record(z.unknown()).default({})
75+
metadata: z.record(z.unknown()).default({}),
7676
});
7777

7878
// TypeScript interfaces
@@ -133,12 +133,15 @@ export interface ChatStatistics {
133133
total_messages: number;
134134
message_types: Record<string, number>;
135135
session_types: Record<string, number>;
136-
workspace_activity: Record<string, {
137-
sessions: number;
138-
messages: number;
139-
first_seen: string;
140-
last_seen: string;
141-
}>;
136+
workspace_activity: Record<
137+
string,
138+
{
139+
sessions: number;
140+
messages: number;
141+
first_seen: string;
142+
last_seen: string;
143+
}
144+
>;
142145
date_range: {
143146
earliest: string | null;
144147
latest: string | null;
@@ -168,7 +171,7 @@ export class MessageData implements Message {
168171
role: this.role,
169172
content: this.content,
170173
timestamp: this.timestamp.toISOString(),
171-
metadata: this.metadata
174+
metadata: this.metadata,
172175
};
173176
}
174177

@@ -179,7 +182,7 @@ export class MessageData implements Message {
179182
role: validated.role,
180183
content: validated.content,
181184
timestamp: new Date(validated.timestamp),
182-
metadata: validated.metadata as MessageMetadata
185+
metadata: validated.metadata as MessageMetadata,
183186
});
184187
}
185188
}
@@ -205,12 +208,12 @@ export class ChatSessionData implements ChatSession {
205208
return {
206209
agent: this.agent,
207210
timestamp: this.timestamp.toISOString(),
208-
messages: this.messages.map(msg =>
209-
msg instanceof MessageData ? msg.toDict() : new MessageData(msg).toDict()
211+
messages: this.messages.map((msg) =>
212+
msg instanceof MessageData ? msg.toDict() : new MessageData(msg).toDict(),
210213
),
211214
workspace: this.workspace,
212215
session_id: this.session_id,
213-
metadata: this.metadata
216+
metadata: this.metadata,
214217
};
215218
}
216219

@@ -219,10 +222,12 @@ export class ChatSessionData implements ChatSession {
219222
return new ChatSessionData({
220223
agent: validated.agent,
221224
timestamp: new Date(validated.timestamp),
222-
messages: validated.messages.map((msgData: unknown) => MessageData.fromDict(msgData as Record<string, unknown>)),
225+
messages: validated.messages.map((msgData: unknown) =>
226+
MessageData.fromDict(msgData as Record<string, unknown>),
227+
),
223228
workspace: validated.workspace,
224229
session_id: validated.session_id,
225-
metadata: validated.metadata as ChatSessionMetadata
230+
metadata: validated.metadata as ChatSessionMetadata,
226231
});
227232
}
228233
}
@@ -247,10 +252,12 @@ export class WorkspaceDataContainer implements WorkspaceData {
247252
agent: this.agent,
248253
version: this.version,
249254
workspace_path: this.workspace_path,
250-
chat_sessions: this.chat_sessions.map(session =>
251-
session instanceof ChatSessionData ? session.toDict() : new ChatSessionData(session).toDict()
255+
chat_sessions: this.chat_sessions.map((session) =>
256+
session instanceof ChatSessionData
257+
? session.toDict()
258+
: new ChatSessionData(session).toDict(),
252259
),
253-
metadata: this.metadata
260+
metadata: this.metadata,
254261
};
255262
}
256263

@@ -260,8 +267,10 @@ export class WorkspaceDataContainer implements WorkspaceData {
260267
agent: validated.agent,
261268
version: validated.version,
262269
workspace_path: validated.workspace_path,
263-
chat_sessions: validated.chat_sessions.map((sessionData: unknown) => ChatSessionData.fromDict(sessionData as Record<string, unknown>)),
264-
metadata: validated.metadata as WorkspaceMetadata
270+
chat_sessions: validated.chat_sessions.map((sessionData: unknown) =>
271+
ChatSessionData.fromDict(sessionData as Record<string, unknown>),
272+
),
273+
metadata: validated.metadata as WorkspaceMetadata,
265274
});
266275
}
267276
}

packages/mcp/src/tools/chat-tools.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function getApiClient(): DevlogApiClient {
2525

2626
// Export MCP Tool argument interfaces for better type safety
2727
export interface ImportChatHistoryArgs {
28-
source?: 'codehist' | 'vs-code';
28+
source?: 'github-copilot' | 'cursor' | 'claude-code' | 'windsurf' | 'manual';
2929
autoLink?: boolean;
3030
autoLinkThreshold?: number;
3131
includeArchived?: boolean;
@@ -116,14 +116,15 @@ export interface GetChatWorkspacesArgs {
116116

117117
export const importChatHistoryTool: Tool = {
118118
name: 'import_chat_history',
119-
description: 'Import chat history from GitHub Copilot (via codehist) into devlog storage',
119+
description:
120+
'Import chat history from GitHub Copilot and other AI assistants into devlog storage',
120121
inputSchema: {
121122
type: 'object',
122123
properties: {
123124
source: {
124125
type: 'string',
125-
enum: ['codehist', 'vs-code'],
126-
default: 'codehist',
126+
enum: ['github-copilot', 'cursor', 'claude-code', 'windsurf', 'manual'],
127+
default: 'github-copilot',
127128
description: 'Source to import chat history from',
128129
},
129130
autoLink: {

0 commit comments

Comments
 (0)