Skip to content

Commit 19eea76

Browse files
committed
refactor: Refactor devlog management by replacing DevlogManager with MCPDevlogAdapter
- Removed DevlogManager implementation and replaced it with MCPDevlogAdapter for better integration with the Model Context Protocol. - Updated index.ts to utilize MCPDevlogAdapter for handling devlog-related requests. - Created mcp-adapter.ts to wrap DevlogManager and convert responses to MCP format. - Adjusted test.ts to reflect changes in the API and ensure compatibility with the new adapter. - Updated tsconfig.json and pnpm-lock.yaml to include references to the new core package. - Removed devlog-manager.ts as it is no longer needed.
1 parent 64fec74 commit 19eea76

19 files changed

+1501
-644
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ pnpm build
3838
# Build only the MCP server
3939
pnpm build:mcp
4040

41+
# Build only the core package
42+
pnpm build:core
43+
4144
# Build only the types package
4245
pnpm build:types
4346

@@ -63,6 +66,10 @@ You can also work directly with individual packages using pnpm filters:
6366
pnpm --filter @devlog/mcp-server build
6467
pnpm --filter @devlog/mcp-server dev
6568

69+
# Work on the core package
70+
pnpm --filter @devlog/core build
71+
pnpm --filter @devlog/core dev
72+
6673
# Work on the types package
6774
pnpm --filter @devlog/types build
6875
pnpm --filter @devlog/types dev
@@ -92,10 +99,11 @@ When adding a new package to the monorepo:
9299

93100
### Package Structure
94101

95-
- `@devlog/mcp-server`: The main MCP server implementation
102+
- `@devlog/types`: Shared TypeScript types and interfaces
103+
- `@devlog/core`: Core devlog management functionality (file system operations, CRUD, etc.)
104+
- `@devlog/mcp-server`: MCP server implementation that wraps the core functionality
96105
- Future packages might include:
97106
- `@devlog/cli`: Command-line interface for devlog management
98-
- `@devlog/types`: Shared TypeScript types
99107
- `@devlog/web`: Web interface for browsing devlogs
100108
- `@devlog/utils`: Shared utilities
101109

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ A monorepo containing development logging tools and utilities, including a Model
44

55
## Packages
66

7+
### `@devlog/types`
8+
Shared TypeScript types and interfaces used across all packages.
9+
10+
### `@devlog/core`
11+
Core devlog management functionality including file system operations, CRUD operations, filtering, and search. This package provides the foundation that other packages build upon.
12+
713
### `@devlog/mcp-server`
8-
The main MCP server for development logging functionality.
14+
MCP (Model Context Protocol) server that wraps the core functionality for AI assistant integration.
915

1016
## Features
1117

@@ -42,10 +48,53 @@ pnpm dev
4248
pnpm build
4349

4450
# Build specific packages
45-
pnpm build:mcp
4651
pnpm build:types
52+
pnpm build:core
53+
pnpm build:mcp
4754
```
4855

56+
### Using the Core Package
57+
58+
The `@devlog/core` package can be used directly in your own applications:
59+
60+
```typescript
61+
import { DevlogManager } from '@devlog/core';
62+
63+
// Initialize the manager
64+
const devlog = new DevlogManager({
65+
workspaceRoot: '/path/to/your/project',
66+
// devlogDir: '/custom/path/.devlog' // optional custom directory
67+
});
68+
69+
// Create a new devlog entry
70+
const entry = await devlog.createDevlog({
71+
title: 'Implement user authentication',
72+
type: 'feature',
73+
description: 'Add JWT-based authentication system',
74+
priority: 'high',
75+
businessContext: 'Users need secure login to access protected features',
76+
technicalContext: 'Using JWT tokens with refresh mechanism'
77+
});
78+
79+
// Update the devlog
80+
await devlog.updateDevlog({
81+
id: entry.id,
82+
status: 'in-progress',
83+
progress: 'Completed user registration endpoint'
84+
});
85+
86+
// List all devlogs
87+
const allDevlogs = await devlog.listDevlogs();
88+
89+
// Search devlogs
90+
const authDevlogs = await devlog.searchDevlogs('authentication');
91+
92+
// Get active context for AI assistants
93+
const activeContext = await devlog.getActiveContext(5);
94+
```
95+
96+
This makes it easy to build additional tools like CLI interfaces, web dashboards, or integrations with other development tools.
97+
4998
### Available Tools
5099

51100
#### `create_devlog`

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"clean": "pnpm -r clean",
1616
"install-all": "pnpm install",
1717
"build:mcp": "pnpm --filter @devlog/mcp-server build",
18-
"build:types": "pnpm --filter @devlog/types build"
18+
"build:types": "pnpm --filter @devlog/types build",
19+
"build:core": "pnpm --filter @devlog/core build"
1920
},
2021
"keywords": [
2122
"monorepo",

packages/core/README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# @devlog/core
2+
3+
Core functionality for the devlog system. This package provides the main `DevlogManager` class that handles creation, updating, querying, and management of development logs.
4+
5+
## Features
6+
7+
- **CRUD Operations**: Create, read, update, and delete devlog entries
8+
- **File System Storage**: JSON-based storage in `.devlog` directory
9+
- **Rich Context**: Support for business context, technical context, and AI-enhanced metadata
10+
- **Filtering & Search**: Query devlogs by status, type, priority, tags, and text search
11+
- **Notes & Progress Tracking**: Add timestamped notes to track progress
12+
- **AI Context Management**: Special handling for AI assistant context and insights
13+
- **Decision Tracking**: Record important decisions with rationale
14+
- **Statistics**: Get overview statistics of your devlog entries
15+
16+
## Installation
17+
18+
```bash
19+
pnpm add @devlog/core
20+
```
21+
22+
## Usage
23+
24+
```typescript
25+
import { DevlogManager } from '@devlog/core';
26+
27+
// Initialize the manager
28+
const devlog = new DevlogManager({
29+
workspaceRoot: '/path/to/your/project',
30+
// devlogDir: '/custom/path/.devlog' // optional custom directory
31+
});
32+
33+
// Create a new devlog entry
34+
const entry = await devlog.createDevlog({
35+
title: 'Implement user authentication',
36+
type: 'feature',
37+
description: 'Add JWT-based authentication system',
38+
priority: 'high',
39+
businessContext: 'Users need secure login to access protected features',
40+
technicalContext: 'Using JWT tokens with refresh mechanism',
41+
acceptanceCriteria: [
42+
'Users can register with email/password',
43+
'Users can login and receive JWT token',
44+
'Protected routes require valid token'
45+
]
46+
});
47+
48+
// Update the devlog
49+
await devlog.updateDevlog({
50+
id: entry.id,
51+
status: 'in-progress',
52+
progress: 'Completed user registration endpoint'
53+
});
54+
55+
// Add a note
56+
await devlog.addNote(entry.id, {
57+
category: 'progress',
58+
content: 'Fixed validation issues with email format'
59+
});
60+
61+
// List all devlogs
62+
const allDevlogs = await devlog.listDevlogs();
63+
64+
// Filter devlogs
65+
const inProgressTasks = await devlog.listDevlogs({
66+
status: ['in-progress'],
67+
type: ['feature', 'bugfix']
68+
});
69+
70+
// Search devlogs
71+
const authDevlogs = await devlog.searchDevlogs('authentication');
72+
73+
// Get active context for AI assistants
74+
const activeContext = await devlog.getActiveContext(5);
75+
76+
// Complete a devlog
77+
await devlog.completeDevlog(entry.id, 'Authentication system implemented and tested');
78+
```
79+
80+
## API Reference
81+
82+
### DevlogManager
83+
84+
#### Constructor
85+
86+
```typescript
87+
new DevlogManager(options?: DevlogManagerOptions)
88+
```
89+
90+
Options:
91+
- `workspaceRoot?: string` - Root directory of your project (defaults to `process.cwd()`)
92+
- `devlogDir?: string` - Custom directory for devlog storage (defaults to `{workspaceRoot}/.devlog`)
93+
94+
#### Methods
95+
96+
- `createDevlog(request: CreateDevlogRequest): Promise<DevlogEntry>`
97+
- `updateDevlog(request: UpdateDevlogRequest): Promise<DevlogEntry>`
98+
- `getDevlog(id: string): Promise<DevlogEntry | null>`
99+
- `listDevlogs(filters?: DevlogFilter): Promise<DevlogEntry[]>`
100+
- `searchDevlogs(query: string): Promise<DevlogEntry[]>`
101+
- `addNote(id: string, note: Omit<DevlogNote, "id" | "timestamp">): Promise<DevlogEntry>`
102+
- `completeDevlog(id: string, summary?: string): Promise<DevlogEntry>`
103+
- `deleteDevlog(id: string): Promise<void>`
104+
- `getActiveContext(limit?: number): Promise<DevlogEntry[]>`
105+
- `updateAIContext(args: AIContextUpdate): Promise<DevlogEntry>`
106+
- `addDecision(args: DecisionArgs): Promise<DevlogEntry>`
107+
- `getStats(): Promise<DevlogStats>`
108+
109+
## Storage Format
110+
111+
Devlogs are stored as JSON files in the `.devlog` directory with the following structure:
112+
113+
```
114+
.devlog/
115+
├── index.json # Maps devlog IDs to filenames
116+
├── feature-auth-123.json
117+
├── bugfix-validation-456.json
118+
└── ...
119+
```
120+
121+
Each devlog file contains a complete `DevlogEntry` object with all metadata, notes, and context information.
122+
123+
## Integration
124+
125+
This core package is designed to be used by:
126+
127+
- `@devlog/mcp-server` - MCP server for AI assistants
128+
- `@devlog/cli` - Command-line interface
129+
- `@devlog/web` - Web interface for browsing devlogs
130+
- Custom applications and scripts
131+
132+
## License
133+
134+
MIT

packages/core/package.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "@devlog/core",
3+
"version": "1.0.0",
4+
"description": "Core devlog management functionality",
5+
"main": "build/index.js",
6+
"types": "build/index.d.ts",
7+
"type": "module",
8+
"files": [
9+
"build/**/*",
10+
"README.md",
11+
"LICENSE"
12+
],
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/your-username/devlog-monorepo.git",
16+
"directory": "packages/core"
17+
},
18+
"homepage": "https://github.com/your-username/devlog-monorepo#readme",
19+
"bugs": {
20+
"url": "https://github.com/your-username/devlog-monorepo/issues"
21+
},
22+
"scripts": {
23+
"build": "tsc",
24+
"dev": "tsc --watch",
25+
"test": "vitest run",
26+
"test:watch": "vitest",
27+
"test:ui": "vitest --ui",
28+
"prepare": "pnpm build",
29+
"clean": "rm -rf build",
30+
"prepublishOnly": "pnpm build"
31+
},
32+
"keywords": [
33+
"devlog",
34+
"development-notes",
35+
"core",
36+
"library"
37+
],
38+
"author": "",
39+
"license": "MIT",
40+
"dependencies": {
41+
"@devlog/types": "workspace:*"
42+
},
43+
"devDependencies": {
44+
"@types/node": "^20.0.0",
45+
"@vitest/ui": "^2.1.9",
46+
"typescript": "^5.0.0",
47+
"vitest": "^2.1.9"
48+
},
49+
"engines": {
50+
"node": ">=18"
51+
}
52+
}

0 commit comments

Comments
 (0)