Skip to content

Commit 1c0cef5

Browse files
author
Marvin Zhang
committed
feat: Implement chat import service and restructure AI package dependencies
1 parent d3f3fed commit 1c0cef5

File tree

9 files changed

+115
-4
lines changed

9 files changed

+115
-4
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"id": 261,
3+
"key": "architecture-quality-analysis-devlog-ai-and-devlog",
4+
"title": "Architecture Quality Analysis: @devlog/ai and @devlog/core Dependency Inversion",
5+
"type": "refactor",
6+
"description": "Analyze and fix architectural dependency issue where @devlog/core incorrectly references @devlog/ai package. The dependency direction should be inverted: @devlog/ai should use common utilities from @devlog/core, not the reverse. @devlog/ai should serve as the fundamental package for AI-related functionality including AI agents, orchestration, chat history management, and IDE utilities.",
7+
"status": "done",
8+
"priority": "high",
9+
"createdAt": "2025-07-24T06:10:40.194Z",
10+
"updatedAt": "2025-07-24T06:20:10.001Z",
11+
"notes": [
12+
{
13+
"id": "8d0fdc06-8933-4642-919f-409470817468",
14+
"timestamp": "2025-07-24T06:11:35.939Z",
15+
"category": "progress",
16+
"content": "ARCHITECTURAL ANALYSIS COMPLETE\n\n**Current Problem Identified:**\n- @devlog/core imports `CopilotParser` from @devlog/ai in `packages/core/src/services/chat-import-service.ts`\n- This creates an inverted dependency where the core package depends on the AI package\n- @devlog/ai currently has NO dependencies on @devlog/core, making this a one-way incorrect dependency\n\n**Impact Assessment:**\n🔴 CRITICAL - This violates fundamental architectural layering principles:\n- Core should contain shared utilities, not depend on specialized packages\n- AI should build upon core functionality, not be imported by core\n- Creates coupling that prevents proper separation of concerns\n- Makes the architecture brittle and harder to maintain\n\n**Root Cause:**\nThe ChatImportService in @devlog/core directly imports CopilotParser from @devlog/ai to handle chat history importing. This functionality should either:\n1. Be moved entirely to @devlog/ai package, OR\n2. Use dependency injection to invert the dependency"
17+
},
18+
{
19+
"id": "9d957625-16c7-4e39-8643-a49d9a3a7c19",
20+
"timestamp": "2025-07-24T06:11:59.318Z",
21+
"category": "solution",
22+
"content": "SOLUTION DESIGN: Dependency Inversion Architecture\n\n**Recommended Approach: Move ChatImportService to @devlog/ai Package**\n\nThe chat import functionality should be moved entirely to the @devlog/ai package since it's AI-specific functionality. This aligns with the established architectural patterns:\n\n**Phase 1: Move ChatImportService to @devlog/ai**\n1. Move `packages/core/src/services/chat-import-service.ts` → `packages/ai/src/services/chat-import-service.ts`\n2. Add dependency: `@devlog/ai` should import types and utilities from `@devlog/core`\n3. Remove dependency: `@devlog/core` removes dependency on `@devlog/ai`\n\n**Phase 2: Create Proper Abstraction Layer**\n1. Define IChatImportService interface in @devlog/core/types\n2. Export service interface for cross-package usage\n3. Implement concrete service in @devlog/ai package\n\n**Phase 3: Update Dependent Packages**\n1. Update @devlog/mcp to import from @devlog/ai instead of @devlog/core\n2. Update @devlog/web to use new service location\n3. Verify all builds pass\n\n**Benefits:**\n✅ Correct dependency direction: AI → Core (not Core → AI)\n✅ Proper separation of concerns\n✅ AI package becomes the dedicated hub for AI functionality\n✅ Aligns with instruction file requirements"
23+
},
24+
{
25+
"id": "a9c68fb4-b098-4ef4-9772-b418f6646393",
26+
"timestamp": "2025-07-24T06:12:46.845Z",
27+
"category": "progress",
28+
"content": "IMPLEMENTATION START: Phase 1 - Move ChatImportService to @devlog/ai\n\n**Migration Discovery Complete:**\n✅ Only @devlog/core/services/chat-import-service.ts needs to be moved\n✅ MCP chat tools are already marked as TODO/not implemented - clean migration path\n✅ No other packages currently use ChatImportService directly\n✅ Service is only exported from @devlog/core/services/index.ts\n\n**Phase 1 Implementation Plan:**\n1. First, update @devlog/ai package.json to add @devlog/core dependency\n2. Create services directory in @devlog/ai package\n3. Move chat-import-service.ts from core to ai package with proper imports\n4. Update @devlog/ai exports to include the service\n5. Remove service from @devlog/core exports and delete file\n6. Remove @devlog/ai dependency from @devlog/core package.json\n7. Test build succeeds for both packages\n\nStarting with Step 1: Update @devlog/ai dependencies"
29+
},
30+
{
31+
"id": "8099f2bf-7231-4351-9306-a7dc9ecb08da",
32+
"timestamp": "2025-07-24T06:20:01.958Z",
33+
"category": "solution",
34+
"content": "✅ PHASE 1 COMPLETE: Dependency Inversion Successfully Implemented!\n\n**What was accomplished:**\n1. ✅ Updated @devlog/ai package.json to add @devlog/core dependency\n2. ✅ Created services directory in @devlog/ai package\n3. ✅ Moved chat-import-service.ts from core to ai package with corrected imports\n4. ✅ Updated @devlog/ai exports to include the service\n5. ✅ Removed service from @devlog/core exports and deleted original file\n6. ✅ Removed @devlog/ai dependency from @devlog/core package.json\n7. ✅ All packages build successfully\n\n**Dependency Direction Now Correct:**\n- ❌ BEFORE: @devlog/core imported from @devlog/ai (incorrect)\n- ✅ AFTER: @devlog/ai imports from @devlog/core (correct architectural layering)\n\n**Build Verification:**\n- @devlog/core builds: ✅\n- @devlog/ai builds: ✅ \n- All packages build together: ✅\n- No circular dependencies: ✅\n\n**Impact Assessment:**\n- ChatImportService is now properly located in the AI package where it belongs\n- Core package no longer depends on specialized AI functionality\n- Architectural boundaries are now properly respected\n- Foundation established for @devlog/ai to become the AI functionality hub"
35+
}
36+
],
37+
"files": [],
38+
"relatedDevlogs": [],
39+
"context": {
40+
"businessContext": "This architectural fix is critical for maintaining clean dependency boundaries in the monorepo. The current incorrect dependency direction creates coupling issues and prevents proper separation of concerns. With Docker automation implemented in devlog #260, this is the right time to establish proper architectural foundations.",
41+
"technicalContext": "The issue involves reversing package dependencies to align with proper architectural layering. @devlog/core should contain shared utilities and fundamental types, while @devlog/ai should build upon core to provide specialized AI functionality. This follows standard dependency inversion principles.",
42+
"dependencies": [],
43+
"decisions": [],
44+
"acceptanceCriteria": [
45+
"@devlog/core no longer imports from @devlog/ai",
46+
"@devlog/ai imports utilities from @devlog/core",
47+
"All packages build successfully",
48+
"No circular dependencies introduced",
49+
"Package boundaries clearly defined",
50+
"AI-specific functionality consolidated in @devlog/ai"
51+
],
52+
"risks": []
53+
},
54+
"aiContext": {
55+
"currentSummary": "",
56+
"keyInsights": [],
57+
"openQuestions": [],
58+
"relatedPatterns": [],
59+
"suggestedNextSteps": [],
60+
"lastAIUpdate": "2025-07-24T06:10:40.194Z",
61+
"contextVersion": 1
62+
},
63+
"closedAt": "2025-07-24T06:20:10.001Z"
64+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"id": 262,
3+
"key": "docker-development-fix-build-folder-permission-iss",
4+
"title": "Docker Development: Fix Build Folder Permission Issues",
5+
"type": "task",
6+
"description": "The devlog-web-dev container in docker-compose.dev.yml creates build folders with root permissions by default, causing permission issues when trying to clean or rebuild packages on the host system. This affects development workflow when switching between containerized and host-based builds.",
7+
"status": "new",
8+
"priority": "medium",
9+
"createdAt": "2025-07-24T06:18:56.658Z",
10+
"updatedAt": "2025-07-24T06:18:56.658Z",
11+
"notes": [],
12+
"files": [],
13+
"relatedDevlogs": [],
14+
"context": {
15+
"businessContext": "This permission issue disrupts the development workflow and creates friction when developers need to clean build artifacts or switch between containerized and host builds. It's particularly problematic during package migrations and architectural changes.",
16+
"technicalContext": "The Docker container runs as root by default, so any files created by build processes (like TypeScript compilation) are owned by root:root. This prevents the host user from modifying or removing these files without sudo privileges.",
17+
"dependencies": [],
18+
"decisions": [],
19+
"acceptanceCriteria": [
20+
"Container build processes create files with correct user permissions",
21+
"Host user can clean build artifacts without sudo",
22+
"Build processes work seamlessly in both container and host environments",
23+
"No permission conflicts during development workflow"
24+
],
25+
"risks": []
26+
},
27+
"aiContext": {
28+
"currentSummary": "",
29+
"keyInsights": [],
30+
"openQuestions": [],
31+
"relatedPatterns": [],
32+
"suggestedNextSteps": [],
33+
"lastAIUpdate": "2025-07-24T06:18:56.658Z",
34+
"contextVersion": 1
35+
}
36+
}

packages/ai/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"author": "Devlog Contributors",
3737
"license": "MIT",
3838
"dependencies": {
39+
"@devlog/core": "workspace:*",
3940
"commander": "^12.0.0",
4041
"chalk": "^5.3.0",
4142
"cli-table3": "^0.6.5",

packages/ai/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export * from './parsers/index.js';
1313
// Export all exporters
1414
export * from './exporters/index.js';
1515

16+
// Export all services
17+
export * from './services/index.js';
18+
1619
// Export automation layer
1720
export * from './automation/index.js';
1821

packages/core/src/services/chat-import-service.ts renamed to packages/ai/src/services/chat-import-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* into the devlog storage system with proper workspace mapping and linking.
66
*/
77

8-
import { CopilotParser } from '@devlog/ai';
8+
import { CopilotParser } from '../parsers/index.js';
99
import type {
1010
AgentType,
1111
ChatDevlogLink,
@@ -17,7 +17,7 @@ import type {
1717
ChatStatus,
1818
DevlogEntry,
1919
StorageProvider,
20-
} from '../types/index.js';
20+
} from '@devlog/core';
2121

2222
export interface ChatImportService {
2323
/**

packages/ai/src/services/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/**
2+
* AI Services - Chat import and other AI-related services
3+
*/
4+
5+
export { DefaultChatImportService, type ChatImportService } from './chat-import-service.js';

packages/core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
},
4141
"license": "MIT",
4242
"dependencies": {
43-
"@devlog/ai": "workspace:*",
4443
"better-sqlite3": "^11.0.0",
4544
"cheerio": "1.1.2",
4645
"dotenv": "16.5.0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { IntegrationService } from './integration-service.js';
2-
export { DefaultChatImportService, type ChatImportService } from './chat-import-service.js';
2+
// Note: ChatImportService has been moved to @devlog/ai package for proper dependency direction

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)