Skip to content

Commit 02eccef

Browse files
author
Marvin Zhang
committed
Refactor devlog tools and remove deprecated chat tools
- Removed deprecated `update_ai_context` tool from `ai-context-tools.ts`. - Deleted `chat-tools.ts` file and its associated tools. - Introduced new `devlog-tools.ts` file containing CRUD operations for devlog entries. - Updated `index.ts` to include `devlogTools` and removed references to `progressTools` and `chatTools`. - Removed `progress-tools.ts` as its functionality has been integrated into `devlog-tools.ts`. - Updated project tools to reflect changes in project last accessed date.
1 parent 658d1ad commit 02eccef

File tree

15 files changed

+542
-3248
lines changed

15 files changed

+542
-3248
lines changed

.github/copilot-instructions.md

Lines changed: 2 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Devlog Project - Copilot Instructions
22

3-
## 🚨 CRITICAL RULES (READ FIRST!)
3+
<!-- ## 🚨 CRITICAL RULES (READ FIRST!)
44
55
### ⚠️ MANDATORY FIRST STEP: Always Discover Before Creating
66
@@ -20,7 +20,7 @@
2020
2. **📖 REVIEW**: Analyze discovered entries to understand context and avoid overlaps
2121
3. **✅ CREATE ONLY IF NEEDED**: Create new devlog entry using MCP tools only if no overlapping work exists
2222
4. **📝 TRACK PROGRESS**: Update entries with notes and status changes via MCP functions
23-
5. **🔗 LINK WORK**: Reference devlog IDs in commits and documentation
23+
5. **🔗 LINK WORK**: Reference devlog IDs in commits and documentation -->
2424

2525
## Development Philosophy (Brief)
2626

@@ -50,107 +50,6 @@ import { DevlogEntry } from '@/types'; // Ambiguous sel
5050
import { StorageProvider } from '../storage/providers'; // Missing .js extension
5151
```
5252

53-
## ⚠️ AUTOMATIC MIGRATION DETECTION
54-
55-
### 🚨 **Contextual Migration Prompts**
56-
**These prompts trigger automatically based on file patterns being edited:**
57-
58-
#### **When editing `packages/core/src/managers/**/*.ts`:**
59-
```
60-
⚠️ MIGRATION CHECK: Manager class changes often affect:
61-
- MCP adapter (packages/mcp/src/mcp-adapter.ts)
62-
- Web API routes (packages/web/app/api/*/route.ts)
63-
- Web contexts (packages/web/app/contexts/*.tsx)
64-
65-
Run: grep -r "ManagerClassName" packages/ --include="*.ts"
66-
```
67-
68-
#### **When editing `packages/core/src/types/**/*.ts`:**
69-
```
70-
⚠️ MIGRATION CHECK: Type changes often affect:
71-
- All packages importing these types
72-
- MCP tool parameter validation
73-
- Web component prop types
74-
75-
Run: grep -r "TypeName" packages/ --include="*.ts" --include="*.tsx"
76-
```
77-
78-
#### **When editing `packages/core/src/storage/**/*.ts`:**
79-
```
80-
⚠️ MIGRATION CHECK: Storage changes often affect:
81-
- MCP storage tools (packages/mcp/src/tools/*)
82-
- Web API endpoints (packages/web/app/api/*)
83-
- Configuration and initialization code
84-
85-
Run: grep -r "StorageInterface" packages/ --include="*.ts"
86-
```
87-
88-
#### **When making any @codervisor/devlog-core changes:**
89-
```
90-
⚠️ AUTO-CHECK: After core changes, verify:
91-
1. pnpm detect-migration # Automatic migration detection
92-
2. pnpm --filter @codervisor/devlog-mcp build
93-
3. pnpm --filter @codervisor/devlog-web build:test
94-
4. Check for new compilation errors in dependent packages
95-
```
96-
97-
#### **Before starting any development session:**
98-
```
99-
💡 PROACTIVE CHECK: Run automatic migration detection:
100-
pnpm detect-migration
101-
102-
This scans recent changes and identifies potential cross-package impacts
103-
that require migration attention.
104-
```
105-
106-
## 🔄 Architecture Migration Protocol
107-
108-
### ⚠️ CRITICAL: For Major Architecture Changes
109-
110-
**When modifying core classes, interfaces, or manager patterns:**
111-
112-
### **MANDATORY Migration Steps:**
113-
1. **🔍 IMPACT ANALYSIS FIRST**: Map all dependent packages and components
114-
- Search for usage across ALL packages (`grep -r "ClassName" packages/`)
115-
- Identify adapters, API routes, tests, and integration points
116-
- Document breaking changes and compatibility requirements
117-
118-
2. **📋 MIGRATION PLAN**: Create systematic update sequence
119-
- **Order**: Core → MCP → AI → Web (follow dependency chain)
120-
- **Validation**: Build and test each package after updates
121-
- **Integration**: Test cross-package functionality
122-
123-
3. **✅ VALIDATION STRATEGY**: Define success criteria and checkpoints
124-
- All packages build successfully
125-
- All tests pass
126-
- Integration workflows function correctly
127-
- No runtime errors in dependent packages
128-
129-
4. **🔙 ROLLBACK PLAN**: Document reversion procedures
130-
- Backup state before migration
131-
- Clear steps to restore previous version
132-
- Dependency version compatibility matrix
133-
134-
### **Cross-Package Dependency Map:**
135-
- **@codervisor/devlog-core changes** → ALWAYS update @codervisor/devlog-mcp, @codervisor/devlog-web APIs
136-
- **Manager class changes** → Update adapters, API routes, tests, web contexts
137-
- **Type/Interface changes** → Update ALL imports and usages across packages
138-
- **Storage provider changes** → Update web API endpoints and MCP tools
139-
140-
### **Migration Validation Checklist:**
141-
```markdown
142-
□ Impact analysis completed across all packages
143-
□ Migration plan documented with specific steps
144-
□ Core package updated and builds successfully
145-
□ MCP package updated and builds successfully
146-
□ Web package updated and builds successfully
147-
□ AI package updated and builds successfully (if affected)
148-
□ All cross-package tests pass
149-
□ Integration workflows validated
150-
□ Rollback procedure documented and tested
151-
□ Related devlog entries updated with migration status
152-
```
153-
15453
## Essential SOPs
15554

15655
### Documentation Synchronization Process

packages/core/src/types/requests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface CreateDevlogRequest {
2727
}
2828

2929
export interface UpdateDevlogRequest {
30-
id: DevlogId;
30+
id?: DevlogId;
3131
title?: string;
3232
description?: string;
3333
type?: DevlogType;

packages/mcp/src/adapters/adapter-factory.ts

Lines changed: 21 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
/**
2-
* Factory for creating MCP adapters based on configuration
3-
* Supports both direct core access and HTTP API client modes
2+
* Factory for creating MCP adapters
3+
* Uses HTTP API client for secure and isolated access to devlog operations
44
*/
55

6-
import { MCPDevlogAdapter } from './mcp-adapter.js';
76
import { MCPApiAdapter, type MCPApiAdapterConfig } from './mcp-api-adapter.js';
87
import {
98
loadMCPConfig,
@@ -12,10 +11,10 @@ import {
1211
type MCPServerConfig,
1312
} from '../config/mcp-config.js';
1413

15-
export type MCPAdapter = MCPDevlogAdapter | MCPApiAdapter;
14+
export type MCPAdapter = MCPApiAdapter;
1615

1716
/**
18-
* Create an MCP adapter based on configuration
17+
* Create an MCP adapter using HTTP API client
1918
*/
2019
export async function createMCPAdapter(config?: MCPServerConfig): Promise<MCPAdapter> {
2120
// Load configuration if not provided
@@ -27,33 +26,19 @@ export async function createMCPAdapter(config?: MCPServerConfig): Promise<MCPAda
2726
// Print configuration summary for debugging
2827
printConfigSummary(mcpConfig);
2928

30-
let adapter: MCPAdapter;
29+
// Create API-based adapter
30+
const apiConfig: MCPApiAdapterConfig = {
31+
apiClient: {
32+
baseUrl: mcpConfig.webApi.baseUrl,
33+
timeout: mcpConfig.webApi.timeout,
34+
retries: mcpConfig.webApi.retries,
35+
},
36+
defaultProjectId: mcpConfig.defaultProjectId,
37+
autoDiscoverWebService: mcpConfig.webApi.autoDiscover,
38+
};
3139

32-
if (mcpConfig.mode === 'api') {
33-
// Create API-based adapter
34-
if (!mcpConfig.webApi) {
35-
throw new Error('Web API configuration is required for API mode');
36-
}
37-
38-
const apiConfig: MCPApiAdapterConfig = {
39-
apiClient: {
40-
baseUrl: mcpConfig.webApi.baseUrl,
41-
timeout: mcpConfig.webApi.timeout,
42-
retries: mcpConfig.webApi.retries,
43-
},
44-
defaultWorkspaceId: mcpConfig.defaultWorkspaceId,
45-
autoDiscoverWebService: mcpConfig.webApi.autoDiscover,
46-
};
47-
48-
adapter = new MCPApiAdapter(apiConfig);
49-
console.log('Created MCP API Adapter (HTTP client mode)');
50-
} else {
51-
// Create direct core access adapter (existing implementation)
52-
const directConfig = mcpConfig.direct || {};
53-
54-
adapter = new MCPDevlogAdapter(mcpConfig.defaultWorkspaceId);
55-
console.log('Created MCP Direct Adapter (core access mode)');
56-
}
40+
const adapter = new MCPApiAdapter(apiConfig);
41+
console.log('Created MCP API Adapter (HTTP client mode)');
5742

5843
// Initialize the adapter
5944
await adapter.initialize();
@@ -66,7 +51,7 @@ export async function createMCPAdapter(config?: MCPServerConfig): Promise<MCPAda
6651
*/
6752
export async function checkWebApiAvailability(baseUrl: string): Promise<boolean> {
6853
try {
69-
const response = await fetch(`${baseUrl}/api/workspaces`, {
54+
const response = await fetch(`${baseUrl}/api/projects`, {
7055
method: 'GET',
7156
headers: { 'Content-Type': 'application/json' },
7257
signal: AbortSignal.timeout(5000), // 5 second timeout
@@ -106,39 +91,24 @@ export async function discoverWebApiUrl(): Promise<string | null> {
10691
export async function createMCPAdapterWithDiscovery(): Promise<MCPAdapter> {
10792
const config = loadMCPConfig();
10893

109-
// If in API mode and auto-discovery is enabled, try to find web API
110-
if (config.mode === 'api' && config.webApi?.autoDiscover) {
94+
// If auto-discovery is enabled, try to find web API
95+
if (config.webApi.autoDiscover) {
11196
const discoveredUrl = await discoverWebApiUrl();
11297

11398
if (discoveredUrl) {
11499
// Update config with discovered URL
115100
config.webApi.baseUrl = discoveredUrl;
116101
console.log(`Using discovered web API URL: ${discoveredUrl}`);
117102
} else {
118-
console.warn('Could not discover web API, falling back to direct mode');
119-
config.mode = 'direct';
103+
console.warn('Could not discover web API, using configured URL:', config.webApi.baseUrl);
120104
}
121105
}
122106

123107
return createMCPAdapter(config);
124108
}
125109

126110
/**
127-
* Get adapter interface type for tools
128-
*/
129-
export function getAdapterInterface(adapter: MCPAdapter): 'direct' | 'api' {
130-
return adapter instanceof MCPApiAdapter ? 'api' : 'direct';
131-
}
132-
133-
/**
134-
* Type guard for direct adapter
135-
*/
136-
export function isDirectAdapter(adapter: MCPAdapter): adapter is MCPDevlogAdapter {
137-
return adapter instanceof MCPDevlogAdapter;
138-
}
139-
140-
/**
141-
* Type guard for API adapter
111+
* Type guard for API adapter (always true now)
142112
*/
143113
export function isApiAdapter(adapter: MCPAdapter): adapter is MCPApiAdapter {
144114
return adapter instanceof MCPApiAdapter;

packages/mcp/src/adapters/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
* Adapter exports for MCP package
33
*/
44

5-
export { MCPDevlogAdapter } from './mcp-adapter.js';
65
export { MCPApiAdapter } from './mcp-api-adapter.js';
76
export {
87
createMCPAdapter,
98
createMCPAdapterWithDiscovery,
109
checkWebApiAvailability,
1110
discoverWebApiUrl,
12-
getAdapterInterface,
13-
isDirectAdapter,
1411
isApiAdapter,
1512
type MCPAdapter,
1613
} from './adapter-factory.js';

0 commit comments

Comments
 (0)