mycontext-cli 2.0.25 → 2.0.27
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 +184 -37
- package/dist/cli.js +92 -80
- package/dist/cli.js.map +1 -1
- package/dist/commands/build-app.d.ts +6 -1
- package/dist/commands/build-app.d.ts.map +1 -1
- package/dist/commands/build-app.js +97 -9
- package/dist/commands/build-app.js.map +1 -1
- package/dist/commands/compile-prd.d.ts.map +1 -1
- package/dist/commands/compile-prd.js +7 -0
- package/dist/commands/compile-prd.js.map +1 -1
- package/dist/commands/export-progress.d.ts +34 -0
- package/dist/commands/export-progress.d.ts.map +1 -0
- package/dist/commands/export-progress.js +552 -0
- package/dist/commands/export-progress.js.map +1 -0
- package/dist/commands/generate-context-files.d.ts.map +1 -1
- package/dist/commands/generate-context-files.js +10 -2
- package/dist/commands/generate-context-files.js.map +1 -1
- package/dist/commands/generate.d.ts +8 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +212 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/help.d.ts +17 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +329 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/import-project-plan.d.ts +27 -0
- package/dist/commands/import-project-plan.d.ts.map +1 -0
- package/dist/commands/import-project-plan.js +411 -0
- package/dist/commands/import-project-plan.js.map +1 -0
- package/dist/commands/pm-integration.d.ts +18 -0
- package/dist/commands/pm-integration.d.ts.map +1 -0
- package/dist/commands/pm-integration.js +385 -0
- package/dist/commands/pm-integration.js.map +1 -0
- package/dist/commands/setup-complete.d.ts +16 -0
- package/dist/commands/setup-complete.d.ts.map +1 -0
- package/dist/commands/setup-complete.js +468 -0
- package/dist/commands/setup-complete.js.map +1 -0
- package/dist/commands/setup-shadcn.d.ts +20 -0
- package/dist/commands/setup-shadcn.d.ts.map +1 -0
- package/dist/commands/setup-shadcn.js +241 -0
- package/dist/commands/setup-shadcn.js.map +1 -0
- package/dist/commands/suggest.d.ts +15 -0
- package/dist/commands/suggest.d.ts.map +1 -0
- package/dist/commands/suggest.js +288 -0
- package/dist/commands/suggest.js.map +1 -0
- package/dist/commands/update.d.ts +0 -4
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +7 -197
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/workflow.d.ts +16 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +464 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/package.json +1 -1
- package/dist/services/PMIntegrationService.d.ts +46 -0
- package/dist/services/PMIntegrationService.d.ts.map +1 -0
- package/dist/services/PMIntegrationService.js +363 -0
- package/dist/services/PMIntegrationService.js.map +1 -0
- package/dist/services/WebhookServer.d.ts +37 -0
- package/dist/services/WebhookServer.d.ts.map +1 -0
- package/dist/services/WebhookServer.js +231 -0
- package/dist/services/WebhookServer.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/pm-integration.d.ts +241 -0
- package/dist/types/pm-integration.d.ts.map +1 -0
- package/dist/types/pm-integration.js +24 -0
- package/dist/types/pm-integration.js.map +1 -0
- package/dist/utils/NextJSProjectValidator.d.ts.map +1 -1
- package/dist/utils/NextJSProjectValidator.js +14 -7
- package/dist/utils/NextJSProjectValidator.js.map +1 -1
- package/dist/utils/ProjectStateAnalyzer.d.ts +46 -0
- package/dist/utils/ProjectStateAnalyzer.d.ts.map +1 -0
- package/dist/utils/ProjectStateAnalyzer.js +311 -0
- package/dist/utils/ProjectStateAnalyzer.js.map +1 -0
- package/dist/utils/ProjectStructureValidator.d.ts +12 -0
- package/dist/utils/ProjectStructureValidator.d.ts.map +1 -1
- package/dist/utils/ProjectStructureValidator.js +111 -14
- package/dist/utils/ProjectStructureValidator.js.map +1 -1
- package/dist/utils/claudeAgentClient.d.ts +4 -0
- package/dist/utils/claudeAgentClient.d.ts.map +1 -1
- package/dist/utils/claudeAgentClient.js +90 -20
- package/dist/utils/claudeAgentClient.js.map +1 -1
- package/dist/utils/errorHandler.d.ts +31 -74
- package/dist/utils/errorHandler.d.ts.map +1 -1
- package/dist/utils/errorHandler.js +190 -276
- package/dist/utils/errorHandler.js.map +1 -1
- package/dist/utils/hybridAIClient.js +1 -1
- package/dist/utils/hybridAIClient.js.map +1 -1
- package/dist/utils/mcpTools.d.ts +9 -9
- package/dist/utils/nextStepsSuggester.d.ts +52 -0
- package/dist/utils/nextStepsSuggester.d.ts.map +1 -0
- package/dist/utils/nextStepsSuggester.js +438 -0
- package/dist/utils/nextStepsSuggester.js.map +1 -0
- package/dist/utils/progress.d.ts +31 -1
- package/dist/utils/progress.d.ts.map +1 -1
- package/dist/utils/progress.js +110 -2
- package/dist/utils/progress.js.map +1 -1
- package/dist/utils/workflowEngine.d.ts +96 -0
- package/dist/utils/workflowEngine.d.ts.map +1 -0
- package/dist/utils/workflowEngine.js +793 -0
- package/dist/utils/workflowEngine.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,793 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.WorkflowEngine = void 0;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs-extra"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const nextStepsSuggester_1 = require("./nextStepsSuggester");
|
|
44
|
+
class WorkflowEngine {
|
|
45
|
+
/**
|
|
46
|
+
* Register a workflow definition
|
|
47
|
+
*/
|
|
48
|
+
static registerWorkflow(workflow) {
|
|
49
|
+
this.workflows.set(workflow.id, workflow);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all available workflows
|
|
53
|
+
*/
|
|
54
|
+
static getWorkflows() {
|
|
55
|
+
return Array.from(this.workflows.values());
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get a specific workflow by ID
|
|
59
|
+
*/
|
|
60
|
+
static getWorkflow(workflowId) {
|
|
61
|
+
return this.workflows.get(workflowId);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Start a workflow for a project
|
|
65
|
+
*/
|
|
66
|
+
static async startWorkflow(workflowId, projectRoot = process.cwd(), autoContinue = false) {
|
|
67
|
+
const workflow = this.workflows.get(workflowId);
|
|
68
|
+
if (!workflow) {
|
|
69
|
+
throw new Error(`Workflow '${workflowId}' not found`);
|
|
70
|
+
}
|
|
71
|
+
const context = await nextStepsSuggester_1.NextStepsSuggester.getWorkflowContext(projectRoot);
|
|
72
|
+
const progress = {
|
|
73
|
+
workflowId,
|
|
74
|
+
completedSteps: [],
|
|
75
|
+
startedAt: new Date(),
|
|
76
|
+
context,
|
|
77
|
+
};
|
|
78
|
+
// Check if there's already a saved workflow for this project
|
|
79
|
+
const existingProgress = await this.loadWorkflowState(projectRoot);
|
|
80
|
+
if (existingProgress && !existingProgress.completed) {
|
|
81
|
+
console.log(chalk_1.default.yellow("⚠️ Found existing workflow progress. Use 'workflow continue' to resume or 'workflow stop' to start fresh."));
|
|
82
|
+
throw new Error("Existing workflow in progress. Use 'workflow continue' to resume.");
|
|
83
|
+
}
|
|
84
|
+
// Calculate estimated completion time
|
|
85
|
+
const totalTime = workflow.estimatedTotalTime;
|
|
86
|
+
progress.estimatedCompletion = new Date(Date.now() + totalTime * 60 * 1000);
|
|
87
|
+
this.activeWorkflows.set(`${workflowId}:${projectRoot}`, progress);
|
|
88
|
+
// Save to disk
|
|
89
|
+
await this.saveWorkflowState(projectRoot, progress);
|
|
90
|
+
console.log(chalk_1.default.blue(`🚀 Starting workflow: ${workflow.name}`));
|
|
91
|
+
console.log(chalk_1.default.gray(workflow.description));
|
|
92
|
+
console.log(chalk_1.default.gray(`Estimated time: ${totalTime} minutes`));
|
|
93
|
+
console.log();
|
|
94
|
+
// Start with the first step
|
|
95
|
+
await this.executeNextStep(progress, projectRoot, autoContinue);
|
|
96
|
+
return progress;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Execute the next step in a workflow
|
|
100
|
+
*/
|
|
101
|
+
static async executeNextStep(progress, projectRoot, autoContinue) {
|
|
102
|
+
const workflow = this.workflows.get(progress.workflowId);
|
|
103
|
+
if (!workflow)
|
|
104
|
+
return;
|
|
105
|
+
const nextStep = this.getNextStep(workflow, progress);
|
|
106
|
+
if (!nextStep) {
|
|
107
|
+
// Workflow complete
|
|
108
|
+
this.completeWorkflow(progress);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
progress.currentStepId = nextStep.id;
|
|
112
|
+
const stepNumber = progress.completedSteps.length + 1;
|
|
113
|
+
console.log(chalk_1.default.cyan(`📋 Step ${stepNumber}/${workflow.steps.length}: ${nextStep.name}`));
|
|
114
|
+
console.log(chalk_1.default.gray(nextStep.description));
|
|
115
|
+
console.log(chalk_1.default.gray(`⏱️ Estimated time: ${nextStep.estimatedTime} minutes`));
|
|
116
|
+
// Calculate and display ETA
|
|
117
|
+
const remainingSteps = workflow.steps.length - progress.completedSteps.length;
|
|
118
|
+
const totalRemainingTime = workflow.steps
|
|
119
|
+
.filter((step) => !progress.completedSteps.includes(step.id))
|
|
120
|
+
.reduce((sum, step) => sum + (step.estimatedTime || 5), 0);
|
|
121
|
+
if (remainingSteps > 1) {
|
|
122
|
+
const eta = new Date(Date.now() + totalRemainingTime * 60 * 1000);
|
|
123
|
+
console.log(chalk_1.default.gray(`🎯 ETA: ${eta.toLocaleTimeString()}`));
|
|
124
|
+
}
|
|
125
|
+
console.log();
|
|
126
|
+
if (autoContinue && nextStep.autoContinue) {
|
|
127
|
+
console.log(chalk_1.default.yellow(`⚡ Auto-executing: ${nextStep.command}`));
|
|
128
|
+
console.log();
|
|
129
|
+
const stepStartTime = Date.now();
|
|
130
|
+
try {
|
|
131
|
+
await this.executeCommand(nextStep.command, projectRoot);
|
|
132
|
+
const stepDuration = Date.now() - stepStartTime;
|
|
133
|
+
const durationText = stepDuration > 60000
|
|
134
|
+
? `${(stepDuration / 60000).toFixed(1)}m`
|
|
135
|
+
: `${(stepDuration / 1000).toFixed(1)}s`;
|
|
136
|
+
progress.completedSteps.push(nextStep.id);
|
|
137
|
+
progress.currentStepId = undefined;
|
|
138
|
+
// Save progress to disk
|
|
139
|
+
await this.saveWorkflowState(projectRoot, progress);
|
|
140
|
+
console.log(chalk_1.default.green(`✅ Completed in ${durationText}`));
|
|
141
|
+
console.log();
|
|
142
|
+
// Continue to next step
|
|
143
|
+
await this.executeNextStep(progress, projectRoot, autoContinue);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.log(chalk_1.default.red(`❌ Step failed: ${error}`));
|
|
147
|
+
console.log(chalk_1.default.yellow(`💡 Manual execution: ${nextStep.command}`));
|
|
148
|
+
console.log();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
console.log(chalk_1.default.yellow(`💡 Execute: ${nextStep.command}`));
|
|
153
|
+
console.log(chalk_1.default.gray(`Then run: mycontext workflow continue`));
|
|
154
|
+
console.log();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Continue an active workflow
|
|
159
|
+
*/
|
|
160
|
+
static async continueWorkflow(projectRoot = process.cwd()) {
|
|
161
|
+
let activeWorkflow = this.findActiveWorkflow(projectRoot);
|
|
162
|
+
// If not in memory, try to load from disk
|
|
163
|
+
if (!activeWorkflow) {
|
|
164
|
+
const loadedWorkflow = await this.loadWorkflowState(projectRoot);
|
|
165
|
+
if (loadedWorkflow) {
|
|
166
|
+
activeWorkflow = loadedWorkflow;
|
|
167
|
+
// Restore to memory
|
|
168
|
+
const key = `${activeWorkflow.workflowId}:${projectRoot}`;
|
|
169
|
+
this.activeWorkflows.set(key, activeWorkflow);
|
|
170
|
+
console.log(chalk_1.default.green("📂 Resumed workflow from saved state"));
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!activeWorkflow) {
|
|
174
|
+
console.log(chalk_1.default.red("❌ No active workflow found"));
|
|
175
|
+
console.log(chalk_1.default.gray("Start a workflow with: mycontext workflow start <workflow-id>"));
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
await this.executeNextStep(activeWorkflow, projectRoot, false);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get the next step to execute
|
|
182
|
+
*/
|
|
183
|
+
static getNextStep(workflow, progress) {
|
|
184
|
+
// Find steps that haven't been completed and have all dependencies met
|
|
185
|
+
for (const step of workflow.steps) {
|
|
186
|
+
if (progress.completedSteps.includes(step.id))
|
|
187
|
+
continue;
|
|
188
|
+
// Check if all dependencies are completed
|
|
189
|
+
const dependenciesMet = step.dependencies.every((dep) => progress.completedSteps.includes(dep));
|
|
190
|
+
if (dependenciesMet) {
|
|
191
|
+
// Check if required context is available
|
|
192
|
+
if (step.requiredContext) {
|
|
193
|
+
const contextMatch = Object.entries(step.requiredContext).every(([key, value]) => {
|
|
194
|
+
return progress.context[key] === value;
|
|
195
|
+
});
|
|
196
|
+
if (!contextMatch && !step.optional)
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
return step;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Execute a command
|
|
206
|
+
*/
|
|
207
|
+
static async executeCommand(command, projectRoot) {
|
|
208
|
+
const { spawn } = await Promise.resolve().then(() => __importStar(require("child_process")));
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
const parts = command.split(" ");
|
|
211
|
+
const cmd = parts[0];
|
|
212
|
+
const args = parts.slice(1);
|
|
213
|
+
if (!cmd) {
|
|
214
|
+
reject(new Error("Invalid command"));
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
const child = spawn(cmd, args, {
|
|
218
|
+
cwd: projectRoot,
|
|
219
|
+
stdio: "inherit",
|
|
220
|
+
shell: true,
|
|
221
|
+
});
|
|
222
|
+
child.on("close", (code) => {
|
|
223
|
+
if (code === 0) {
|
|
224
|
+
resolve();
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
reject(new Error(`Command failed with exit code ${code}`));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
child.on("error", (error) => {
|
|
231
|
+
reject(error);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Complete a workflow
|
|
237
|
+
*/
|
|
238
|
+
static completeWorkflow(progress) {
|
|
239
|
+
const workflow = this.workflows.get(progress.workflowId);
|
|
240
|
+
if (!workflow)
|
|
241
|
+
return;
|
|
242
|
+
const duration = Date.now() - progress.startedAt.getTime();
|
|
243
|
+
const minutes = Math.round(duration / (1000 * 60));
|
|
244
|
+
console.log(chalk_1.default.green(`🎉 Workflow completed: ${workflow.name}`));
|
|
245
|
+
console.log(chalk_1.default.gray(`Total time: ${minutes} minutes`));
|
|
246
|
+
console.log(chalk_1.default.gray(`Steps completed: ${progress.completedSteps.length}/${workflow.steps.length}`));
|
|
247
|
+
console.log();
|
|
248
|
+
// Clean up
|
|
249
|
+
this.activeWorkflows.delete(`${progress.workflowId}:${progress.context.projectType || "default"}`);
|
|
250
|
+
// Clear saved state
|
|
251
|
+
this.clearWorkflowState(process.cwd());
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Find active workflow for a project
|
|
255
|
+
*/
|
|
256
|
+
static findActiveWorkflow(projectRoot) {
|
|
257
|
+
// Try to find by exact project root first
|
|
258
|
+
for (const [key, progress] of this.activeWorkflows) {
|
|
259
|
+
if (key.endsWith(`:${projectRoot}`) || key.endsWith(":default")) {
|
|
260
|
+
return progress;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return undefined;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Get workflow status
|
|
267
|
+
*/
|
|
268
|
+
static getWorkflowStatus(projectRoot = process.cwd()) {
|
|
269
|
+
return this.findActiveWorkflow(projectRoot) || null;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Stop an active workflow
|
|
273
|
+
*/
|
|
274
|
+
static async stopWorkflow(projectRoot = process.cwd()) {
|
|
275
|
+
const activeWorkflow = this.findActiveWorkflow(projectRoot);
|
|
276
|
+
if (activeWorkflow) {
|
|
277
|
+
console.log(chalk_1.default.yellow(`⏹️ Stopped workflow: ${activeWorkflow.workflowId}`));
|
|
278
|
+
this.activeWorkflows.delete(`${activeWorkflow.workflowId}:${projectRoot}`);
|
|
279
|
+
// Clear saved state
|
|
280
|
+
await this.clearWorkflowState(projectRoot);
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
console.log(chalk_1.default.gray("No active workflow to stop"));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Save workflow state to disk
|
|
288
|
+
*/
|
|
289
|
+
static async saveWorkflowState(projectRoot, progress) {
|
|
290
|
+
try {
|
|
291
|
+
const stateFile = path.join(projectRoot, this.WORKFLOW_STATE_FILE);
|
|
292
|
+
const stateDir = path.dirname(stateFile);
|
|
293
|
+
// Ensure directory exists
|
|
294
|
+
await fs.ensureDir(stateDir);
|
|
295
|
+
// Save workflow state
|
|
296
|
+
await fs.writeJson(stateFile, {
|
|
297
|
+
...progress,
|
|
298
|
+
lastSaved: new Date().toISOString(),
|
|
299
|
+
}, { spaces: 2 });
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
// Ignore save errors to avoid disrupting workflow
|
|
303
|
+
console.warn(`Failed to save workflow state: ${error}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Load workflow state from disk
|
|
308
|
+
*/
|
|
309
|
+
static async loadWorkflowState(projectRoot) {
|
|
310
|
+
try {
|
|
311
|
+
const stateFile = path.join(projectRoot, this.WORKFLOW_STATE_FILE);
|
|
312
|
+
if (!(await fs.pathExists(stateFile))) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
const state = await fs.readJson(stateFile);
|
|
316
|
+
// Validate loaded state
|
|
317
|
+
if (!state.workflowId || !state.completedSteps || !state.context) {
|
|
318
|
+
console.warn("Invalid workflow state file, ignoring");
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
// Restore dates
|
|
322
|
+
state.startedAt = new Date(state.startedAt);
|
|
323
|
+
if (state.estimatedCompletion) {
|
|
324
|
+
state.estimatedCompletion = new Date(state.estimatedCompletion);
|
|
325
|
+
}
|
|
326
|
+
return state;
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
console.warn(`Failed to load workflow state: ${error}`);
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Clear saved workflow state
|
|
335
|
+
*/
|
|
336
|
+
static async clearWorkflowState(projectRoot) {
|
|
337
|
+
try {
|
|
338
|
+
const stateFile = path.join(projectRoot, this.WORKFLOW_STATE_FILE);
|
|
339
|
+
if (await fs.pathExists(stateFile)) {
|
|
340
|
+
await fs.remove(stateFile);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
// Ignore cleanup errors
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
exports.WorkflowEngine = WorkflowEngine;
|
|
349
|
+
WorkflowEngine.workflows = new Map();
|
|
350
|
+
WorkflowEngine.activeWorkflows = new Map();
|
|
351
|
+
WorkflowEngine.WORKFLOW_STATE_FILE = ".mycontext/workflow-state.json";
|
|
352
|
+
// Register built-in workflows
|
|
353
|
+
WorkflowEngine.registerWorkflow({
|
|
354
|
+
id: "complete-setup",
|
|
355
|
+
name: "Complete Project Setup",
|
|
356
|
+
description: "Set up a new MyContext project from scratch to production-ready",
|
|
357
|
+
category: "setup",
|
|
358
|
+
estimatedTotalTime: 45,
|
|
359
|
+
steps: [
|
|
360
|
+
{
|
|
361
|
+
id: "init",
|
|
362
|
+
name: "Initialize Project",
|
|
363
|
+
description: "Create project structure and basic configuration",
|
|
364
|
+
command: "mycontext init . --framework instantdb",
|
|
365
|
+
dependencies: [],
|
|
366
|
+
autoContinue: true,
|
|
367
|
+
estimatedTime: 5,
|
|
368
|
+
estimatedDuration: 300000, // 5 minutes
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
id: "setup-shadcn",
|
|
372
|
+
name: "Set Up shadcn/ui",
|
|
373
|
+
description: "Install and configure shadcn/ui components",
|
|
374
|
+
command: "mycontext setup-shadcn --all",
|
|
375
|
+
dependencies: ["init"],
|
|
376
|
+
autoContinue: true,
|
|
377
|
+
estimatedTime: 8,
|
|
378
|
+
estimatedDuration: 480000, // 8 minutes
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
id: "compile-prd",
|
|
382
|
+
name: "Compile PRD",
|
|
383
|
+
description: "Generate comprehensive PRD from context files",
|
|
384
|
+
command: "mycontext compile-prd",
|
|
385
|
+
dependencies: ["init"],
|
|
386
|
+
autoContinue: true,
|
|
387
|
+
estimatedTime: 3,
|
|
388
|
+
estimatedDuration: 180000, // 3 minutes
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
id: "generate-types",
|
|
392
|
+
name: "Generate Types",
|
|
393
|
+
description: "Create TypeScript types from PRD",
|
|
394
|
+
command: "mycontext generate types",
|
|
395
|
+
dependencies: ["compile-prd"],
|
|
396
|
+
autoContinue: true,
|
|
397
|
+
estimatedTime: 5,
|
|
398
|
+
estimatedDuration: 300000, // 5 minutes
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: "generate-brand",
|
|
402
|
+
name: "Generate Brand Guidelines",
|
|
403
|
+
description: "Create brand guidelines and design tokens",
|
|
404
|
+
command: "mycontext generate brand",
|
|
405
|
+
dependencies: ["compile-prd"],
|
|
406
|
+
autoContinue: true,
|
|
407
|
+
estimatedTime: 3,
|
|
408
|
+
estimatedDuration: 180000, // 3 minutes
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
id: "generate-component-list",
|
|
412
|
+
name: "Generate Component List",
|
|
413
|
+
description: "Create comprehensive component list",
|
|
414
|
+
command: "mycontext generate component-list",
|
|
415
|
+
dependencies: ["generate-types"],
|
|
416
|
+
autoContinue: true,
|
|
417
|
+
estimatedTime: 4,
|
|
418
|
+
estimatedDuration: 240000, // 4 minutes
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
id: "generate-components",
|
|
422
|
+
name: "Generate Components",
|
|
423
|
+
description: "Generate all React components with tests",
|
|
424
|
+
command: "mycontext generate-components all --with-tests",
|
|
425
|
+
dependencies: ["generate-component-list", "setup-shadcn"],
|
|
426
|
+
autoContinue: true,
|
|
427
|
+
estimatedTime: 15,
|
|
428
|
+
estimatedDuration: 900000, // 15 minutes
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
id: "validate",
|
|
432
|
+
name: "Validate Project",
|
|
433
|
+
description: "Run comprehensive project validation",
|
|
434
|
+
command: "mycontext validate",
|
|
435
|
+
dependencies: ["generate-components"],
|
|
436
|
+
autoContinue: false,
|
|
437
|
+
estimatedTime: 2,
|
|
438
|
+
estimatedDuration: 120000, // 2 minutes
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
});
|
|
442
|
+
WorkflowEngine.registerWorkflow({
|
|
443
|
+
id: "component-development",
|
|
444
|
+
name: "Component Development",
|
|
445
|
+
description: "Develop and refine React components",
|
|
446
|
+
category: "development",
|
|
447
|
+
estimatedTotalTime: 25,
|
|
448
|
+
steps: [
|
|
449
|
+
{
|
|
450
|
+
id: "generate-component",
|
|
451
|
+
name: "Generate Component",
|
|
452
|
+
description: "Generate a specific component",
|
|
453
|
+
command: "mycontext generate-components Button",
|
|
454
|
+
dependencies: [],
|
|
455
|
+
autoContinue: true,
|
|
456
|
+
estimatedTime: 3,
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
id: "preview-component",
|
|
460
|
+
name: "Preview Component",
|
|
461
|
+
description: "Preview component in development environment",
|
|
462
|
+
command: "mycontext preview components",
|
|
463
|
+
dependencies: ["generate-component"],
|
|
464
|
+
autoContinue: true,
|
|
465
|
+
estimatedTime: 2,
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
id: "validate-component",
|
|
469
|
+
name: "Validate Component",
|
|
470
|
+
description: "Run validation on generated component",
|
|
471
|
+
command: "mycontext validate --component Button",
|
|
472
|
+
dependencies: ["generate-component"],
|
|
473
|
+
autoContinue: false,
|
|
474
|
+
estimatedTime: 1,
|
|
475
|
+
},
|
|
476
|
+
],
|
|
477
|
+
});
|
|
478
|
+
WorkflowEngine.registerWorkflow({
|
|
479
|
+
id: "ecommerce-setup",
|
|
480
|
+
name: "E-commerce Application Setup",
|
|
481
|
+
description: "Complete setup for e-commerce applications with shopping cart, products, and checkout",
|
|
482
|
+
category: "setup",
|
|
483
|
+
estimatedTotalTime: 50,
|
|
484
|
+
steps: [
|
|
485
|
+
{
|
|
486
|
+
id: "init",
|
|
487
|
+
name: "Initialize E-commerce Project",
|
|
488
|
+
description: "Create project structure for e-commerce application",
|
|
489
|
+
command: "mycontext init . --framework instantdb --description 'E-commerce application with shopping cart and checkout'",
|
|
490
|
+
dependencies: [],
|
|
491
|
+
autoContinue: true,
|
|
492
|
+
estimatedTime: 5,
|
|
493
|
+
estimatedDuration: 300000,
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
id: "setup-shadcn",
|
|
497
|
+
name: "Set Up shadcn/ui",
|
|
498
|
+
description: "Install essential UI components for e-commerce",
|
|
499
|
+
command: "mycontext setup-shadcn --all",
|
|
500
|
+
dependencies: ["init"],
|
|
501
|
+
autoContinue: true,
|
|
502
|
+
estimatedTime: 8,
|
|
503
|
+
estimatedDuration: 480000,
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
id: "compile-prd",
|
|
507
|
+
name: "Compile E-commerce PRD",
|
|
508
|
+
description: "Generate comprehensive PRD for e-commerce features",
|
|
509
|
+
command: "mycontext compile-prd",
|
|
510
|
+
dependencies: ["init"],
|
|
511
|
+
autoContinue: true,
|
|
512
|
+
estimatedTime: 3,
|
|
513
|
+
estimatedDuration: 180000,
|
|
514
|
+
},
|
|
515
|
+
{
|
|
516
|
+
id: "generate-architecture",
|
|
517
|
+
name: "Generate E-commerce Architecture",
|
|
518
|
+
description: "Create types, brand, and component structure for e-commerce",
|
|
519
|
+
command: "mycontext generate architecture --auto-continue",
|
|
520
|
+
dependencies: ["compile-prd"],
|
|
521
|
+
autoContinue: true,
|
|
522
|
+
estimatedTime: 20,
|
|
523
|
+
estimatedDuration: 1200000,
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
id: "generate-ecommerce-components",
|
|
527
|
+
name: "Generate E-commerce Components",
|
|
528
|
+
description: "Generate shopping cart, product display, and checkout components",
|
|
529
|
+
command: "mycontext generate-components all --category ecommerce --with-tests",
|
|
530
|
+
dependencies: ["generate-architecture"],
|
|
531
|
+
autoContinue: true,
|
|
532
|
+
estimatedTime: 12,
|
|
533
|
+
estimatedDuration: 720000,
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
id: "validate-ecommerce",
|
|
537
|
+
name: "Validate E-commerce Setup",
|
|
538
|
+
description: "Run comprehensive validation for e-commerce application",
|
|
539
|
+
command: "mycontext validate",
|
|
540
|
+
dependencies: ["generate-ecommerce-components"],
|
|
541
|
+
autoContinue: false,
|
|
542
|
+
estimatedTime: 2,
|
|
543
|
+
estimatedDuration: 120000,
|
|
544
|
+
},
|
|
545
|
+
],
|
|
546
|
+
});
|
|
547
|
+
WorkflowEngine.registerWorkflow({
|
|
548
|
+
id: "dashboard-setup",
|
|
549
|
+
name: "Dashboard Application Setup",
|
|
550
|
+
description: "Complete setup for analytics dashboards with charts, metrics, and data visualization",
|
|
551
|
+
category: "setup",
|
|
552
|
+
estimatedTotalTime: 48,
|
|
553
|
+
steps: [
|
|
554
|
+
{
|
|
555
|
+
id: "init",
|
|
556
|
+
name: "Initialize Dashboard Project",
|
|
557
|
+
description: "Create project structure for analytics dashboard",
|
|
558
|
+
command: "mycontext init . --framework instantdb --description 'Analytics dashboard with charts and metrics'",
|
|
559
|
+
dependencies: [],
|
|
560
|
+
autoContinue: true,
|
|
561
|
+
estimatedTime: 5,
|
|
562
|
+
estimatedDuration: 300000,
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
id: "setup-shadcn",
|
|
566
|
+
name: "Set Up shadcn/ui",
|
|
567
|
+
description: "Install dashboard UI components",
|
|
568
|
+
command: "mycontext setup-shadcn --all",
|
|
569
|
+
dependencies: ["init"],
|
|
570
|
+
autoContinue: true,
|
|
571
|
+
estimatedTime: 8,
|
|
572
|
+
estimatedDuration: 480000,
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
id: "compile-prd",
|
|
576
|
+
name: "Compile Dashboard PRD",
|
|
577
|
+
description: "Generate comprehensive PRD for dashboard features",
|
|
578
|
+
command: "mycontext compile-prd",
|
|
579
|
+
dependencies: ["init"],
|
|
580
|
+
autoContinue: true,
|
|
581
|
+
estimatedTime: 3,
|
|
582
|
+
estimatedDuration: 180000,
|
|
583
|
+
},
|
|
584
|
+
{
|
|
585
|
+
id: "generate-architecture",
|
|
586
|
+
name: "Generate Dashboard Architecture",
|
|
587
|
+
description: "Create types, brand, and component structure for dashboard",
|
|
588
|
+
command: "mycontext generate architecture --auto-continue",
|
|
589
|
+
dependencies: ["compile-prd"],
|
|
590
|
+
autoContinue: true,
|
|
591
|
+
estimatedTime: 18,
|
|
592
|
+
estimatedDuration: 1080000,
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
id: "generate-dashboard-components",
|
|
596
|
+
name: "Generate Dashboard Components",
|
|
597
|
+
description: "Generate charts, metrics cards, and data tables",
|
|
598
|
+
command: "mycontext generate-components all --category dashboard --with-tests",
|
|
599
|
+
dependencies: ["generate-architecture"],
|
|
600
|
+
autoContinue: true,
|
|
601
|
+
estimatedTime: 12,
|
|
602
|
+
estimatedDuration: 720000,
|
|
603
|
+
},
|
|
604
|
+
{
|
|
605
|
+
id: "validate-dashboard",
|
|
606
|
+
name: "Validate Dashboard Setup",
|
|
607
|
+
description: "Run comprehensive validation for dashboard application",
|
|
608
|
+
command: "mycontext validate",
|
|
609
|
+
dependencies: ["generate-dashboard-components"],
|
|
610
|
+
autoContinue: false,
|
|
611
|
+
estimatedTime: 2,
|
|
612
|
+
estimatedDuration: 120000,
|
|
613
|
+
},
|
|
614
|
+
],
|
|
615
|
+
});
|
|
616
|
+
WorkflowEngine.registerWorkflow({
|
|
617
|
+
id: "content-blog-setup",
|
|
618
|
+
name: "Content/Blog Application Setup",
|
|
619
|
+
description: "Complete setup for content management with articles, comments, and CMS features",
|
|
620
|
+
category: "setup",
|
|
621
|
+
estimatedTotalTime: 46,
|
|
622
|
+
steps: [
|
|
623
|
+
{
|
|
624
|
+
id: "init",
|
|
625
|
+
name: "Initialize Content Project",
|
|
626
|
+
description: "Create project structure for content/blog application",
|
|
627
|
+
command: "mycontext init . --framework instantdb --description 'Content management system with articles and comments'",
|
|
628
|
+
dependencies: [],
|
|
629
|
+
autoContinue: true,
|
|
630
|
+
estimatedTime: 5,
|
|
631
|
+
estimatedDuration: 300000,
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
id: "setup-shadcn",
|
|
635
|
+
name: "Set Up shadcn/ui",
|
|
636
|
+
description: "Install content UI components",
|
|
637
|
+
command: "mycontext setup-shadcn --all",
|
|
638
|
+
dependencies: ["init"],
|
|
639
|
+
autoContinue: true,
|
|
640
|
+
estimatedTime: 8,
|
|
641
|
+
estimatedDuration: 480000,
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
id: "compile-prd",
|
|
645
|
+
name: "Compile Content PRD",
|
|
646
|
+
description: "Generate comprehensive PRD for content features",
|
|
647
|
+
command: "mycontext compile-prd",
|
|
648
|
+
dependencies: ["init"],
|
|
649
|
+
autoContinue: true,
|
|
650
|
+
estimatedTime: 3,
|
|
651
|
+
estimatedDuration: 180000,
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
id: "generate-architecture",
|
|
655
|
+
name: "Generate Content Architecture",
|
|
656
|
+
description: "Create types, brand, and component structure for content",
|
|
657
|
+
command: "mycontext generate architecture --auto-continue",
|
|
658
|
+
dependencies: ["compile-prd"],
|
|
659
|
+
autoContinue: true,
|
|
660
|
+
estimatedTime: 16,
|
|
661
|
+
estimatedDuration: 960000,
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
id: "generate-content-components",
|
|
665
|
+
name: "Generate Content Components",
|
|
666
|
+
description: "Generate articles, comments, and content management components",
|
|
667
|
+
command: "mycontext generate-components all --category content --with-tests",
|
|
668
|
+
dependencies: ["generate-architecture"],
|
|
669
|
+
autoContinue: true,
|
|
670
|
+
estimatedTime: 12,
|
|
671
|
+
estimatedDuration: 720000,
|
|
672
|
+
},
|
|
673
|
+
{
|
|
674
|
+
id: "validate-content",
|
|
675
|
+
name: "Validate Content Setup",
|
|
676
|
+
description: "Run comprehensive validation for content application",
|
|
677
|
+
command: "mycontext validate",
|
|
678
|
+
dependencies: ["generate-content-components"],
|
|
679
|
+
autoContinue: false,
|
|
680
|
+
estimatedTime: 2,
|
|
681
|
+
estimatedDuration: 120000,
|
|
682
|
+
},
|
|
683
|
+
],
|
|
684
|
+
});
|
|
685
|
+
WorkflowEngine.registerWorkflow({
|
|
686
|
+
id: "production-deployment",
|
|
687
|
+
name: "Production Deployment",
|
|
688
|
+
description: "Prepare and deploy application to production environment",
|
|
689
|
+
category: "deployment",
|
|
690
|
+
estimatedTotalTime: 15,
|
|
691
|
+
steps: [
|
|
692
|
+
{
|
|
693
|
+
id: "validate-production",
|
|
694
|
+
name: "Production Validation",
|
|
695
|
+
description: "Run comprehensive validation for production readiness",
|
|
696
|
+
command: "mycontext validate",
|
|
697
|
+
dependencies: [],
|
|
698
|
+
autoContinue: true,
|
|
699
|
+
estimatedTime: 3,
|
|
700
|
+
estimatedDuration: 180000,
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
id: "promote-production",
|
|
704
|
+
name: "Promote to Production",
|
|
705
|
+
description: "Move validated components to production directory",
|
|
706
|
+
command: "mycontext promote --all",
|
|
707
|
+
dependencies: ["validate-production"],
|
|
708
|
+
autoContinue: true,
|
|
709
|
+
estimatedTime: 2,
|
|
710
|
+
estimatedDuration: 120000,
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
id: "build-production",
|
|
714
|
+
name: "Build for Production",
|
|
715
|
+
description: "Create optimized production build",
|
|
716
|
+
command: "npm run build",
|
|
717
|
+
dependencies: ["promote-production"],
|
|
718
|
+
autoContinue: true,
|
|
719
|
+
estimatedTime: 8,
|
|
720
|
+
estimatedDuration: 480000,
|
|
721
|
+
},
|
|
722
|
+
{
|
|
723
|
+
id: "deploy-checklist",
|
|
724
|
+
name: "Deployment Checklist",
|
|
725
|
+
description: "Final deployment preparation checklist",
|
|
726
|
+
command: "mycontext status --deployment-check",
|
|
727
|
+
dependencies: ["build-production"],
|
|
728
|
+
autoContinue: false,
|
|
729
|
+
estimatedTime: 2,
|
|
730
|
+
estimatedDuration: 120000,
|
|
731
|
+
},
|
|
732
|
+
],
|
|
733
|
+
});
|
|
734
|
+
WorkflowEngine.registerWorkflow({
|
|
735
|
+
id: "feature-enhancement",
|
|
736
|
+
name: "Feature Enhancement",
|
|
737
|
+
description: "Add new features to existing applications",
|
|
738
|
+
category: "development",
|
|
739
|
+
estimatedTotalTime: 30,
|
|
740
|
+
steps: [
|
|
741
|
+
{
|
|
742
|
+
id: "analyze-current",
|
|
743
|
+
name: "Analyze Current State",
|
|
744
|
+
description: "Review existing components and architecture",
|
|
745
|
+
command: "mycontext status",
|
|
746
|
+
dependencies: [],
|
|
747
|
+
autoContinue: true,
|
|
748
|
+
estimatedTime: 2,
|
|
749
|
+
estimatedDuration: 120000,
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
id: "update-prd",
|
|
753
|
+
name: "Update PRD",
|
|
754
|
+
description: "Add new requirements to PRD",
|
|
755
|
+
command: "mycontext compile-prd",
|
|
756
|
+
dependencies: ["analyze-current"],
|
|
757
|
+
autoContinue: true,
|
|
758
|
+
estimatedTime: 3,
|
|
759
|
+
estimatedDuration: 180000,
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
id: "generate-enhanced-types",
|
|
763
|
+
name: "Generate Enhanced Types",
|
|
764
|
+
description: "Update types for new features",
|
|
765
|
+
command: "mycontext generate types",
|
|
766
|
+
dependencies: ["update-prd"],
|
|
767
|
+
autoContinue: true,
|
|
768
|
+
estimatedTime: 5,
|
|
769
|
+
estimatedDuration: 300000,
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
id: "generate-new-components",
|
|
773
|
+
name: "Generate New Components",
|
|
774
|
+
description: "Create components for new features",
|
|
775
|
+
command: "mycontext generate-components all --with-tests",
|
|
776
|
+
dependencies: ["generate-enhanced-types"],
|
|
777
|
+
autoContinue: true,
|
|
778
|
+
estimatedTime: 15,
|
|
779
|
+
estimatedDuration: 900000,
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
id: "validate-enhancement",
|
|
783
|
+
name: "Validate Enhancement",
|
|
784
|
+
description: "Ensure new features work correctly",
|
|
785
|
+
command: "mycontext validate",
|
|
786
|
+
dependencies: ["generate-new-components"],
|
|
787
|
+
autoContinue: false,
|
|
788
|
+
estimatedTime: 3,
|
|
789
|
+
estimatedDuration: 180000,
|
|
790
|
+
},
|
|
791
|
+
],
|
|
792
|
+
});
|
|
793
|
+
//# sourceMappingURL=workflowEngine.js.map
|