@devpad/api 1.0.1

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.
package/dist/tools.js ADDED
@@ -0,0 +1,425 @@
1
+ import { z } from "zod";
2
+ import { upsert_project, upsert_todo, upsert_milestone, upsert_goal, save_config_request, save_tags_request } from "@devpad/schema";
3
+ // Filter schemas that aren't in @devpad/schema yet
4
+ export const project_filters = z.object({
5
+ private: z.boolean().optional().describe("Include private projects (default: true)"),
6
+ });
7
+ export const project_by_id_or_name = z
8
+ .object({
9
+ id: z.string().optional().describe("Project ID"),
10
+ name: z.string().optional().describe("Project name"),
11
+ })
12
+ .refine(data => data.id || data.name, {
13
+ message: "Either 'id' or 'name' must be provided",
14
+ });
15
+ export const task_filters = z.object({
16
+ project_id: z.string().optional().describe("Filter by project ID"),
17
+ tag_id: z.string().optional().describe("Filter by tag ID"),
18
+ });
19
+ export const task_by_id = z.object({
20
+ id: z.string().describe("Task ID"),
21
+ });
22
+ export const milestone_filters = z.object({
23
+ project_id: z.string().optional().describe("Filter by project ID"),
24
+ });
25
+ export const milestone_by_id = z.object({
26
+ id: z.string().describe("Milestone ID"),
27
+ });
28
+ export const goal_by_id = z.object({
29
+ id: z.string().describe("Goal ID"),
30
+ });
31
+ export const github_branches = z.object({
32
+ owner: z.string().describe("Repository owner"),
33
+ repo: z.string().describe("Repository name"),
34
+ });
35
+ // Tool definitions
36
+ export const tools = {
37
+ // Projects
38
+ devpad_projects_list: {
39
+ name: "devpad_projects_list",
40
+ description: "List all projects (or only public ones)",
41
+ inputSchema: project_filters,
42
+ execute: async (client, input) => {
43
+ const result = await client.projects.list(input);
44
+ if (result.error)
45
+ throw new Error(result.error.message);
46
+ return result.projects;
47
+ },
48
+ },
49
+ devpad_projects_get: {
50
+ name: "devpad_projects_get",
51
+ description: "Get project by ID or name",
52
+ inputSchema: project_by_id_or_name,
53
+ execute: async (client, input) => {
54
+ const result = input.id ? await client.projects.getById(input.id) : await client.projects.getByName(input.name);
55
+ if (result.error)
56
+ throw new Error(result.error.message);
57
+ return result.project;
58
+ },
59
+ },
60
+ devpad_projects_upsert: {
61
+ name: "devpad_projects_upsert",
62
+ description: "Create or update a project (set deleted=true to delete)",
63
+ inputSchema: upsert_project,
64
+ execute: async (client, input) => {
65
+ const result = await client.projects.upsert(input);
66
+ if (result.error)
67
+ throw new Error(result.error.message);
68
+ return result.project;
69
+ },
70
+ },
71
+ devpad_projects_config_save: {
72
+ name: "devpad_projects_config_save",
73
+ description: "Save project configuration",
74
+ inputSchema: save_config_request,
75
+ execute: async (client, input) => {
76
+ const result = await client.projects.config.save(input);
77
+ if (result.error)
78
+ throw new Error(result.error.message);
79
+ return { success: true };
80
+ },
81
+ },
82
+ // Tasks
83
+ devpad_tasks_list: {
84
+ name: "devpad_tasks_list",
85
+ description: "List tasks, optionally filtered by project or tag",
86
+ inputSchema: task_filters,
87
+ execute: async (client, input) => {
88
+ const result = await client.tasks.list(input);
89
+ if (result.error)
90
+ throw new Error(result.error.message);
91
+ return result.tasks;
92
+ },
93
+ },
94
+ devpad_tasks_get: {
95
+ name: "devpad_tasks_get",
96
+ description: "Get task by ID",
97
+ inputSchema: task_by_id,
98
+ execute: async (client, input) => {
99
+ const result = await client.tasks.find(input.id);
100
+ if (result.error)
101
+ throw new Error(result.error.message);
102
+ return result.task;
103
+ },
104
+ },
105
+ devpad_tasks_upsert: {
106
+ name: "devpad_tasks_upsert",
107
+ description: "Create or update a task (set deleted=true to delete)",
108
+ inputSchema: upsert_todo,
109
+ execute: async (client, input) => {
110
+ const result = await client.tasks.upsert(input);
111
+ if (result.error)
112
+ throw new Error(result.error.message);
113
+ return result.task;
114
+ },
115
+ },
116
+ devpad_tasks_save_tags: {
117
+ name: "devpad_tasks_save_tags",
118
+ description: "Save tags for tasks",
119
+ inputSchema: save_tags_request,
120
+ execute: async (client, input) => {
121
+ const result = await client.tasks.saveTags(input);
122
+ if (result.error)
123
+ throw new Error(result.error.message);
124
+ return { success: true };
125
+ },
126
+ },
127
+ // Milestones
128
+ devpad_milestones_list: {
129
+ name: "devpad_milestones_list",
130
+ description: "List milestones for authenticated user or by project",
131
+ inputSchema: milestone_filters,
132
+ execute: async (client, input) => {
133
+ const result = input.project_id ? await client.milestones.getByProject(input.project_id) : await client.milestones.list();
134
+ if (result.error)
135
+ throw new Error(result.error.message);
136
+ return result.milestones;
137
+ },
138
+ },
139
+ devpad_milestones_get: {
140
+ name: "devpad_milestones_get",
141
+ description: "Get milestone by ID",
142
+ inputSchema: milestone_by_id,
143
+ execute: async (client, input) => {
144
+ const result = await client.milestones.find(input.id);
145
+ if (result.error)
146
+ throw new Error(result.error.message);
147
+ return result.milestone;
148
+ },
149
+ },
150
+ devpad_milestones_upsert: {
151
+ name: "devpad_milestones_upsert",
152
+ description: "Create or update a milestone",
153
+ inputSchema: upsert_milestone,
154
+ execute: async (client, input) => {
155
+ const result = input.id
156
+ ? await client.milestones.update(input.id, {
157
+ name: input.name,
158
+ description: input.description,
159
+ target_time: input.target_time,
160
+ target_version: input.target_version,
161
+ })
162
+ : await client.milestones.create({
163
+ project_id: input.project_id,
164
+ name: input.name,
165
+ description: input.description,
166
+ target_time: input.target_time,
167
+ target_version: input.target_version,
168
+ });
169
+ if (result.error)
170
+ throw new Error(result.error.message);
171
+ return result.milestone;
172
+ },
173
+ },
174
+ // Goals
175
+ devpad_goals_list: {
176
+ name: "devpad_goals_list",
177
+ description: "List goals for authenticated user",
178
+ inputSchema: z.object({}),
179
+ execute: async (client) => {
180
+ const result = await client.goals.list();
181
+ if (result.error)
182
+ throw new Error(result.error.message);
183
+ return result.goals;
184
+ },
185
+ },
186
+ devpad_goals_get: {
187
+ name: "devpad_goals_get",
188
+ description: "Get goal by ID",
189
+ inputSchema: goal_by_id,
190
+ execute: async (client, input) => {
191
+ const result = await client.goals.find(input.id);
192
+ if (result.error)
193
+ throw new Error(result.error.message);
194
+ return result.goal;
195
+ },
196
+ },
197
+ devpad_goals_upsert: {
198
+ name: "devpad_goals_upsert",
199
+ description: "Create or update a goal",
200
+ inputSchema: upsert_goal,
201
+ execute: async (client, input) => {
202
+ const result = input.id
203
+ ? await client.goals.update(input.id, {
204
+ name: input.name,
205
+ description: input.description,
206
+ target_time: input.target_time,
207
+ })
208
+ : await client.goals.create({
209
+ milestone_id: input.milestone_id,
210
+ name: input.name,
211
+ description: input.description,
212
+ target_time: input.target_time,
213
+ });
214
+ if (result.error)
215
+ throw new Error(result.error.message);
216
+ return result.goal;
217
+ },
218
+ },
219
+ // Tags
220
+ devpad_tags_list: {
221
+ name: "devpad_tags_list",
222
+ description: "List tags for authenticated user",
223
+ inputSchema: z.object({}),
224
+ execute: async (client) => {
225
+ const result = await client.tags.list();
226
+ if (result.error)
227
+ throw new Error(result.error.message);
228
+ return result.tags;
229
+ },
230
+ },
231
+ // GitHub integration
232
+ devpad_github_repos: {
233
+ name: "devpad_github_repos",
234
+ description: "List GitHub repositories for authenticated user",
235
+ inputSchema: z.object({}),
236
+ execute: async (client) => {
237
+ const result = await client.github.repos();
238
+ if (result.error)
239
+ throw new Error(result.error.message);
240
+ return result.repos;
241
+ },
242
+ },
243
+ devpad_github_branches: {
244
+ name: "devpad_github_branches",
245
+ description: "List branches for a GitHub repository",
246
+ inputSchema: github_branches,
247
+ execute: async (client, input) => {
248
+ const result = await client.github.branches(input.owner, input.repo);
249
+ if (result.error)
250
+ throw new Error(result.error.message);
251
+ return result.branches;
252
+ },
253
+ },
254
+ // Additional project operations
255
+ devpad_projects_delete: {
256
+ name: "devpad_projects_delete",
257
+ description: "Delete a project",
258
+ inputSchema: z.object({
259
+ id: z.string().describe("Project ID"),
260
+ }),
261
+ execute: async (client, input) => {
262
+ // First get the project to have all required fields
263
+ const getResult = await client.projects.find(input.id);
264
+ if (getResult.error)
265
+ throw new Error(getResult.error.message);
266
+ if (!getResult.project)
267
+ throw new Error(`Project ${input.id} not found`);
268
+ const result = await client.projects.deleteProject(getResult.project);
269
+ if (result.error)
270
+ throw new Error(result.error.message);
271
+ return { success: true };
272
+ },
273
+ },
274
+ devpad_projects_history: {
275
+ name: "devpad_projects_history",
276
+ description: "Get project history",
277
+ inputSchema: z.object({
278
+ project_id: z.string().describe("Project ID"),
279
+ }),
280
+ execute: async (client, input) => {
281
+ const result = await client.projects.history(input.project_id);
282
+ if (result.error)
283
+ throw new Error(result.error.message);
284
+ return result.history;
285
+ },
286
+ },
287
+ devpad_projects_specification: {
288
+ name: "devpad_projects_specification",
289
+ description: "Fetch project specification from GitHub",
290
+ inputSchema: z.object({
291
+ project_id: z.string().describe("Project ID"),
292
+ }),
293
+ execute: async (client, input) => {
294
+ const result = await client.projects.specification(input.project_id);
295
+ if (result.error)
296
+ throw new Error(result.error.message);
297
+ return result.specification;
298
+ },
299
+ },
300
+ devpad_projects_config_load: {
301
+ name: "devpad_projects_config_load",
302
+ description: "Load project configuration",
303
+ inputSchema: z.object({
304
+ project_id: z.string().describe("Project ID"),
305
+ }),
306
+ execute: async (client, input) => {
307
+ const result = await client.projects.config.load(input.project_id);
308
+ if (result.error)
309
+ throw new Error(result.error.message);
310
+ return result.config;
311
+ },
312
+ },
313
+ // Additional milestone operations
314
+ devpad_milestones_delete: {
315
+ name: "devpad_milestones_delete",
316
+ description: "Delete a milestone",
317
+ inputSchema: z.object({
318
+ id: z.string().describe("Milestone ID"),
319
+ }),
320
+ execute: async (client, input) => {
321
+ const result = await client.milestones.delete(input.id);
322
+ if (result.error)
323
+ throw new Error(result.error.message);
324
+ return result.result;
325
+ },
326
+ },
327
+ devpad_milestones_goals: {
328
+ name: "devpad_milestones_goals",
329
+ description: "Get goals for a milestone",
330
+ inputSchema: z.object({
331
+ id: z.string().describe("Milestone ID"),
332
+ }),
333
+ execute: async (client, input) => {
334
+ const result = await client.milestones.goals(input.id);
335
+ if (result.error)
336
+ throw new Error(result.error.message);
337
+ return result.goals;
338
+ },
339
+ },
340
+ // Additional goal operations
341
+ devpad_goals_delete: {
342
+ name: "devpad_goals_delete",
343
+ description: "Delete a goal",
344
+ inputSchema: z.object({
345
+ id: z.string().describe("Goal ID"),
346
+ }),
347
+ execute: async (client, input) => {
348
+ const result = await client.goals.delete(input.id);
349
+ if (result.error)
350
+ throw new Error(result.error.message);
351
+ return result.result;
352
+ },
353
+ },
354
+ // Additional task operations
355
+ devpad_tasks_delete: {
356
+ name: "devpad_tasks_delete",
357
+ description: "Delete a task",
358
+ inputSchema: z.object({
359
+ id: z.string().describe("Task ID"),
360
+ }),
361
+ execute: async (client, input) => {
362
+ // First get the task to have all required fields
363
+ const getResult = await client.tasks.find(input.id);
364
+ if (getResult.error)
365
+ throw new Error(getResult.error.message);
366
+ if (!getResult.task)
367
+ throw new Error(`Task ${input.id} not found`);
368
+ const result = await client.tasks.deleteTask(getResult.task);
369
+ if (result.error)
370
+ throw new Error(result.error.message);
371
+ return { success: true };
372
+ },
373
+ },
374
+ devpad_tasks_history: {
375
+ name: "devpad_tasks_history",
376
+ description: "Get task history",
377
+ inputSchema: z.object({
378
+ task_id: z.string().describe("Task ID"),
379
+ }),
380
+ execute: async (client, input) => {
381
+ const result = await client.tasks.history.get(input.task_id);
382
+ if (result.error)
383
+ throw new Error(result.error.message);
384
+ return result.history;
385
+ },
386
+ },
387
+ // User operations
388
+ devpad_user_history: {
389
+ name: "devpad_user_history",
390
+ description: "Get user activity history",
391
+ inputSchema: z.object({}),
392
+ execute: async (client) => {
393
+ const result = await client.user.history();
394
+ if (result.error)
395
+ throw new Error(result.error.message);
396
+ return result.history;
397
+ },
398
+ },
399
+ devpad_user_preferences: {
400
+ name: "devpad_user_preferences",
401
+ description: "Update user preferences",
402
+ inputSchema: z.object({
403
+ id: z.string().describe("User ID"),
404
+ task_view: z.enum(["list", "grid"]).describe("Task view preference"),
405
+ }),
406
+ execute: async (client, input) => {
407
+ const result = await client.user.preferences(input);
408
+ if (result.error)
409
+ throw new Error(result.error.message);
410
+ return result.result;
411
+ },
412
+ },
413
+ };
414
+ // Helper to convert Zod schema to JSON Schema for MCP
415
+ export function zodToMCPSchema(schema) {
416
+ // This will be imported from zod-to-json-schema for MCP server
417
+ // For now, returning a placeholder
418
+ return schema;
419
+ }
420
+ // Get all tool names
421
+ export const toolNames = Object.keys(tools);
422
+ // Get tool by name
423
+ export function getTool(name) {
424
+ return tools[name];
425
+ }
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@devpad/api",
3
+ "version": "1.0.1",
4
+ "author": {
5
+ "name": "f0rbit",
6
+ "url": "https://github.com/f0rbit"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/f0rbit/devpad.git",
11
+ "directory": "packages/api"
12
+ },
13
+ "main": "dist/index.js",
14
+ "scripts": {
15
+ "build": "bunx tsc",
16
+ "build:watch": "bunx tsc --watch",
17
+ "test": "bun test",
18
+ "test:unit": "bun test tests/unit/",
19
+ "test:integration": "bun test tests/integration/",
20
+ "test:coverage": "bun test --coverage",
21
+ "lint": "bun run eslint",
22
+ "prepublishOnly": "bun run build",
23
+ "clean": "rm -rf dist"
24
+ },
25
+ "dependencies": {
26
+ "@devpad/schema": "workspace:*",
27
+ "zod": "^3.22.4"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^20.11.24",
31
+ "bun-types": "latest",
32
+ "eslint": "^8.57.0",
33
+ "typescript": "^5.9.2"
34
+ },
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js"
39
+ }
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/f0rbit/devpad/issues"
43
+ },
44
+ "description": "TypeScript client library for the devpad API - project and task management made simple",
45
+ "engines": {
46
+ "node": ">=18.0.0"
47
+ },
48
+ "files": [
49
+ "dist"
50
+ ],
51
+ "homepage": "https://devpad.tools",
52
+ "keywords": [
53
+ "devpad",
54
+ "api",
55
+ "client",
56
+ "typescript",
57
+ "project-management",
58
+ "task-management"
59
+ ],
60
+ "license": "MIT",
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "registry": "https://registry.npmjs.org/"
64
+ },
65
+ "type": "module",
66
+ "types": "dist/index.d.ts"
67
+ }