@compilr-dev/sdk 0.1.6 → 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 +136 -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,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Types — Canonical data model types for the compilr-dev ecosystem.
|
|
3
|
+
*
|
|
4
|
+
* These types define the storage-agnostic data models used across all platform
|
|
5
|
+
* clients (CLI, web UI, API). They are extracted from the CLI's SQLite-backed
|
|
6
|
+
* repositories and made async-compatible for future PostgreSQL support.
|
|
7
|
+
*
|
|
8
|
+
* Conventions:
|
|
9
|
+
* - Enums: string literal union types
|
|
10
|
+
* - Data models: camelCase properties (output types)
|
|
11
|
+
* - Input types: snake_case properties (matching CLI tool input schemas)
|
|
12
|
+
*/
|
|
13
|
+
export type ProjectType = 'general' | 'web' | 'cli' | 'library' | 'api';
|
|
14
|
+
export type ProjectStatus = 'active' | 'paused' | 'completed' | 'archived';
|
|
15
|
+
export type RepoPattern = 'single' | 'two-repo';
|
|
16
|
+
export type WorkflowMode = 'flexible' | 'guided';
|
|
17
|
+
export type LifecycleState = 'setup' | 'active' | 'maintenance' | 'complete';
|
|
18
|
+
export type WorkItemType = 'feature' | 'bug' | 'tech-debt' | 'chore';
|
|
19
|
+
export type WorkItemStatus = 'backlog' | 'in_progress' | 'completed' | 'skipped';
|
|
20
|
+
export type WorkItemPriority = 'critical' | 'high' | 'medium' | 'low';
|
|
21
|
+
export type GuidedStep = 'plan' | 'implement' | 'test' | 'commit' | 'review';
|
|
22
|
+
export type DocumentType = 'prd' | 'architecture' | 'design' | 'notes' | 'plan';
|
|
23
|
+
export type PlanStatus = 'draft' | 'approved' | 'in_progress' | 'completed' | 'abandoned';
|
|
24
|
+
export interface Project {
|
|
25
|
+
id: number;
|
|
26
|
+
name: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
description: string | null;
|
|
29
|
+
type: ProjectType;
|
|
30
|
+
status: ProjectStatus;
|
|
31
|
+
path: string;
|
|
32
|
+
docsPath: string | null;
|
|
33
|
+
repoPattern: RepoPattern;
|
|
34
|
+
language: string | null;
|
|
35
|
+
framework: string | null;
|
|
36
|
+
packageManager: string | null;
|
|
37
|
+
runtimeVersion: string | null;
|
|
38
|
+
commands: Record<string, string> | null;
|
|
39
|
+
gitRemote: string | null;
|
|
40
|
+
gitBranch: string;
|
|
41
|
+
workflowMode: WorkflowMode;
|
|
42
|
+
lifecycleState: LifecycleState;
|
|
43
|
+
currentItemId: string | null;
|
|
44
|
+
lastContext: Record<string, unknown> | null;
|
|
45
|
+
metadata: Record<string, unknown> | null;
|
|
46
|
+
createdAt: Date;
|
|
47
|
+
updatedAt: Date;
|
|
48
|
+
lastActivityAt: Date | null;
|
|
49
|
+
}
|
|
50
|
+
export interface WorkItem {
|
|
51
|
+
id: number;
|
|
52
|
+
projectId: number;
|
|
53
|
+
itemNumber: number;
|
|
54
|
+
itemId: string;
|
|
55
|
+
type: WorkItemType;
|
|
56
|
+
status: WorkItemStatus;
|
|
57
|
+
priority: WorkItemPriority;
|
|
58
|
+
guidedStep: GuidedStep | null;
|
|
59
|
+
owner: string | null;
|
|
60
|
+
title: string;
|
|
61
|
+
description: string | null;
|
|
62
|
+
estimatedEffort: string | null;
|
|
63
|
+
actualMinutes: number | null;
|
|
64
|
+
completedAt: Date | null;
|
|
65
|
+
completedBy: string | null;
|
|
66
|
+
commitHash: string | null;
|
|
67
|
+
createdAt: Date;
|
|
68
|
+
updatedAt: Date;
|
|
69
|
+
}
|
|
70
|
+
export interface ProjectDocument {
|
|
71
|
+
id: number;
|
|
72
|
+
projectId: number;
|
|
73
|
+
docType: DocumentType;
|
|
74
|
+
title: string;
|
|
75
|
+
content: string;
|
|
76
|
+
createdAt: Date;
|
|
77
|
+
updatedAt: Date;
|
|
78
|
+
status: string | null;
|
|
79
|
+
workItemId: number | null;
|
|
80
|
+
}
|
|
81
|
+
export interface Plan {
|
|
82
|
+
id: number;
|
|
83
|
+
projectId: number;
|
|
84
|
+
name: string;
|
|
85
|
+
content: string;
|
|
86
|
+
status: PlanStatus;
|
|
87
|
+
workItemId: number | null;
|
|
88
|
+
createdAt: Date;
|
|
89
|
+
updatedAt: Date;
|
|
90
|
+
}
|
|
91
|
+
export interface PlanSummary {
|
|
92
|
+
id: number;
|
|
93
|
+
name: string;
|
|
94
|
+
status: PlanStatus;
|
|
95
|
+
workItemId: number | null;
|
|
96
|
+
workItemTitle?: string;
|
|
97
|
+
workItemItemId?: string;
|
|
98
|
+
updatedAt: Date;
|
|
99
|
+
}
|
|
100
|
+
export interface PlanWithWorkItem extends Plan {
|
|
101
|
+
workItem?: {
|
|
102
|
+
id: number;
|
|
103
|
+
itemId: string;
|
|
104
|
+
title: string;
|
|
105
|
+
status: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export interface HistoryEntry {
|
|
109
|
+
action: string;
|
|
110
|
+
oldValue: string | null;
|
|
111
|
+
newValue: string | null;
|
|
112
|
+
notes: string | null;
|
|
113
|
+
changedBy: string | null;
|
|
114
|
+
changedAt: Date;
|
|
115
|
+
}
|
|
116
|
+
export interface CreateProjectInput {
|
|
117
|
+
name: string;
|
|
118
|
+
display_name: string;
|
|
119
|
+
description?: string;
|
|
120
|
+
type?: ProjectType;
|
|
121
|
+
path: string;
|
|
122
|
+
docs_path?: string;
|
|
123
|
+
repo_pattern?: RepoPattern;
|
|
124
|
+
language?: string;
|
|
125
|
+
framework?: string;
|
|
126
|
+
package_manager?: string;
|
|
127
|
+
runtime_version?: string;
|
|
128
|
+
commands?: Record<string, string>;
|
|
129
|
+
git_remote?: string;
|
|
130
|
+
git_branch?: string;
|
|
131
|
+
workflow_mode?: WorkflowMode;
|
|
132
|
+
metadata?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
export interface UpdateProjectInput {
|
|
135
|
+
display_name?: string;
|
|
136
|
+
description?: string;
|
|
137
|
+
type?: ProjectType;
|
|
138
|
+
status?: ProjectStatus;
|
|
139
|
+
docs_path?: string;
|
|
140
|
+
repo_pattern?: RepoPattern;
|
|
141
|
+
language?: string;
|
|
142
|
+
framework?: string;
|
|
143
|
+
package_manager?: string;
|
|
144
|
+
runtime_version?: string;
|
|
145
|
+
commands?: Record<string, string>;
|
|
146
|
+
git_remote?: string;
|
|
147
|
+
git_branch?: string;
|
|
148
|
+
workflow_mode?: WorkflowMode;
|
|
149
|
+
lifecycle_state?: LifecycleState;
|
|
150
|
+
current_item_id?: string | null;
|
|
151
|
+
last_context?: Record<string, unknown>;
|
|
152
|
+
metadata?: Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
export interface ProjectListOptions {
|
|
155
|
+
status?: ProjectStatus | 'all';
|
|
156
|
+
type?: ProjectType | 'all';
|
|
157
|
+
limit?: number;
|
|
158
|
+
offset?: number;
|
|
159
|
+
}
|
|
160
|
+
export interface CreateWorkItemInput {
|
|
161
|
+
project_id: number;
|
|
162
|
+
type: WorkItemType;
|
|
163
|
+
title: string;
|
|
164
|
+
description?: string;
|
|
165
|
+
priority?: WorkItemPriority;
|
|
166
|
+
estimated_effort?: 'low' | 'medium' | 'high';
|
|
167
|
+
owner?: string;
|
|
168
|
+
}
|
|
169
|
+
export interface UpdateWorkItemInput {
|
|
170
|
+
type?: WorkItemType;
|
|
171
|
+
status?: WorkItemStatus;
|
|
172
|
+
priority?: WorkItemPriority;
|
|
173
|
+
guided_step?: GuidedStep | null;
|
|
174
|
+
owner?: string | null;
|
|
175
|
+
title?: string;
|
|
176
|
+
description?: string;
|
|
177
|
+
estimated_effort?: 'low' | 'medium' | 'high';
|
|
178
|
+
actual_minutes?: number;
|
|
179
|
+
commit_hash?: string;
|
|
180
|
+
}
|
|
181
|
+
export interface QueryWorkItemsInput {
|
|
182
|
+
project_id?: number;
|
|
183
|
+
status?: WorkItemStatus | 'all';
|
|
184
|
+
type?: WorkItemType | 'all';
|
|
185
|
+
priority?: WorkItemPriority | 'all';
|
|
186
|
+
owner?: string;
|
|
187
|
+
search?: string;
|
|
188
|
+
limit?: number;
|
|
189
|
+
offset?: number;
|
|
190
|
+
}
|
|
191
|
+
export interface CreateDocumentInput {
|
|
192
|
+
project_id: number;
|
|
193
|
+
doc_type: DocumentType;
|
|
194
|
+
title: string;
|
|
195
|
+
content: string;
|
|
196
|
+
}
|
|
197
|
+
export interface UpdateDocumentInput {
|
|
198
|
+
title?: string;
|
|
199
|
+
content?: string;
|
|
200
|
+
}
|
|
201
|
+
export interface CreatePlanInput {
|
|
202
|
+
project_id: number;
|
|
203
|
+
name: string;
|
|
204
|
+
content: string;
|
|
205
|
+
work_item_id?: number;
|
|
206
|
+
}
|
|
207
|
+
export interface UpdatePlanInput {
|
|
208
|
+
content?: string;
|
|
209
|
+
status?: PlanStatus;
|
|
210
|
+
work_item_id?: number | null;
|
|
211
|
+
}
|
|
212
|
+
export interface ListPlansOptions {
|
|
213
|
+
status?: PlanStatus | PlanStatus[];
|
|
214
|
+
work_item_id?: number;
|
|
215
|
+
limit?: number;
|
|
216
|
+
order_by?: 'updated_desc' | 'updated_asc' | 'created_desc' | 'name_asc';
|
|
217
|
+
}
|
|
218
|
+
export interface WorkItemQueryResult {
|
|
219
|
+
items: WorkItem[];
|
|
220
|
+
total: number;
|
|
221
|
+
hasMore: boolean;
|
|
222
|
+
}
|
|
223
|
+
export interface ProjectListResult {
|
|
224
|
+
projects: Project[];
|
|
225
|
+
total: number;
|
|
226
|
+
}
|
|
227
|
+
export interface BulkCreateItem {
|
|
228
|
+
type: WorkItemType;
|
|
229
|
+
title: string;
|
|
230
|
+
description?: string;
|
|
231
|
+
priority?: WorkItemPriority;
|
|
232
|
+
owner?: string;
|
|
233
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform Types — Canonical data model types for the compilr-dev ecosystem.
|
|
3
|
+
*
|
|
4
|
+
* These types define the storage-agnostic data models used across all platform
|
|
5
|
+
* clients (CLI, web UI, API). They are extracted from the CLI's SQLite-backed
|
|
6
|
+
* repositories and made async-compatible for future PostgreSQL support.
|
|
7
|
+
*
|
|
8
|
+
* Conventions:
|
|
9
|
+
* - Enums: string literal union types
|
|
10
|
+
* - Data models: camelCase properties (output types)
|
|
11
|
+
* - Input types: snake_case properties (matching CLI tool input schemas)
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Step Criteria — Pure logic for guided workflow steps.
|
|
3
|
+
*
|
|
4
|
+
* Defines exit criteria, step ordering, and transition rules for the
|
|
5
|
+
* guided workflow (plan → implement → test → commit → review → complete).
|
|
6
|
+
*
|
|
7
|
+
* No DB or CLI dependencies — only imports GuidedStep from types.
|
|
8
|
+
*/
|
|
9
|
+
import type { GuidedStep } from './types.js';
|
|
10
|
+
export interface StepCriteria {
|
|
11
|
+
/** The guided step */
|
|
12
|
+
step: GuidedStep;
|
|
13
|
+
/** Human-readable exit criteria for system prompt */
|
|
14
|
+
exitCriteria: string[];
|
|
15
|
+
/** What agent looks for to determine success */
|
|
16
|
+
successIndicators: string[];
|
|
17
|
+
/** Maximum attempts for retryable steps (like test) */
|
|
18
|
+
maxAttempts?: number;
|
|
19
|
+
/** Can agent advance automatically when criteria met? */
|
|
20
|
+
autoAdvance: boolean;
|
|
21
|
+
/** Hint for next action after advancing */
|
|
22
|
+
nextActionHint: string;
|
|
23
|
+
}
|
|
24
|
+
/** Step order — defines valid step progression */
|
|
25
|
+
export declare const STEP_ORDER: readonly GuidedStep[];
|
|
26
|
+
/** Guided step criteria definitions */
|
|
27
|
+
export declare const GUIDED_STEP_CRITERIA: readonly StepCriteria[];
|
|
28
|
+
/** Get the next step in the workflow */
|
|
29
|
+
export declare function getNextStep(current: GuidedStep | null): GuidedStep | 'complete';
|
|
30
|
+
/** Get step number (1-indexed for display) */
|
|
31
|
+
export declare function getStepNumber(step: GuidedStep): number;
|
|
32
|
+
/** Check if step transition is valid (can only advance to next step) */
|
|
33
|
+
export declare function isValidTransition(from: GuidedStep | null, to: GuidedStep | 'complete'): boolean;
|
|
34
|
+
/** Get criteria for a specific step */
|
|
35
|
+
export declare function getStepCriteria(step: GuidedStep): StepCriteria;
|
|
36
|
+
/** Format step for display (e.g., "IMPLEMENT (2 of 5)") */
|
|
37
|
+
export declare function formatStepDisplay(step: GuidedStep): string;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Step Criteria — Pure logic for guided workflow steps.
|
|
3
|
+
*
|
|
4
|
+
* Defines exit criteria, step ordering, and transition rules for the
|
|
5
|
+
* guided workflow (plan → implement → test → commit → review → complete).
|
|
6
|
+
*
|
|
7
|
+
* No DB or CLI dependencies — only imports GuidedStep from types.
|
|
8
|
+
*/
|
|
9
|
+
// =============================================================================
|
|
10
|
+
// Constants
|
|
11
|
+
// =============================================================================
|
|
12
|
+
/** Step order — defines valid step progression */
|
|
13
|
+
export const STEP_ORDER = [
|
|
14
|
+
'plan',
|
|
15
|
+
'implement',
|
|
16
|
+
'test',
|
|
17
|
+
'commit',
|
|
18
|
+
'review',
|
|
19
|
+
];
|
|
20
|
+
/** Guided step criteria definitions */
|
|
21
|
+
export const GUIDED_STEP_CRITERIA = [
|
|
22
|
+
{
|
|
23
|
+
step: 'plan',
|
|
24
|
+
exitCriteria: [
|
|
25
|
+
'Requirements understood and documented',
|
|
26
|
+
'Approach designed (files to create/modify identified)',
|
|
27
|
+
'Edge cases considered',
|
|
28
|
+
],
|
|
29
|
+
successIndicators: [
|
|
30
|
+
'Agent has written a plan in conversation or document',
|
|
31
|
+
'Agent has identified target files',
|
|
32
|
+
'No blocking questions remain',
|
|
33
|
+
],
|
|
34
|
+
autoAdvance: true,
|
|
35
|
+
nextActionHint: 'Start implementing the planned changes',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
step: 'implement',
|
|
39
|
+
exitCriteria: [
|
|
40
|
+
'All planned code changes completed',
|
|
41
|
+
'No placeholder TODOs left',
|
|
42
|
+
'Code compiles/lints cleanly',
|
|
43
|
+
],
|
|
44
|
+
successIndicators: [
|
|
45
|
+
'writeFile/edit tools have been called',
|
|
46
|
+
'Lint command passes (if available)',
|
|
47
|
+
'No obvious errors in code',
|
|
48
|
+
],
|
|
49
|
+
autoAdvance: true,
|
|
50
|
+
nextActionHint: 'Run tests to verify the implementation',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
step: 'test',
|
|
54
|
+
exitCriteria: ['All tests pass', 'OR: User overrides after 2 failed attempts'],
|
|
55
|
+
successIndicators: ['Test command exits with 0', 'All test assertions pass'],
|
|
56
|
+
maxAttempts: 2,
|
|
57
|
+
autoAdvance: true,
|
|
58
|
+
nextActionHint: 'Commit the changes with a proper message',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
step: 'commit',
|
|
62
|
+
exitCriteria: ['Changes committed with proper message', 'Commit hash captured'],
|
|
63
|
+
successIndicators: ['git commit command succeeded', 'Commit hash in output'],
|
|
64
|
+
autoAdvance: true,
|
|
65
|
+
nextActionHint: 'Review and confirm ready for next item',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
step: 'review',
|
|
69
|
+
exitCriteria: ['User confirms ready for next item', 'OR: User wants to do something else'],
|
|
70
|
+
successIndicators: ['User says "yes", "next", "continue"', 'User explicitly approves'],
|
|
71
|
+
autoAdvance: false,
|
|
72
|
+
nextActionHint: 'Pick the next work item from backlog',
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
// =============================================================================
|
|
76
|
+
// Functions
|
|
77
|
+
// =============================================================================
|
|
78
|
+
/** Get the next step in the workflow */
|
|
79
|
+
export function getNextStep(current) {
|
|
80
|
+
if (current === null)
|
|
81
|
+
return 'plan';
|
|
82
|
+
const idx = STEP_ORDER.indexOf(current);
|
|
83
|
+
if (idx === -1 || idx >= STEP_ORDER.length - 1)
|
|
84
|
+
return 'complete';
|
|
85
|
+
return STEP_ORDER[idx + 1];
|
|
86
|
+
}
|
|
87
|
+
/** Get step number (1-indexed for display) */
|
|
88
|
+
export function getStepNumber(step) {
|
|
89
|
+
return STEP_ORDER.indexOf(step) + 1;
|
|
90
|
+
}
|
|
91
|
+
/** Check if step transition is valid (can only advance to next step) */
|
|
92
|
+
export function isValidTransition(from, to) {
|
|
93
|
+
const nextStep = getNextStep(from);
|
|
94
|
+
return nextStep === to;
|
|
95
|
+
}
|
|
96
|
+
/** Get criteria for a specific step */
|
|
97
|
+
export function getStepCriteria(step) {
|
|
98
|
+
const criteria = GUIDED_STEP_CRITERIA.find((c) => c.step === step);
|
|
99
|
+
if (!criteria) {
|
|
100
|
+
throw new Error(`No criteria found for step: ${step}`);
|
|
101
|
+
}
|
|
102
|
+
return criteria;
|
|
103
|
+
}
|
|
104
|
+
/** Format step for display (e.g., "IMPLEMENT (2 of 5)") */
|
|
105
|
+
export function formatStepDisplay(step) {
|
|
106
|
+
const num = getStepNumber(step);
|
|
107
|
+
return `${step.toUpperCase()} (${String(num)} of ${String(STEP_ORDER.length)})`;
|
|
108
|
+
}
|