@compilr-dev/cli 0.5.1 → 0.5.2

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 (40) hide show
  1. package/LICENSE +108 -0
  2. package/README.md +2 -2
  3. package/dist/.tsbuildinfo.app +1 -1
  4. package/dist/.tsbuildinfo.data +1 -1
  5. package/dist/.tsbuildinfo.domain +1 -1
  6. package/dist/.tsbuildinfo.foundation +1 -1
  7. package/dist/commands-v2/handlers/context.js +20 -0
  8. package/dist/commands-v2/handlers/project.js +52 -9
  9. package/dist/compilr-diff-companion.vsix +0 -0
  10. package/dist/db/repositories/document-repository.js +1 -0
  11. package/dist/db/schema.d.ts +1 -1
  12. package/dist/repl-helpers.js +2 -0
  13. package/dist/repl-v2.js +16 -5
  14. package/dist/tool-names.d.ts +5 -0
  15. package/dist/tool-names.js +12 -0
  16. package/dist/tools/db-tools.d.ts +6 -1
  17. package/dist/tools/db-tools.js +6 -2
  18. package/dist/tools/meta-tools.d.ts +1 -1
  19. package/dist/tools/platform-adapter.d.ts +6 -0
  20. package/dist/tools/platform-adapter.js +10 -0
  21. package/dist/tools.js +3 -1
  22. package/dist/ui/constants/labels.js +1 -0
  23. package/dist/ui/overlay/impl/workflow-overlay-v2.d.ts +1 -0
  24. package/dist/ui/overlay/impl/workflow-overlay-v2.js +5 -3
  25. package/dist/ui/tool-formatters.js +190 -6
  26. package/package.json +5 -4
  27. package/dist/tools/anchor-tools.d.ts +0 -31
  28. package/dist/tools/anchor-tools.js +0 -255
  29. package/dist/tools/artifact-tools.d.ts +0 -42
  30. package/dist/tools/artifact-tools.js +0 -328
  31. package/dist/tools/backlog-wrappers.d.ts +0 -56
  32. package/dist/tools/backlog-wrappers.js +0 -353
  33. package/dist/tools/document-db.d.ts +0 -43
  34. package/dist/tools/document-db.js +0 -220
  35. package/dist/tools/plan-tools.d.ts +0 -54
  36. package/dist/tools/plan-tools.js +0 -338
  37. package/dist/tools/recall-work-tool.d.ts +0 -18
  38. package/dist/tools/recall-work-tool.js +0 -82
  39. package/dist/tools/workitem-db.d.ts +0 -135
  40. package/dist/tools/workitem-db.js +0 -730
@@ -1,338 +0,0 @@
1
- /**
2
- * Plan Database Tools
3
- *
4
- * Tools for managing plans in the database.
5
- * Plans are used in Plan Mode for structured task planning before implementation.
6
- */
7
- import { defineTool, createSuccessResult, createErrorResult } from '@compilr-dev/sdk';
8
- import { planRepository, } from '../db/repositories/index.js';
9
- import { getActiveProject } from './project-db.js';
10
- // =============================================================================
11
- // plan_create - Create a new plan
12
- // =============================================================================
13
- export const planCreateTool = defineTool({
14
- name: 'plan_create',
15
- description: 'Create a new plan for the current project. Plans are used to document implementation approaches before coding. The plan is created with "draft" status.',
16
- inputSchema: {
17
- type: 'object',
18
- properties: {
19
- name: {
20
- type: 'string',
21
- description: 'Plan name (kebab-case, 3-5 words). Example: "auth-jwt-migration", "add-dark-mode-toggle"',
22
- },
23
- content: {
24
- type: 'string',
25
- description: 'Plan content in markdown format. Should include: Context, Goals, Steps, Verification sections.',
26
- },
27
- work_item_id: {
28
- type: 'number',
29
- description: 'Optional: ID of the work item this plan is for. Links the plan to a backlog item.',
30
- },
31
- project_id: {
32
- type: 'number',
33
- description: 'Project ID (uses active project if not provided)',
34
- },
35
- },
36
- required: ['name', 'content'],
37
- },
38
- execute: async (input) => {
39
- await Promise.resolve();
40
- try {
41
- const projectId = input.project_id ?? getActiveProject()?.id;
42
- if (!projectId) {
43
- return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
44
- }
45
- // Validate name format (kebab-case)
46
- if (!/^[a-z][a-z0-9-]*[a-z0-9]$/.test(input.name) && input.name.length > 2) {
47
- // Allow simple 2-char names, but enforce kebab-case for longer names
48
- if (input.name.length > 2 && !/^[a-z0-9-]+$/.test(input.name)) {
49
- return createErrorResult('Plan name should be kebab-case (lowercase letters, numbers, hyphens). Example: "auth-jwt-migration"');
50
- }
51
- }
52
- const createInput = {
53
- project_id: projectId,
54
- name: input.name,
55
- content: input.content,
56
- work_item_id: input.work_item_id,
57
- };
58
- const plan = planRepository.create(createInput);
59
- return createSuccessResult({
60
- success: true,
61
- message: `Plan "${plan.name}" created`,
62
- plan: {
63
- id: plan.id,
64
- name: plan.name,
65
- status: plan.status,
66
- workItemId: plan.workItemId,
67
- createdAt: plan.createdAt.toISOString(),
68
- },
69
- });
70
- }
71
- catch (error) {
72
- return createErrorResult(`Failed to create plan: ${error instanceof Error ? error.message : String(error)}`);
73
- }
74
- },
75
- });
76
- // =============================================================================
77
- // plan_update - Update an existing plan
78
- // =============================================================================
79
- export const planUpdateTool = defineTool({
80
- name: 'plan_update',
81
- description: 'Update an existing plan. Can update content, status, or work item link. Status transitions: draft→approved→in_progress→completed. Any status can transition to "abandoned".',
82
- inputSchema: {
83
- type: 'object',
84
- properties: {
85
- plan_id: {
86
- type: 'number',
87
- description: 'ID of the plan to update',
88
- },
89
- content: {
90
- type: 'string',
91
- description: 'New plan content (optional)',
92
- },
93
- status: {
94
- type: 'string',
95
- enum: ['draft', 'approved', 'in_progress', 'completed', 'abandoned'],
96
- description: 'New status (optional). Valid transitions: draft→approved, approved→in_progress, in_progress→completed. Any→abandoned. abandoned→draft.',
97
- },
98
- work_item_id: {
99
- type: ['number', 'null'],
100
- description: 'Work item ID to link (optional). Use null to unlink.',
101
- },
102
- },
103
- required: ['plan_id'],
104
- },
105
- execute: async (input) => {
106
- await Promise.resolve();
107
- try {
108
- const updateInput = {};
109
- if (input.content !== undefined) {
110
- updateInput.content = input.content;
111
- }
112
- if (input.status !== undefined) {
113
- updateInput.status = input.status;
114
- }
115
- if (input.work_item_id !== undefined) {
116
- updateInput.work_item_id = input.work_item_id;
117
- }
118
- const plan = planRepository.update(input.plan_id, updateInput);
119
- if (!plan) {
120
- return createErrorResult(`Plan with ID ${String(input.plan_id)} not found`);
121
- }
122
- return createSuccessResult({
123
- success: true,
124
- message: `Plan "${plan.name}" updated`,
125
- plan: {
126
- id: plan.id,
127
- name: plan.name,
128
- status: plan.status,
129
- workItemId: plan.workItemId,
130
- updatedAt: plan.updatedAt.toISOString(),
131
- },
132
- });
133
- }
134
- catch (error) {
135
- return createErrorResult(`Failed to update plan: ${error instanceof Error ? error.message : String(error)}`);
136
- }
137
- },
138
- });
139
- // =============================================================================
140
- // plan_get - Get a plan by ID or name
141
- // =============================================================================
142
- export const planGetTool = defineTool({
143
- name: 'plan_get',
144
- description: 'Get a plan by ID or name. Returns the full plan content and linked work item details.',
145
- inputSchema: {
146
- type: 'object',
147
- properties: {
148
- plan_id: {
149
- type: 'number',
150
- description: 'Plan ID (preferred)',
151
- },
152
- name: {
153
- type: 'string',
154
- description: 'Plan name (alternative to ID)',
155
- },
156
- project_id: {
157
- type: 'number',
158
- description: 'Project ID (required if using name, uses active project if not provided)',
159
- },
160
- },
161
- required: [],
162
- },
163
- execute: async (input) => {
164
- await Promise.resolve();
165
- try {
166
- let plan;
167
- if (input.plan_id) {
168
- plan = planRepository.getWithWorkItem(input.plan_id);
169
- }
170
- else if (input.name) {
171
- const projectId = input.project_id ?? getActiveProject()?.id;
172
- if (!projectId) {
173
- return createErrorResult('No project specified and no active project. Provide plan_id or project_id.');
174
- }
175
- const basePlan = planRepository.getByName(projectId, input.name);
176
- if (basePlan) {
177
- plan = planRepository.getWithWorkItem(basePlan.id);
178
- }
179
- }
180
- else {
181
- return createErrorResult('Either plan_id or name is required');
182
- }
183
- if (!plan) {
184
- return createSuccessResult({
185
- success: true,
186
- plan: null,
187
- message: 'Plan not found',
188
- });
189
- }
190
- return createSuccessResult({
191
- success: true,
192
- plan: {
193
- id: plan.id,
194
- name: plan.name,
195
- content: plan.content,
196
- status: plan.status,
197
- workItemId: plan.workItemId,
198
- workItem: plan.workItem
199
- ? {
200
- id: plan.workItem.id,
201
- itemId: plan.workItem.itemId,
202
- title: plan.workItem.title,
203
- status: plan.workItem.status,
204
- }
205
- : null,
206
- createdAt: plan.createdAt.toISOString(),
207
- updatedAt: plan.updatedAt.toISOString(),
208
- },
209
- });
210
- }
211
- catch (error) {
212
- return createErrorResult(`Failed to get plan: ${error instanceof Error ? error.message : String(error)}`);
213
- }
214
- },
215
- });
216
- // =============================================================================
217
- // plan_list - List plans for a project
218
- // =============================================================================
219
- export const planListTool = defineTool({
220
- name: 'plan_list',
221
- description: 'List plans for a project. Supports filtering by status and work item. Returns plan summaries without full content.',
222
- inputSchema: {
223
- type: 'object',
224
- properties: {
225
- project_id: {
226
- type: 'number',
227
- description: 'Project ID (uses active project if not provided)',
228
- },
229
- status: {
230
- type: 'string',
231
- enum: ['draft', 'approved', 'in_progress', 'completed', 'abandoned', 'all'],
232
- description: 'Filter by status (default: all)',
233
- },
234
- work_item_id: {
235
- type: 'number',
236
- description: 'Filter by linked work item',
237
- },
238
- limit: {
239
- type: 'number',
240
- description: 'Maximum plans to return (default: 20)',
241
- },
242
- order_by: {
243
- type: 'string',
244
- enum: ['updated_desc', 'updated_asc', 'created_desc', 'name_asc'],
245
- description: 'Sort order (default: updated_desc)',
246
- },
247
- },
248
- required: [],
249
- },
250
- execute: async (input) => {
251
- await Promise.resolve();
252
- try {
253
- const projectId = input.project_id ?? getActiveProject()?.id;
254
- if (!projectId) {
255
- return createErrorResult('No project specified and no active project. Use project_get or /projects to select a project first.');
256
- }
257
- const options = {
258
- limit: input.limit ?? 20,
259
- order_by: input.order_by ?? 'updated_desc',
260
- };
261
- if (input.status && input.status !== 'all') {
262
- options.status = input.status;
263
- }
264
- if (input.work_item_id !== undefined) {
265
- options.work_item_id = input.work_item_id;
266
- }
267
- const plans = planRepository.list(projectId, options);
268
- const counts = planRepository.countByStatus(projectId);
269
- const planSummaries = plans.map((plan) => ({
270
- id: plan.id,
271
- name: plan.name,
272
- status: plan.status,
273
- workItemId: plan.workItemId,
274
- workItemTitle: plan.workItemTitle,
275
- workItemItemId: plan.workItemItemId,
276
- updatedAt: plan.updatedAt.toISOString(),
277
- }));
278
- return createSuccessResult({
279
- success: true,
280
- plans: planSummaries,
281
- count: planSummaries.length,
282
- statusCounts: counts,
283
- projectId,
284
- });
285
- }
286
- catch (error) {
287
- return createErrorResult(`Failed to list plans: ${error instanceof Error ? error.message : String(error)}`);
288
- }
289
- },
290
- });
291
- // =============================================================================
292
- // plan_delete - Delete a plan
293
- // =============================================================================
294
- export const planDeleteTool = defineTool({
295
- name: 'plan_delete',
296
- description: 'Delete a plan by ID. This action cannot be undone.',
297
- inputSchema: {
298
- type: 'object',
299
- properties: {
300
- plan_id: {
301
- type: 'number',
302
- description: 'ID of the plan to delete',
303
- },
304
- },
305
- required: ['plan_id'],
306
- },
307
- execute: async (input) => {
308
- await Promise.resolve();
309
- try {
310
- // Get plan first to show name in message
311
- const plan = planRepository.getById(input.plan_id);
312
- if (!plan) {
313
- return createErrorResult(`Plan with ID ${String(input.plan_id)} not found`);
314
- }
315
- const deleted = planRepository.delete(input.plan_id);
316
- if (!deleted) {
317
- return createErrorResult(`Failed to delete plan "${plan.name}"`);
318
- }
319
- return createSuccessResult({
320
- success: true,
321
- message: `Plan "${plan.name}" deleted`,
322
- });
323
- }
324
- catch (error) {
325
- return createErrorResult(`Failed to delete plan: ${error instanceof Error ? error.message : String(error)}`);
326
- }
327
- },
328
- });
329
- // =============================================================================
330
- // All plan tools
331
- // =============================================================================
332
- export const planDbTools = [
333
- planCreateTool,
334
- planUpdateTool,
335
- planGetTool,
336
- planListTool,
337
- planDeleteTool,
338
- ];
@@ -1,18 +0,0 @@
1
- /**
2
- * recall_work Tool — Query Work History
3
- *
4
- * Lets agents proactively query episodic work history.
5
- * Returns episodes with agent attribution, effort level, and affected files.
6
- */
7
- interface RecallWorkInput {
8
- /** Filter by file paths (returns episodes touching any of these files) */
9
- files?: string[];
10
- /** Filter by agent ID */
11
- agentId?: string;
12
- /** Filter by session ID */
13
- sessionId?: string;
14
- /** Return N most recent episodes (default: 20) */
15
- recent?: number;
16
- }
17
- export declare const recallWorkTool: import("@compilr-dev/sdk").Tool<RecallWorkInput>;
18
- export {};
@@ -1,82 +0,0 @@
1
- /**
2
- * recall_work Tool — Query Work History
3
- *
4
- * Lets agents proactively query episodic work history.
5
- * Returns episodes with agent attribution, effort level, and affected files.
6
- */
7
- import { defineTool } from '@compilr-dev/sdk';
8
- import { getGlobalEpisodeStore } from '../episodes/index.js';
9
- // =============================================================================
10
- // Tool Definition
11
- // =============================================================================
12
- export const recallWorkTool = defineTool({
13
- name: 'recall_work',
14
- description: 'Query work history — episodes of what agents have done in this project. ' +
15
- 'Returns episodes with agent attribution, effort level, and affected files. ' +
16
- 'Use before destructive operations to check what work would be affected. ' +
17
- 'Use to understand what has been done in this session or by other agents.',
18
- inputSchema: {
19
- type: 'object',
20
- properties: {
21
- files: {
22
- type: 'array',
23
- items: { type: 'string' },
24
- description: 'Filter by file paths — returns episodes touching any of these files',
25
- },
26
- agentId: {
27
- type: 'string',
28
- description: 'Filter by agent ID (e.g., "default", "backend")',
29
- },
30
- sessionId: {
31
- type: 'string',
32
- description: 'Filter by session ID',
33
- },
34
- recent: {
35
- type: 'number',
36
- description: 'Return N most recent episodes (default: 20)',
37
- },
38
- },
39
- },
40
- execute: (input) => {
41
- const store = getGlobalEpisodeStore();
42
- if (!store) {
43
- return Promise.resolve({
44
- success: false,
45
- error: 'No episode store available (no active project)',
46
- });
47
- }
48
- let episodes;
49
- if (input.files && input.files.length > 0) {
50
- episodes = store.getByFiles(input.files);
51
- }
52
- else if (input.agentId) {
53
- episodes = store.getByAgent(input.agentId);
54
- }
55
- else if (input.sessionId) {
56
- episodes = store.getBySession(input.sessionId);
57
- }
58
- else {
59
- episodes = store.getRecent(input.recent ?? 20);
60
- }
61
- const summary = store.getWorkSummary();
62
- return Promise.resolve({
63
- success: true,
64
- result: {
65
- episodes: episodes.map(ep => ({
66
- id: ep.id,
67
- agentId: ep.agentId,
68
- terminalPrefix: ep.terminalPrefix,
69
- action: ep.action,
70
- summary: ep.summary,
71
- files: ep.files,
72
- effort: ep.effort,
73
- timestamp: ep.timestamp,
74
- toolCalls: ep.toolCalls,
75
- })),
76
- totalEpisodes: summary.episodeCount,
77
- totalEffort: summary.totalEffort,
78
- uncommittedCount: summary.uncommittedWork.length,
79
- },
80
- });
81
- },
82
- });
@@ -1,135 +0,0 @@
1
- /**
2
- * Work Item Database Tools
3
- *
4
- * Tools for managing work items (backlog items, tasks, bugs) in the database.
5
- */
6
- /**
7
- * workitem_query - Query work items with filters
8
- */
9
- export declare const workitemQueryTool: import("@compilr-dev/sdk").Tool<{
10
- project_id?: number;
11
- status?: string;
12
- type?: string;
13
- priority?: string;
14
- owner?: string;
15
- search?: string;
16
- limit?: number;
17
- offset?: number;
18
- }>;
19
- /**
20
- * workitem_add - Add a new work item
21
- */
22
- export declare const workitemAddTool: import("@compilr-dev/sdk").Tool<{
23
- project_id?: number;
24
- type: string;
25
- title: string;
26
- description?: string;
27
- priority?: string;
28
- estimated_effort?: string;
29
- owner?: string;
30
- }>;
31
- /**
32
- * workitem_update - Update a work item
33
- */
34
- export declare const workitemUpdateTool: import("@compilr-dev/sdk").Tool<{
35
- item_id: string;
36
- project_id?: number;
37
- status?: string;
38
- priority?: string;
39
- owner?: string;
40
- guided_step?: string;
41
- title?: string;
42
- description?: string;
43
- commit_hash?: string;
44
- }>;
45
- /**
46
- * workitem_next - Get the next work item to work on
47
- */
48
- export declare const workitemNextTool: import("@compilr-dev/sdk").Tool<{
49
- project_id?: number;
50
- type?: string;
51
- }>;
52
- /**
53
- * workitem_delete - Delete a work item
54
- */
55
- export declare const workitemDeleteTool: import("@compilr-dev/sdk").Tool<{
56
- item_id: string;
57
- project_id?: number;
58
- }>;
59
- /**
60
- * workitem_status_counts - Get work item counts by status
61
- */
62
- export declare const workitemStatusCountsTool: import("@compilr-dev/sdk").Tool<{
63
- project_id?: number;
64
- }>;
65
- /**
66
- * workitem_advance_step - Advance to the next guided workflow step
67
- */
68
- export declare const workitemAdvanceStepTool: import("@compilr-dev/sdk").Tool<{
69
- item_id: string;
70
- reason: string;
71
- force?: boolean;
72
- project_id?: number;
73
- }>;
74
- /**
75
- * workitem_claim - Claim an unassigned work item
76
- */
77
- export declare const workitemClaimTool: import("@compilr-dev/sdk").Tool<{
78
- item_id: string;
79
- agent_id: string;
80
- project_id?: number;
81
- }>;
82
- /**
83
- * workitem_handoff - Hand off a work item to another agent
84
- */
85
- export declare const workitemHandoffTool: import("@compilr-dev/sdk").Tool<{
86
- item_id: string;
87
- to_agent_id: string;
88
- notes?: string;
89
- project_id?: number;
90
- }>;
91
- /**
92
- * All work item tools
93
- */
94
- export declare const workitemDbTools: (import("@compilr-dev/sdk").Tool<{
95
- project_id?: number;
96
- status?: string;
97
- type?: string;
98
- priority?: string;
99
- owner?: string;
100
- search?: string;
101
- limit?: number;
102
- offset?: number;
103
- }> | import("@compilr-dev/sdk").Tool<{
104
- project_id?: number;
105
- type: string;
106
- title: string;
107
- description?: string;
108
- priority?: string;
109
- estimated_effort?: string;
110
- owner?: string;
111
- }> | import("@compilr-dev/sdk").Tool<{
112
- item_id: string;
113
- project_id?: number;
114
- status?: string;
115
- priority?: string;
116
- owner?: string;
117
- guided_step?: string;
118
- title?: string;
119
- description?: string;
120
- commit_hash?: string;
121
- }> | import("@compilr-dev/sdk").Tool<{
122
- item_id: string;
123
- reason: string;
124
- force?: boolean;
125
- project_id?: number;
126
- }> | import("@compilr-dev/sdk").Tool<{
127
- item_id: string;
128
- agent_id: string;
129
- project_id?: number;
130
- }> | import("@compilr-dev/sdk").Tool<{
131
- item_id: string;
132
- to_agent_id: string;
133
- notes?: string;
134
- project_id?: number;
135
- }>)[];