@compilr-dev/sdk 0.1.7 → 0.1.8
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/README.md +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +8 -0
- package/dist/platform/context.d.ts +44 -0
- package/dist/platform/context.js +7 -0
- package/dist/platform/index.d.ts +9 -0
- package/dist/platform/index.js +7 -0
- package/dist/platform/repositories.d.ts +62 -0
- package/dist/platform/repositories.js +8 -0
- package/dist/platform/tools/backlog-tools.d.ts +41 -0
- package/dist/platform/tools/backlog-tools.js +358 -0
- package/dist/platform/tools/document-tools.d.ts +15 -0
- package/dist/platform/tools/document-tools.js +217 -0
- package/dist/platform/tools/index.d.ts +135 -0
- package/dist/platform/tools/index.js +31 -0
- package/dist/platform/tools/plan-tools.d.ts +29 -0
- package/dist/platform/tools/plan-tools.js +325 -0
- package/dist/platform/tools/project-tools.d.ts +41 -0
- package/dist/platform/tools/project-tools.js +367 -0
- package/dist/platform/tools/workitem-tools.d.ts +56 -0
- package/dist/platform/tools/workitem-tools.js +715 -0
- package/dist/platform/types.d.ts +233 -0
- package/dist/platform/types.js +13 -0
- package/dist/platform/workflow.d.ts +37 -0
- package/dist/platform/workflow.js +108 -0
- package/package.json +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Document Tools — CRUD operations for project documents.
|
|
3
|
+
*
|
|
4
|
+
* 4 tools: project_document_add, project_document_get,
|
|
5
|
+
* project_document_list, project_document_delete
|
|
6
|
+
*
|
|
7
|
+
* Ported from CLI's src/tools/document-db.ts.
|
|
8
|
+
*/
|
|
9
|
+
import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev/agents';
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
11
|
+
export function createDocumentTools(config) {
|
|
12
|
+
const { context: ctx } = config;
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// project_document_add
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
const projectDocumentAddTool = defineTool({
|
|
17
|
+
name: 'project_document_add',
|
|
18
|
+
description: 'Add or update a project document (PRD, architecture, design, notes). If a document of the same type exists, it will be updated.',
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: 'object',
|
|
21
|
+
properties: {
|
|
22
|
+
project_id: {
|
|
23
|
+
type: 'number',
|
|
24
|
+
description: 'Project ID (uses active project if not provided)',
|
|
25
|
+
},
|
|
26
|
+
doc_type: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
enum: ['prd', 'architecture', 'design', 'notes'],
|
|
29
|
+
description: 'Document type',
|
|
30
|
+
},
|
|
31
|
+
title: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Document title',
|
|
34
|
+
},
|
|
35
|
+
content: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'Document content (markdown)',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
required: ['doc_type', 'title', 'content'],
|
|
41
|
+
},
|
|
42
|
+
execute: async (input) => {
|
|
43
|
+
try {
|
|
44
|
+
const projectId = input.project_id ?? ctx.currentProjectId;
|
|
45
|
+
if (!projectId) {
|
|
46
|
+
return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
|
|
47
|
+
}
|
|
48
|
+
const createInput = {
|
|
49
|
+
project_id: projectId,
|
|
50
|
+
doc_type: input.doc_type,
|
|
51
|
+
title: input.title,
|
|
52
|
+
content: input.content,
|
|
53
|
+
};
|
|
54
|
+
const doc = await ctx.documents.upsert(createInput);
|
|
55
|
+
return createSuccessResult({
|
|
56
|
+
success: true,
|
|
57
|
+
message: `Document "${doc.title}" saved`,
|
|
58
|
+
document: {
|
|
59
|
+
id: doc.id,
|
|
60
|
+
docType: doc.docType,
|
|
61
|
+
title: doc.title,
|
|
62
|
+
contentLength: doc.content.length,
|
|
63
|
+
updatedAt: doc.updatedAt.toISOString(),
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
return createErrorResult(`Failed to save document: ${error instanceof Error ? error.message : String(error)}`);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// project_document_get
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
const projectDocumentGetTool = defineTool({
|
|
76
|
+
name: 'project_document_get',
|
|
77
|
+
description: 'Get a project document by type. Returns the document content.',
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties: {
|
|
81
|
+
project_id: {
|
|
82
|
+
type: 'number',
|
|
83
|
+
description: 'Project ID (uses active project if not provided)',
|
|
84
|
+
},
|
|
85
|
+
doc_type: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
enum: ['prd', 'architecture', 'design', 'notes'],
|
|
88
|
+
description: 'Document type to retrieve',
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
required: ['doc_type'],
|
|
92
|
+
},
|
|
93
|
+
execute: async (input) => {
|
|
94
|
+
try {
|
|
95
|
+
const projectId = input.project_id ?? ctx.currentProjectId;
|
|
96
|
+
if (!projectId) {
|
|
97
|
+
return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
|
|
98
|
+
}
|
|
99
|
+
const doc = await ctx.documents.getByType(projectId, input.doc_type);
|
|
100
|
+
if (!doc) {
|
|
101
|
+
return createSuccessResult({
|
|
102
|
+
success: true,
|
|
103
|
+
document: null,
|
|
104
|
+
message: `No ${input.doc_type} document found for this project`,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return createSuccessResult({
|
|
108
|
+
success: true,
|
|
109
|
+
document: {
|
|
110
|
+
id: doc.id,
|
|
111
|
+
docType: doc.docType,
|
|
112
|
+
title: doc.title,
|
|
113
|
+
content: doc.content,
|
|
114
|
+
createdAt: doc.createdAt.toISOString(),
|
|
115
|
+
updatedAt: doc.updatedAt.toISOString(),
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return createErrorResult(`Failed to get document: ${error instanceof Error ? error.message : String(error)}`);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
// ---------------------------------------------------------------------------
|
|
125
|
+
// project_document_list
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
const projectDocumentListTool = defineTool({
|
|
128
|
+
name: 'project_document_list',
|
|
129
|
+
description: 'List all documents for a project. Returns document metadata without full content.',
|
|
130
|
+
inputSchema: {
|
|
131
|
+
type: 'object',
|
|
132
|
+
properties: {
|
|
133
|
+
project_id: {
|
|
134
|
+
type: 'number',
|
|
135
|
+
description: 'Project ID (uses active project if not provided)',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
required: [],
|
|
139
|
+
},
|
|
140
|
+
execute: async (input) => {
|
|
141
|
+
try {
|
|
142
|
+
const projectId = input.project_id ?? ctx.currentProjectId;
|
|
143
|
+
if (!projectId) {
|
|
144
|
+
return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
|
|
145
|
+
}
|
|
146
|
+
const docs = await ctx.documents.listByProject(projectId);
|
|
147
|
+
const documents = docs.map((doc) => ({
|
|
148
|
+
id: doc.id,
|
|
149
|
+
docType: doc.docType,
|
|
150
|
+
title: doc.title,
|
|
151
|
+
contentLength: doc.content.length,
|
|
152
|
+
createdAt: doc.createdAt.toISOString(),
|
|
153
|
+
updatedAt: doc.updatedAt.toISOString(),
|
|
154
|
+
}));
|
|
155
|
+
return createSuccessResult({
|
|
156
|
+
success: true,
|
|
157
|
+
documents,
|
|
158
|
+
count: documents.length,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
return createErrorResult(`Failed to list documents: ${error instanceof Error ? error.message : String(error)}`);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
// ---------------------------------------------------------------------------
|
|
167
|
+
// project_document_delete
|
|
168
|
+
// ---------------------------------------------------------------------------
|
|
169
|
+
const projectDocumentDeleteTool = defineTool({
|
|
170
|
+
name: 'project_document_delete',
|
|
171
|
+
description: 'Delete a project document by type.',
|
|
172
|
+
inputSchema: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
project_id: {
|
|
176
|
+
type: 'number',
|
|
177
|
+
description: 'Project ID (uses active project if not provided)',
|
|
178
|
+
},
|
|
179
|
+
doc_type: {
|
|
180
|
+
type: 'string',
|
|
181
|
+
enum: ['prd', 'architecture', 'design', 'notes'],
|
|
182
|
+
description: 'Document type to delete',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
required: ['doc_type'],
|
|
186
|
+
},
|
|
187
|
+
execute: async (input) => {
|
|
188
|
+
try {
|
|
189
|
+
const projectId = input.project_id ?? ctx.currentProjectId;
|
|
190
|
+
if (!projectId) {
|
|
191
|
+
return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
|
|
192
|
+
}
|
|
193
|
+
const doc = await ctx.documents.getByType(projectId, input.doc_type);
|
|
194
|
+
if (!doc) {
|
|
195
|
+
return createErrorResult(`No ${input.doc_type} document found for this project`);
|
|
196
|
+
}
|
|
197
|
+
const deleted = await ctx.documents.delete(doc.id);
|
|
198
|
+
if (!deleted) {
|
|
199
|
+
return createErrorResult(`Failed to delete ${input.doc_type} document`);
|
|
200
|
+
}
|
|
201
|
+
return createSuccessResult({
|
|
202
|
+
success: true,
|
|
203
|
+
message: `Document "${doc.title}" deleted`,
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
return createErrorResult(`Failed to delete document: ${error instanceof Error ? error.message : String(error)}`);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
return [
|
|
212
|
+
projectDocumentAddTool,
|
|
213
|
+
projectDocumentGetTool,
|
|
214
|
+
projectDocumentListTool,
|
|
215
|
+
projectDocumentDeleteTool,
|
|
216
|
+
];
|
|
217
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Tools — Factory function for all platform tools.
|
|
3
|
+
*
|
|
4
|
+
* Returns 24 tool definitions operating against async PlatformContext repositories.
|
|
5
|
+
* Decouples tool logic from SQLite storage, enabling mock-based testing and
|
|
6
|
+
* future PostgreSQL/API backends.
|
|
7
|
+
*/
|
|
8
|
+
import type { PlatformToolsConfig } from '../context.js';
|
|
9
|
+
/**
|
|
10
|
+
* Create all 24 platform tools operating against the given context.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createPlatformTools(config: PlatformToolsConfig): (import("@compilr-dev/agents").Tool<{
|
|
13
|
+
project_id?: number;
|
|
14
|
+
name?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
17
|
+
name: string;
|
|
18
|
+
display_name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
path?: string;
|
|
21
|
+
type?: string;
|
|
22
|
+
workflow_mode?: string;
|
|
23
|
+
language?: string;
|
|
24
|
+
framework?: string;
|
|
25
|
+
package_manager?: string;
|
|
26
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
27
|
+
project_id?: number;
|
|
28
|
+
status?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
workflow_mode?: string;
|
|
31
|
+
lifecycle_state?: string;
|
|
32
|
+
current_item_id?: string;
|
|
33
|
+
git_remote?: string;
|
|
34
|
+
git_branch?: string;
|
|
35
|
+
last_context?: Record<string, unknown>;
|
|
36
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
37
|
+
project_id?: number;
|
|
38
|
+
status?: string;
|
|
39
|
+
type?: string;
|
|
40
|
+
priority?: string;
|
|
41
|
+
owner?: string;
|
|
42
|
+
search?: string;
|
|
43
|
+
limit?: number;
|
|
44
|
+
offset?: number;
|
|
45
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
46
|
+
project_id?: number;
|
|
47
|
+
type: string;
|
|
48
|
+
title: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
priority?: string;
|
|
51
|
+
estimated_effort?: string;
|
|
52
|
+
owner?: string;
|
|
53
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
54
|
+
item_id: string;
|
|
55
|
+
project_id?: number;
|
|
56
|
+
status?: string;
|
|
57
|
+
priority?: string;
|
|
58
|
+
owner?: string;
|
|
59
|
+
guided_step?: string;
|
|
60
|
+
title?: string;
|
|
61
|
+
description?: string;
|
|
62
|
+
commit_hash?: string;
|
|
63
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
64
|
+
item_id: string;
|
|
65
|
+
reason: string;
|
|
66
|
+
force?: boolean;
|
|
67
|
+
project_id?: number;
|
|
68
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
69
|
+
item_id: string;
|
|
70
|
+
agent_id: string;
|
|
71
|
+
project_id?: number;
|
|
72
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
73
|
+
item_id: string;
|
|
74
|
+
to_agent_id: string;
|
|
75
|
+
notes?: string;
|
|
76
|
+
project_id?: number;
|
|
77
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
78
|
+
project_id?: number;
|
|
79
|
+
doc_type: string;
|
|
80
|
+
title: string;
|
|
81
|
+
content: string;
|
|
82
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
83
|
+
name: string;
|
|
84
|
+
content: string;
|
|
85
|
+
work_item_id?: number;
|
|
86
|
+
project_id?: number;
|
|
87
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
88
|
+
plan_id: number;
|
|
89
|
+
content?: string;
|
|
90
|
+
status?: string;
|
|
91
|
+
work_item_id?: number | null;
|
|
92
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
93
|
+
plan_id?: number;
|
|
94
|
+
name?: string;
|
|
95
|
+
project_id?: number;
|
|
96
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
97
|
+
project_id?: number;
|
|
98
|
+
status?: string;
|
|
99
|
+
work_item_id?: number;
|
|
100
|
+
limit?: number;
|
|
101
|
+
order_by?: string;
|
|
102
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
103
|
+
id?: string;
|
|
104
|
+
status?: string;
|
|
105
|
+
type?: string;
|
|
106
|
+
search?: string;
|
|
107
|
+
priority?: string;
|
|
108
|
+
limit?: number;
|
|
109
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
110
|
+
action: string;
|
|
111
|
+
item?: {
|
|
112
|
+
id?: string;
|
|
113
|
+
type?: string;
|
|
114
|
+
title?: string;
|
|
115
|
+
description?: string;
|
|
116
|
+
status?: string;
|
|
117
|
+
priority?: string;
|
|
118
|
+
owner?: string;
|
|
119
|
+
commit_hash?: string;
|
|
120
|
+
};
|
|
121
|
+
deleteId?: string;
|
|
122
|
+
items?: Array<{
|
|
123
|
+
id?: string;
|
|
124
|
+
type: string;
|
|
125
|
+
title: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
status?: string;
|
|
128
|
+
priority?: string;
|
|
129
|
+
}>;
|
|
130
|
+
}>)[];
|
|
131
|
+
export { createProjectTools } from './project-tools.js';
|
|
132
|
+
export { createWorkItemTools } from './workitem-tools.js';
|
|
133
|
+
export { createDocumentTools } from './document-tools.js';
|
|
134
|
+
export { createPlanTools } from './plan-tools.js';
|
|
135
|
+
export { createBacklogTools } from './backlog-tools.js';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Tools — Factory function for all platform tools.
|
|
3
|
+
*
|
|
4
|
+
* Returns 24 tool definitions operating against async PlatformContext repositories.
|
|
5
|
+
* Decouples tool logic from SQLite storage, enabling mock-based testing and
|
|
6
|
+
* future PostgreSQL/API backends.
|
|
7
|
+
*/
|
|
8
|
+
import { createProjectTools } from './project-tools.js';
|
|
9
|
+
import { createWorkItemTools } from './workitem-tools.js';
|
|
10
|
+
import { createDocumentTools } from './document-tools.js';
|
|
11
|
+
import { createPlanTools } from './plan-tools.js';
|
|
12
|
+
import { createBacklogTools } from './backlog-tools.js';
|
|
13
|
+
/**
|
|
14
|
+
* Create all 24 platform tools operating against the given context.
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
17
|
+
export function createPlatformTools(config) {
|
|
18
|
+
return [
|
|
19
|
+
...createProjectTools(config),
|
|
20
|
+
...createWorkItemTools(config),
|
|
21
|
+
...createDocumentTools(config),
|
|
22
|
+
...createPlanTools(config),
|
|
23
|
+
...createBacklogTools(config),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
// Re-export individual factory functions for selective use
|
|
27
|
+
export { createProjectTools } from './project-tools.js';
|
|
28
|
+
export { createWorkItemTools } from './workitem-tools.js';
|
|
29
|
+
export { createDocumentTools } from './document-tools.js';
|
|
30
|
+
export { createPlanTools } from './plan-tools.js';
|
|
31
|
+
export { createBacklogTools } from './backlog-tools.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plan Tools — CRUD operations for plans.
|
|
3
|
+
*
|
|
4
|
+
* 5 tools: plan_create, plan_update, plan_get, plan_list, plan_delete
|
|
5
|
+
*
|
|
6
|
+
* Ported from CLI's src/tools/plan-tools.ts.
|
|
7
|
+
*/
|
|
8
|
+
import type { PlatformToolsConfig } from '../context.js';
|
|
9
|
+
export declare function createPlanTools(config: PlatformToolsConfig): (import("@compilr-dev/agents").Tool<{
|
|
10
|
+
name: string;
|
|
11
|
+
content: string;
|
|
12
|
+
work_item_id?: number;
|
|
13
|
+
project_id?: number;
|
|
14
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
15
|
+
plan_id: number;
|
|
16
|
+
content?: string;
|
|
17
|
+
status?: string;
|
|
18
|
+
work_item_id?: number | null;
|
|
19
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
20
|
+
plan_id?: number;
|
|
21
|
+
name?: string;
|
|
22
|
+
project_id?: number;
|
|
23
|
+
}> | import("@compilr-dev/agents").Tool<{
|
|
24
|
+
project_id?: number;
|
|
25
|
+
status?: string;
|
|
26
|
+
work_item_id?: number;
|
|
27
|
+
limit?: number;
|
|
28
|
+
order_by?: string;
|
|
29
|
+
}>)[];
|