@prmichaelsen/task-mcp 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/.env.example +19 -0
  2. package/AGENT.md +1165 -0
  3. package/CHANGELOG.md +72 -0
  4. package/agent/commands/acp.commit.md +511 -0
  5. package/agent/commands/acp.init.md +376 -0
  6. package/agent/commands/acp.package-install.md +347 -0
  7. package/agent/commands/acp.proceed.md +311 -0
  8. package/agent/commands/acp.report.md +392 -0
  9. package/agent/commands/acp.status.md +280 -0
  10. package/agent/commands/acp.sync.md +323 -0
  11. package/agent/commands/acp.update.md +301 -0
  12. package/agent/commands/acp.validate.md +385 -0
  13. package/agent/commands/acp.version-check-for-updates.md +275 -0
  14. package/agent/commands/acp.version-check.md +190 -0
  15. package/agent/commands/acp.version-update.md +288 -0
  16. package/agent/commands/command.template.md +273 -0
  17. package/agent/commands/git.commit.md +511 -0
  18. package/agent/commands/git.init.md +513 -0
  19. package/agent/design/.gitkeep +0 -0
  20. package/agent/design/acp-task-execution-requirements.md +555 -0
  21. package/agent/design/api-dto-design.md +394 -0
  22. package/agent/design/code-extraction-guide.md +827 -0
  23. package/agent/design/design.template.md +136 -0
  24. package/agent/design/requirements.template.md +387 -0
  25. package/agent/design/rest-api-integration.md +489 -0
  26. package/agent/design/sdk-export-requirements.md +549 -0
  27. package/agent/milestones/.gitkeep +0 -0
  28. package/agent/milestones/milestone-1-{title}.template.md +206 -0
  29. package/agent/milestones/milestone-2-task-infrastructure.md +232 -0
  30. package/agent/milestones/milestone-4-autonomous-execution.md +235 -0
  31. package/agent/patterns/.gitkeep +0 -0
  32. package/agent/patterns/bootstrap.md +1271 -0
  33. package/agent/patterns/bootstrap.template.md +1237 -0
  34. package/agent/patterns/pattern.template.md +364 -0
  35. package/agent/progress.template.yaml +158 -0
  36. package/agent/progress.yaml +375 -0
  37. package/agent/scripts/check-for-updates.sh +88 -0
  38. package/agent/scripts/install.sh +157 -0
  39. package/agent/scripts/uninstall.sh +75 -0
  40. package/agent/scripts/update.sh +139 -0
  41. package/agent/scripts/version.sh +35 -0
  42. package/agent/tasks/.gitkeep +0 -0
  43. package/agent/tasks/task-1-{title}.template.md +225 -0
  44. package/agent/tasks/task-86-task-data-model-schemas.md +143 -0
  45. package/agent/tasks/task-87-task-database-service.md +220 -0
  46. package/agent/tasks/task-88-firebase-client-wrapper.md +139 -0
  47. package/agent/tasks/task-88-task-execution-engine.md +277 -0
  48. package/agent/tasks/task-89-mcp-server-implementation.md +197 -0
  49. package/agent/tasks/task-90-build-configuration.md +146 -0
  50. package/agent/tasks/task-91-deployment-configuration.md +128 -0
  51. package/coverage/base.css +224 -0
  52. package/coverage/block-navigation.js +87 -0
  53. package/coverage/favicon.png +0 -0
  54. package/coverage/index.html +191 -0
  55. package/coverage/lcov-report/base.css +224 -0
  56. package/coverage/lcov-report/block-navigation.js +87 -0
  57. package/coverage/lcov-report/favicon.png +0 -0
  58. package/coverage/lcov-report/index.html +191 -0
  59. package/coverage/lcov-report/prettify.css +1 -0
  60. package/coverage/lcov-report/prettify.js +2 -0
  61. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  62. package/coverage/lcov-report/sorter.js +210 -0
  63. package/coverage/lcov-report/src/client.ts.html +1030 -0
  64. package/coverage/lcov-report/src/constant/collections.ts.html +469 -0
  65. package/coverage/lcov-report/src/constant/index.html +116 -0
  66. package/coverage/lcov-report/src/dto/index.html +116 -0
  67. package/coverage/lcov-report/src/dto/transformers.ts.html +568 -0
  68. package/coverage/lcov-report/src/index.html +146 -0
  69. package/coverage/lcov-report/src/schemas/index.html +116 -0
  70. package/coverage/lcov-report/src/schemas/task.ts.html +547 -0
  71. package/coverage/lcov-report/src/server-factory.ts.html +418 -0
  72. package/coverage/lcov-report/src/server.ts.html +289 -0
  73. package/coverage/lcov-report/src/services/index.html +116 -0
  74. package/coverage/lcov-report/src/services/task-database.service.ts.html +1495 -0
  75. package/coverage/lcov-report/src/tools/index.html +236 -0
  76. package/coverage/lcov-report/src/tools/index.ts.html +292 -0
  77. package/coverage/lcov-report/src/tools/task-add-message.ts.html +277 -0
  78. package/coverage/lcov-report/src/tools/task-complete-task-item.ts.html +343 -0
  79. package/coverage/lcov-report/src/tools/task-create-milestone.ts.html +286 -0
  80. package/coverage/lcov-report/src/tools/task-create-task-item.ts.html +358 -0
  81. package/coverage/lcov-report/src/tools/task-get-next-step.ts.html +460 -0
  82. package/coverage/lcov-report/src/tools/task-get-status.ts.html +316 -0
  83. package/coverage/lcov-report/src/tools/task-report-completion.ts.html +343 -0
  84. package/coverage/lcov-report/src/tools/task-update-progress.ts.html +232 -0
  85. package/coverage/lcov.info +974 -0
  86. package/coverage/prettify.css +1 -0
  87. package/coverage/prettify.js +2 -0
  88. package/coverage/sort-arrow-sprite.png +0 -0
  89. package/coverage/sorter.js +210 -0
  90. package/coverage/src/client.ts.html +1030 -0
  91. package/coverage/src/constant/collections.ts.html +469 -0
  92. package/coverage/src/constant/index.html +116 -0
  93. package/coverage/src/dto/index.html +116 -0
  94. package/coverage/src/dto/transformers.ts.html +568 -0
  95. package/coverage/src/index.html +146 -0
  96. package/coverage/src/schemas/index.html +116 -0
  97. package/coverage/src/schemas/task.ts.html +547 -0
  98. package/coverage/src/server-factory.ts.html +418 -0
  99. package/coverage/src/server.ts.html +289 -0
  100. package/coverage/src/services/index.html +116 -0
  101. package/coverage/src/services/task-database.service.ts.html +1495 -0
  102. package/coverage/src/tools/index.html +236 -0
  103. package/coverage/src/tools/index.ts.html +292 -0
  104. package/coverage/src/tools/task-add-message.ts.html +277 -0
  105. package/coverage/src/tools/task-complete-task-item.ts.html +343 -0
  106. package/coverage/src/tools/task-create-milestone.ts.html +286 -0
  107. package/coverage/src/tools/task-create-task-item.ts.html +358 -0
  108. package/coverage/src/tools/task-get-next-step.ts.html +460 -0
  109. package/coverage/src/tools/task-get-status.ts.html +316 -0
  110. package/coverage/src/tools/task-report-completion.ts.html +343 -0
  111. package/coverage/src/tools/task-update-progress.ts.html +232 -0
  112. package/firestore.rules +95 -0
  113. package/jest.config.js +31 -0
  114. package/package.json +67 -0
  115. package/src/client.spec.ts +199 -0
  116. package/src/client.ts +315 -0
  117. package/src/constant/collections.ts +128 -0
  118. package/src/dto/index.ts +47 -0
  119. package/src/dto/task-api.dto.ts +219 -0
  120. package/src/dto/transformers.spec.ts +462 -0
  121. package/src/dto/transformers.ts +161 -0
  122. package/src/schemas/task.ts +154 -0
  123. package/src/server-factory.spec.ts +70 -0
  124. package/src/server-factory.ts +111 -0
  125. package/src/server.ts +68 -0
  126. package/src/services/task-database.service.e2e.ts +116 -0
  127. package/src/services/task-database.service.spec.ts +479 -0
  128. package/src/services/task-database.service.ts +470 -0
  129. package/src/test-schemas.ts +161 -0
  130. package/src/tools/index.ts +69 -0
  131. package/src/tools/task-add-message.ts +64 -0
  132. package/src/tools/task-complete-task-item.ts +86 -0
  133. package/src/tools/task-create-milestone.ts +67 -0
  134. package/src/tools/task-create-task-item.ts +91 -0
  135. package/src/tools/task-get-next-step.spec.ts +136 -0
  136. package/src/tools/task-get-next-step.ts +125 -0
  137. package/src/tools/task-get-status.spec.ts +213 -0
  138. package/src/tools/task-get-status.ts +77 -0
  139. package/src/tools/task-report-completion.ts +86 -0
  140. package/src/tools/task-update-progress.ts +49 -0
  141. package/src/tools/tools.spec.ts +194 -0
  142. package/tsconfig.json +31 -0
@@ -0,0 +1,394 @@
1
+ # API DTO Design
2
+
3
+ **Concept**: Define Data Transfer Objects (DTOs) for REST API responses
4
+ **Created**: 2026-02-16
5
+ **Status**: Design Specification
6
+
7
+ ---
8
+
9
+ ## Overview
10
+
11
+ This document defines the API response DTOs for task-mcp REST API. These DTOs are based on the internal schemas but exclude internal fields and match the structure expected by agentbase.me.
12
+
13
+ ## Problem Statement
14
+
15
+ Our internal schemas ([`src/schemas/task.ts`](../../src/schemas/task.ts)) contain fields that should not be exposed via REST API:
16
+
17
+ - `execution.api_messages` - Internal Anthropic API conversation
18
+ - `execution.tool_results` - Internal MCP tool execution details
19
+ - Other internal implementation details
20
+
21
+ We need separate DTOs for API responses that:
22
+ 1. Exclude internal fields
23
+ 2. Match agentbase.me's expected structure
24
+ 3. Use updated field naming conventions
25
+ 4. Provide clear TypeScript types for API consumers
26
+
27
+ ## Solution
28
+
29
+ Create API response DTOs in `src/dto/task-api.dto.ts` that transform internal schemas into public API responses.
30
+
31
+ ### DTO Structure
32
+
33
+ ```typescript
34
+ // src/dto/task-api.dto.ts
35
+
36
+ /**
37
+ * API Response DTOs
38
+ *
39
+ * These DTOs define the structure of REST API responses.
40
+ * They exclude internal fields and match agentbase.me expectations.
41
+ */
42
+
43
+ // ============================================================================
44
+ // Status Enums
45
+ // ============================================================================
46
+
47
+ export type TaskStatus = 'not_started' | 'in_progress' | 'paused' | 'completed' | 'failed'
48
+ export type MilestoneStatus = 'not_started' | 'in_progress' | 'completed'
49
+ export type TaskItemStatus = 'not_started' | 'in_progress' | 'completed'
50
+ export type MessageRole = 'user' | 'assistant' | 'system'
51
+
52
+ // ============================================================================
53
+ // Nested DTOs
54
+ // ============================================================================
55
+
56
+ export interface TaskItemApiResponse {
57
+ id: string
58
+ name: string
59
+ description: string
60
+ status: TaskItemStatus
61
+ estimated_hours?: number
62
+ completed_at?: string // ISO 8601 timestamp
63
+ notes?: string
64
+ }
65
+
66
+ export interface MilestoneApiResponse {
67
+ id: string
68
+ name: string
69
+ description: string
70
+ status: MilestoneStatus
71
+ progress: number // 0-100
72
+ tasks_completed: number
73
+ tasks_total: number
74
+ started_at?: string // ISO 8601 timestamp
75
+ completed_at?: string // ISO 8601 timestamp
76
+ }
77
+
78
+ export interface TaskProgressApiResponse {
79
+ current_milestone: string
80
+ current_task: string
81
+ overall_percentage: number // 0-100
82
+ milestones: MilestoneApiResponse[]
83
+ tasks: Record<string, TaskItemApiResponse[]> // Keyed by milestone ID
84
+ }
85
+
86
+ export interface TaskConfigApiResponse {
87
+ system_prompt: string
88
+ auto_approve: boolean
89
+ max_iterations?: number
90
+ }
91
+
92
+ export interface TaskMetadataApiResponse {
93
+ conversation_id?: string
94
+ parent_task_id?: string
95
+ tags?: string[]
96
+ }
97
+
98
+ // ============================================================================
99
+ // Main Task DTO
100
+ // ============================================================================
101
+
102
+ export interface TaskApiResponse {
103
+ id: string
104
+ user_id: string
105
+ title: string
106
+ description: string
107
+ status: TaskStatus
108
+ created_at: string // ISO 8601 timestamp
109
+ updated_at: string // ISO 8601 timestamp
110
+ started_at?: string // ISO 8601 timestamp
111
+ completed_at?: string // ISO 8601 timestamp
112
+
113
+ progress: TaskProgressApiResponse
114
+ config: TaskConfigApiResponse
115
+ metadata?: TaskMetadataApiResponse
116
+
117
+ // Note: execution field is EXCLUDED from API responses
118
+ // Internal fields (api_messages, tool_results) are not exposed
119
+ }
120
+
121
+ // ============================================================================
122
+ // List Response DTO
123
+ // ============================================================================
124
+
125
+ export interface TaskListApiResponse {
126
+ tasks: TaskApiResponse[]
127
+ total: number
128
+ }
129
+
130
+ // ============================================================================
131
+ // Message DTO
132
+ // ============================================================================
133
+
134
+ export interface TaskMessageApiResponse {
135
+ id: string
136
+ task_id: string
137
+ role: MessageRole
138
+ content: string
139
+ timestamp: string // ISO 8601 timestamp
140
+ metadata?: any
141
+ }
142
+
143
+ export interface TaskMessageListApiResponse {
144
+ messages: TaskMessageApiResponse[]
145
+ total: number
146
+ }
147
+ ```
148
+
149
+ ## Transformation Logic
150
+
151
+ ### From Schema to DTO
152
+
153
+ ```typescript
154
+ // src/dto/transformers.ts
155
+
156
+ import { Task, TaskMessage } from '../schemas/task.js'
157
+ import { TaskApiResponse, TaskMessageApiResponse } from './task-api.dto.js'
158
+
159
+ /**
160
+ * Transform internal Task schema to API response DTO
161
+ * Excludes internal execution details
162
+ */
163
+ export function toTaskApiResponse(task: Task): TaskApiResponse {
164
+ return {
165
+ id: task.id,
166
+ user_id: task.user_id,
167
+ title: task.title,
168
+ description: task.description,
169
+ status: task.status,
170
+ created_at: task.created_at,
171
+ updated_at: task.updated_at,
172
+ started_at: task.started_at,
173
+ completed_at: task.completed_at,
174
+
175
+ progress: {
176
+ current_milestone: task.progress.current_milestone,
177
+ current_task: task.progress.current_task,
178
+ overall_percentage: task.progress.overall_percentage,
179
+ milestones: task.progress.milestones.map(m => ({
180
+ id: m.id,
181
+ name: m.name,
182
+ description: m.description,
183
+ status: m.status,
184
+ progress: m.progress,
185
+ tasks_completed: m.tasks_completed,
186
+ tasks_total: m.tasks_total,
187
+ started_at: m.started_at,
188
+ completed_at: m.completed_at
189
+ })),
190
+ tasks: task.progress.tasks
191
+ },
192
+
193
+ config: {
194
+ system_prompt: task.config.system_prompt,
195
+ auto_approve: task.config.auto_approve,
196
+ max_iterations: task.config.max_iterations
197
+ },
198
+
199
+ metadata: task.metadata
200
+
201
+ // execution field is intentionally excluded
202
+ }
203
+ }
204
+
205
+ /**
206
+ * Transform internal TaskMessage schema to API response DTO
207
+ */
208
+ export function toTaskMessageApiResponse(message: TaskMessage): TaskMessageApiResponse {
209
+ return {
210
+ id: message.id,
211
+ task_id: message.task_id,
212
+ role: message.role,
213
+ content: message.content,
214
+ timestamp: message.timestamp,
215
+ metadata: message.metadata
216
+ }
217
+ }
218
+ ```
219
+
220
+ ## Field Mapping
221
+
222
+ ### Included Fields
223
+
224
+ | Schema Field | DTO Field | Notes |
225
+ |--------------|-----------|-------|
226
+ | `id` | `id` | ✅ Included |
227
+ | `user_id` | `user_id` | ✅ Included |
228
+ | `title` | `title` | ✅ Included |
229
+ | `description` | `description` | ✅ Included |
230
+ | `status` | `status` | ✅ Included |
231
+ | `created_at` | `created_at` | ✅ Included |
232
+ | `updated_at` | `updated_at` | ✅ Included |
233
+ | `started_at` | `started_at` | ✅ Included |
234
+ | `completed_at` | `completed_at` | ✅ Included |
235
+ | `progress` | `progress` | ✅ Included (all subfields) |
236
+ | `config` | `config` | ✅ Included (all subfields) |
237
+ | `metadata` | `metadata` | ✅ Included (all subfields) |
238
+
239
+ ### Excluded Fields
240
+
241
+ | Schema Field | Reason for Exclusion |
242
+ |--------------|---------------------|
243
+ | `execution.api_messages` | Internal Anthropic API conversation |
244
+ | `execution.task_messages` | Stored in separate messages collection |
245
+ | `execution.tool_results` | Internal MCP tool execution details |
246
+ | `execution.error` | Internal error details (may expose sensitive info) |
247
+ | `execution.abort_reason` | Internal abort details |
248
+
249
+ ## Usage in REST API
250
+
251
+ ### Example: GET /api/tasks/:taskId
252
+
253
+ ```typescript
254
+ // REST API handler
255
+ import { TaskDatabaseService } from '../services/task-database.service.js'
256
+ import { toTaskApiResponse } from '../dto/transformers.js'
257
+
258
+ export async function getTask(req, res) {
259
+ const { taskId } = req.params
260
+ const userId = req.user.id // From auth middleware
261
+
262
+ const task = await TaskDatabaseService.getTask(userId, taskId)
263
+
264
+ if (!task) {
265
+ return res.status(404).json({ error: 'Task not found' })
266
+ }
267
+
268
+ // Transform to DTO before sending
269
+ const dto = toTaskApiResponse(task)
270
+
271
+ return res.json(dto)
272
+ }
273
+ ```
274
+
275
+ ### Example: GET /api/tasks
276
+
277
+ ```typescript
278
+ export async function listTasks(req, res) {
279
+ const userId = req.user.id
280
+ const { status, limit = 10, offset = 0 } = req.query
281
+
282
+ const tasks = await TaskDatabaseService.listTasks(userId, limit)
283
+
284
+ // Transform all tasks to DTOs
285
+ const dtos = tasks.map(toTaskApiResponse)
286
+
287
+ return res.json({
288
+ tasks: dtos,
289
+ total: dtos.length
290
+ })
291
+ }
292
+ ```
293
+
294
+ ## Compatibility with agentbase.me
295
+
296
+ The DTOs match the structure expected by agentbase.me's mock service:
297
+
298
+ **Reference**: [`/home/prmichaelsen/agentbase.me/src/services/task-mock.service.ts`](../../../agentbase.me/src/services/task-mock.service.ts)
299
+
300
+ ### Key Differences from Mock Service
301
+
302
+ 1. ✅ **Updated field names**: `completed_at` (not `completed_date`)
303
+ 2. ✅ **Simplified config**: No `model` or `timeout_minutes` fields
304
+ 3. ✅ **Excluded execution**: Internal fields not exposed
305
+
306
+ ### Migration Path for agentbase.me
307
+
308
+ When agentbase.me switches from mock service to real task-mcp client:
309
+
310
+ ```typescript
311
+ // Before (mock service)
312
+ import { TaskMockService } from './services/task-mock.service'
313
+ const tasks = await TaskMockService.getTasks()
314
+
315
+ // After (real client)
316
+ import { TaskMCPClient } from 'task-mcp/client'
317
+ const client = new TaskMCPClient({ apiUrl: 'https://task-mcp.example.com' })
318
+ const tasks = await client.getTasks()
319
+
320
+ // Response structure is identical!
321
+ ```
322
+
323
+ ## Benefits
324
+
325
+ 1. **Security**: Internal implementation details not exposed
326
+ 2. **Stability**: API contract separate from internal schema changes
327
+ 3. **Clarity**: Clear TypeScript types for API consumers
328
+ 4. **Compatibility**: Matches agentbase.me expectations
329
+ 5. **Flexibility**: Can evolve internal schemas without breaking API
330
+
331
+ ## Implementation Files
332
+
333
+ When implementing, create:
334
+
335
+ 1. `src/dto/task-api.dto.ts` - DTO type definitions
336
+ 2. `src/dto/transformers.ts` - Schema-to-DTO transformation functions
337
+ 3. `src/dto/index.ts` - Export all DTOs
338
+
339
+ Update `package.json` exports:
340
+ ```json
341
+ {
342
+ "exports": {
343
+ "./dto": {
344
+ "types": "./dist/dto/index.d.ts",
345
+ "import": "./dist/dto/index.js"
346
+ }
347
+ }
348
+ }
349
+ ```
350
+
351
+ ## Future Considerations
352
+
353
+ ### Input DTOs (for write operations)
354
+
355
+ When implementing write operations, create input DTOs:
356
+
357
+ ```typescript
358
+ export interface CreateTaskDto {
359
+ title: string
360
+ description: string
361
+ config?: Partial<TaskConfigApiResponse>
362
+ metadata?: TaskMetadataApiResponse
363
+ }
364
+
365
+ export interface UpdateTaskDto {
366
+ title?: string
367
+ description?: string
368
+ status?: TaskStatus
369
+ config?: Partial<TaskConfigApiResponse>
370
+ }
371
+ ```
372
+
373
+ ### Validation
374
+
375
+ Use Zod to validate DTOs:
376
+
377
+ ```typescript
378
+ import { z } from 'zod'
379
+
380
+ export const CreateTaskDtoSchema = z.object({
381
+ title: z.string().min(1).max(200),
382
+ description: z.string().min(1).max(2000),
383
+ config: z.object({
384
+ system_prompt: z.string().optional(),
385
+ auto_approve: z.boolean().optional(),
386
+ max_iterations: z.number().min(1).max(1000).optional()
387
+ }).optional()
388
+ })
389
+ ```
390
+
391
+ ---
392
+
393
+ **Status**: Design Complete
394
+ **Recommendation**: Implement DTOs when building REST API (Task 90)