@compilr-dev/sdk 0.2.15 → 0.2.16

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.
@@ -104,17 +104,26 @@ export function createBacklogTools(config) {
104
104
  if (!item) {
105
105
  return createErrorResult(`Item not found: ${input.id}`);
106
106
  }
107
+ const itemData = {
108
+ id: item.itemId,
109
+ type: TYPE_TO_LIBRARY[item.type],
110
+ title: item.title,
111
+ description: item.description ?? '',
112
+ status: STATUS_TO_LIBRARY[item.status],
113
+ priority: item.priority,
114
+ };
115
+ // Include comments when available
116
+ if (ctx.comments) {
117
+ const itemComments = await ctx.comments.listByWorkItem(item.id);
118
+ itemData.comments = itemComments.map((c) => ({
119
+ id: c.id,
120
+ author: c.author,
121
+ content: c.content,
122
+ createdAt: c.createdAt.toISOString(),
123
+ }));
124
+ }
107
125
  return createSuccessResult({
108
- items: [
109
- {
110
- id: item.itemId,
111
- type: TYPE_TO_LIBRARY[item.type],
112
- title: item.title,
113
- description: item.description ?? '',
114
- status: STATUS_TO_LIBRARY[item.status],
115
- priority: item.priority,
116
- },
117
- ],
126
+ items: [itemData],
118
127
  total: 1,
119
128
  filtered: 1,
120
129
  });
@@ -13,12 +13,14 @@
13
13
  */
14
14
  import type { PlatformToolsConfig } from '../context.js';
15
15
  export declare function createWorkItemTools(config: PlatformToolsConfig): (import("@compilr-dev/agents").Tool<{
16
+ item_id?: string;
16
17
  project_id?: number;
17
18
  status?: string;
18
19
  type?: string;
19
20
  priority?: string;
20
21
  owner?: string;
21
22
  search?: string;
23
+ include_comments?: boolean;
22
24
  limit?: number;
23
25
  offset?: number;
24
26
  }> | import("@compilr-dev/agents").Tool<{
@@ -21,10 +21,14 @@ export function createWorkItemTools(config) {
21
21
  // ---------------------------------------------------------------------------
22
22
  const workitemQueryTool = defineTool({
23
23
  name: 'workitem_query',
24
- description: 'Query work items from the project backlog. Supports filtering by status, type, priority, owner, and search.',
24
+ description: 'Query work items from the project backlog. Use item_id for a single item with full details and comments. Supports filtering by status, type, priority, owner, and search.',
25
25
  inputSchema: {
26
26
  type: 'object',
27
27
  properties: {
28
+ item_id: {
29
+ type: 'string',
30
+ description: 'Get a specific item by ID (e.g., "REQ-001"). Returns full details with comments.',
31
+ },
28
32
  status: {
29
33
  type: 'string',
30
34
  enum: ['backlog', 'in_progress', 'completed', 'skipped', 'all'],
@@ -49,6 +53,10 @@ export function createWorkItemTools(config) {
49
53
  type: 'string',
50
54
  description: 'Search in title and description',
51
55
  },
56
+ include_comments: {
57
+ type: 'boolean',
58
+ description: 'Include full comments for each item (default: false for lists, always true for single item_id lookup)',
59
+ },
52
60
  limit: {
53
61
  type: 'number',
54
62
  description: 'Max items to return',
@@ -72,7 +80,47 @@ export function createWorkItemTools(config) {
72
80
  if (!projectId) {
73
81
  return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
74
82
  }
75
- // Resolve "self" to the active agent ID via hook
83
+ const comments = ctx.comments;
84
+ // Single item lookup by item_id
85
+ if (input.item_id) {
86
+ const item = await ctx.workItems.getByItemId(projectId, input.item_id);
87
+ if (!item) {
88
+ return createErrorResult(`Work item "${input.item_id}" not found in current project`);
89
+ }
90
+ const itemData = {
91
+ id: item.id,
92
+ itemId: item.itemId,
93
+ type: item.type,
94
+ status: item.status,
95
+ priority: item.priority,
96
+ owner: item.owner,
97
+ guidedStep: item.guidedStep,
98
+ title: item.title,
99
+ description: item.description,
100
+ estimatedEffort: item.estimatedEffort,
101
+ completedAt: item.completedAt?.toISOString(),
102
+ commitHash: item.commitHash,
103
+ createdAt: item.createdAt.toISOString(),
104
+ };
105
+ // Always include full comments for single-item lookup
106
+ if (comments) {
107
+ const itemComments = await comments.listByWorkItem(item.id);
108
+ itemData.comments = itemComments.map((c) => ({
109
+ id: c.id,
110
+ author: c.author,
111
+ content: c.content,
112
+ createdAt: c.createdAt.toISOString(),
113
+ }));
114
+ }
115
+ return createSuccessResult({
116
+ success: true,
117
+ items: [itemData],
118
+ total: 1,
119
+ hasMore: false,
120
+ projectId,
121
+ });
122
+ }
123
+ // List query
76
124
  let resolvedOwner = input.owner;
77
125
  if (input.owner === 'self') {
78
126
  resolvedOwner = hooks?.resolveOwner?.('self') ?? undefined;
@@ -88,7 +136,7 @@ export function createWorkItemTools(config) {
88
136
  offset: input.offset ?? 0,
89
137
  };
90
138
  const result = await ctx.workItems.query(queryInput);
91
- const comments = ctx.comments;
139
+ const wantFullComments = input.include_comments === true;
92
140
  const items = await Promise.all(result.items.map(async (item) => {
93
141
  const base = {
94
142
  id: item.id,
@@ -107,16 +155,19 @@ export function createWorkItemTools(config) {
107
155
  };
108
156
  if (!comments)
109
157
  return base;
110
- const itemComments = await comments.listByWorkItem(item.id);
111
- return {
112
- ...base,
113
- comments: itemComments.map((c) => ({
158
+ if (wantFullComments) {
159
+ const itemComments = await comments.listByWorkItem(item.id);
160
+ base.comments = itemComments.map((c) => ({
114
161
  id: c.id,
115
162
  author: c.author,
116
163
  content: c.content,
117
164
  createdAt: c.createdAt.toISOString(),
118
- })),
119
- };
165
+ }));
166
+ }
167
+ else {
168
+ base.commentCount = await comments.countByWorkItem(item.id);
169
+ }
170
+ return base;
120
171
  }));
121
172
  return createSuccessResult({
122
173
  success: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compilr-dev/sdk",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Universal agent runtime for building AI-powered applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",