mycontext-cli 2.0.27 → 2.0.29
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 +71 -342
- package/dist/agents/implementations/CodeGenSubAgent.d.ts.map +1 -1
- package/dist/agents/implementations/CodeGenSubAgent.js +67 -14
- package/dist/agents/implementations/CodeGenSubAgent.js.map +1 -1
- package/dist/agents/implementations/DesignPipelineAgent.d.ts +80 -0
- package/dist/agents/implementations/DesignPipelineAgent.d.ts.map +1 -0
- package/dist/agents/implementations/DesignPipelineAgent.js +1406 -0
- package/dist/agents/implementations/DesignPipelineAgent.js.map +1 -0
- package/dist/agents/implementations/FeatureAssemblyAgent.d.ts +67 -0
- package/dist/agents/implementations/FeatureAssemblyAgent.d.ts.map +1 -0
- package/dist/agents/implementations/FeatureAssemblyAgent.js +564 -0
- package/dist/agents/implementations/FeatureAssemblyAgent.js.map +1 -0
- package/dist/agents/implementations/PromptConstructorAgent.d.ts +10 -0
- package/dist/agents/implementations/PromptConstructorAgent.d.ts.map +1 -1
- package/dist/agents/implementations/PromptConstructorAgent.js +172 -12
- package/dist/agents/implementations/PromptConstructorAgent.js.map +1 -1
- package/dist/agents/implementations/RoleBasedGenerator.d.ts +52 -0
- package/dist/agents/implementations/RoleBasedGenerator.d.ts.map +1 -0
- package/dist/agents/implementations/RoleBasedGenerator.js +370 -0
- package/dist/agents/implementations/RoleBasedGenerator.js.map +1 -0
- package/dist/cli.js +111 -56
- package/dist/cli.js.map +1 -1
- package/dist/clients/ClaudeSDKClient.d.ts +48 -0
- package/dist/clients/ClaudeSDKClient.d.ts.map +1 -0
- package/dist/clients/ClaudeSDKClient.js +158 -0
- package/dist/clients/ClaudeSDKClient.js.map +1 -0
- package/dist/clients/MyContextAIClient.d.ts +73 -0
- package/dist/clients/MyContextAIClient.d.ts.map +1 -0
- package/dist/clients/MyContextAIClient.js +280 -0
- package/dist/clients/MyContextAIClient.js.map +1 -0
- package/dist/clients/ProviderChain.d.ts +87 -0
- package/dist/clients/ProviderChain.d.ts.map +1 -0
- package/dist/clients/ProviderChain.js +246 -0
- package/dist/clients/ProviderChain.js.map +1 -0
- package/dist/clients/XAIClient.d.ts +48 -0
- package/dist/clients/XAIClient.d.ts.map +1 -0
- package/dist/clients/XAIClient.js +152 -0
- package/dist/clients/XAIClient.js.map +1 -0
- package/dist/commands/assemble-features.d.ts +40 -0
- package/dist/commands/assemble-features.d.ts.map +1 -0
- package/dist/commands/assemble-features.js +383 -0
- package/dist/commands/assemble-features.js.map +1 -0
- package/dist/commands/clone-starter.d.ts +32 -0
- package/dist/commands/clone-starter.d.ts.map +1 -0
- package/dist/commands/clone-starter.js +218 -0
- package/dist/commands/clone-starter.js.map +1 -0
- package/dist/commands/design-analyze.d.ts +46 -0
- package/dist/commands/design-analyze.d.ts.map +1 -0
- package/dist/commands/design-analyze.js +232 -0
- package/dist/commands/design-analyze.js.map +1 -0
- package/dist/commands/generate-components.d.ts +11 -0
- package/dist/commands/generate-components.d.ts.map +1 -1
- package/dist/commands/generate-components.js +342 -12
- package/dist/commands/generate-components.js.map +1 -1
- package/dist/commands/generate-context-files.d.ts +9 -0
- package/dist/commands/generate-context-files.d.ts.map +1 -1
- package/dist/commands/generate-context-files.js +57 -0
- package/dist/commands/generate-context-files.js.map +1 -1
- package/dist/commands/generate.d.ts +5 -0
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +109 -2
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +32 -10
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/preview-components.d.ts +12 -0
- package/dist/commands/preview-components.d.ts.map +1 -0
- package/dist/commands/preview-components.js +122 -0
- package/dist/commands/preview-components.js.map +1 -0
- package/dist/commands/refine-component.d.ts +43 -0
- package/dist/commands/refine-component.d.ts.map +1 -0
- package/dist/commands/refine-component.js +313 -0
- package/dist/commands/refine-component.js.map +1 -0
- package/dist/commands/review-context.d.ts +47 -0
- package/dist/commands/review-context.d.ts.map +1 -0
- package/dist/commands/review-context.js +335 -0
- package/dist/commands/review-context.js.map +1 -0
- package/dist/commands/setup-complete.d.ts.map +1 -1
- package/dist/commands/setup-complete.js +38 -2
- package/dist/commands/setup-complete.js.map +1 -1
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +86 -7
- package/dist/commands/workflow.js.map +1 -1
- package/dist/config/intent-dictionary.json +3700 -0
- package/dist/package.json +12 -1
- package/dist/services/ContextValidator.d.ts +99 -0
- package/dist/services/ContextValidator.d.ts.map +1 -0
- package/dist/services/ContextValidator.js +433 -0
- package/dist/services/ContextValidator.js.map +1 -0
- package/dist/services/IntentEnricher.d.ts +61 -0
- package/dist/services/IntentEnricher.d.ts.map +1 -0
- package/dist/services/IntentEnricher.js +318 -0
- package/dist/services/IntentEnricher.js.map +1 -0
- package/dist/services/IntentValidator.d.ts +114 -0
- package/dist/services/IntentValidator.d.ts.map +1 -0
- package/dist/services/IntentValidator.js +680 -0
- package/dist/services/IntentValidator.js.map +1 -0
- package/dist/services/MutationLogger.d.ts +54 -0
- package/dist/services/MutationLogger.d.ts.map +1 -0
- package/dist/services/MutationLogger.js +164 -0
- package/dist/services/MutationLogger.js.map +1 -0
- package/dist/services/RegressionRunner.d.ts +49 -0
- package/dist/services/RegressionRunner.d.ts.map +1 -0
- package/dist/services/RegressionRunner.js +285 -0
- package/dist/services/RegressionRunner.js.map +1 -0
- package/dist/services/TriggerLogger.d.ts +101 -0
- package/dist/services/TriggerLogger.d.ts.map +1 -0
- package/dist/services/TriggerLogger.js +263 -0
- package/dist/services/TriggerLogger.js.map +1 -0
- package/dist/types/design-pipeline.d.ts +300 -0
- package/dist/types/design-pipeline.d.ts.map +1 -0
- package/dist/types/design-pipeline.js +9 -0
- package/dist/types/design-pipeline.js.map +1 -0
- package/dist/types/feature-bundle.d.ts +239 -0
- package/dist/types/feature-bundle.d.ts.map +1 -0
- package/dist/types/feature-bundle.js +9 -0
- package/dist/types/feature-bundle.js.map +1 -0
- package/dist/types/index.d.ts +2 -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/intent-dictionary.d.ts +525 -0
- package/dist/types/intent-dictionary.d.ts.map +1 -0
- package/dist/types/intent-dictionary.js +11 -0
- package/dist/types/intent-dictionary.js.map +1 -0
- package/dist/types/role-permissions.d.ts +167 -0
- package/dist/types/role-permissions.d.ts.map +1 -0
- package/dist/types/role-permissions.js +9 -0
- package/dist/types/role-permissions.js.map +1 -0
- package/dist/utils/contextEnricher.d.ts +41 -0
- package/dist/utils/contextEnricher.d.ts.map +1 -0
- package/dist/utils/contextEnricher.js +327 -0
- package/dist/utils/contextEnricher.js.map +1 -0
- package/dist/utils/designFallbacks.d.ts +48 -0
- package/dist/utils/designFallbacks.d.ts.map +1 -0
- package/dist/utils/designFallbacks.js +885 -0
- package/dist/utils/designFallbacks.js.map +1 -0
- package/dist/utils/designManifestManager.d.ts +89 -0
- package/dist/utils/designManifestManager.d.ts.map +1 -0
- package/dist/utils/designManifestManager.js +533 -0
- package/dist/utils/designManifestManager.js.map +1 -0
- package/dist/utils/designPipelineStateManager.d.ts +63 -0
- package/dist/utils/designPipelineStateManager.d.ts.map +1 -0
- package/dist/utils/designPipelineStateManager.js +174 -0
- package/dist/utils/designPipelineStateManager.js.map +1 -0
- package/dist/utils/envExampleGenerator.d.ts.map +1 -1
- package/dist/utils/envExampleGenerator.js +41 -171
- package/dist/utils/envExampleGenerator.js.map +1 -1
- package/dist/utils/featureBundleManager.d.ts +90 -0
- package/dist/utils/featureBundleManager.d.ts.map +1 -0
- package/dist/utils/featureBundleManager.js +340 -0
- package/dist/utils/featureBundleManager.js.map +1 -0
- package/dist/utils/githubCloner.d.ts +93 -0
- package/dist/utils/githubCloner.d.ts.map +1 -0
- package/dist/utils/githubCloner.js +305 -0
- package/dist/utils/githubCloner.js.map +1 -0
- package/dist/utils/hybridAIClient.d.ts.map +1 -1
- package/dist/utils/hybridAIClient.js +21 -0
- package/dist/utils/hybridAIClient.js.map +1 -1
- package/dist/utils/openRouterClient.d.ts +10 -0
- package/dist/utils/openRouterClient.d.ts.map +1 -0
- package/dist/utils/openRouterClient.js +61 -0
- package/dist/utils/openRouterClient.js.map +1 -0
- package/dist/utils/rolePermissionMapper.d.ts +89 -0
- package/dist/utils/rolePermissionMapper.d.ts.map +1 -0
- package/dist/utils/rolePermissionMapper.js +337 -0
- package/dist/utils/rolePermissionMapper.js.map +1 -0
- package/dist/utils/unifiedDesignContextLoader.d.ts +76 -0
- package/dist/utils/unifiedDesignContextLoader.d.ts.map +1 -0
- package/dist/utils/unifiedDesignContextLoader.js +344 -0
- package/dist/utils/unifiedDesignContextLoader.js.map +1 -0
- package/package.json +12 -1
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Role-Based Generator
|
|
4
|
+
*
|
|
5
|
+
* Generates features for different roles using admin-first approach.
|
|
6
|
+
* Admin features are generated first, then user/guest features are
|
|
7
|
+
* derived as subsets with appropriate permissions.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
43
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.RoleBasedGenerator = void 0;
|
|
47
|
+
const hybridAIClient_1 = require("../../utils/hybridAIClient");
|
|
48
|
+
const fs = __importStar(require("fs/promises"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
51
|
+
class RoleBasedGenerator {
|
|
52
|
+
constructor(projectPath) {
|
|
53
|
+
this.name = "RoleBasedGenerator";
|
|
54
|
+
this.description = "Generates role-based feature adaptations";
|
|
55
|
+
this.personality = "adaptive and security-focused";
|
|
56
|
+
this.llmProvider = "hybrid";
|
|
57
|
+
this.expertise = [
|
|
58
|
+
"role-based-access",
|
|
59
|
+
"permission-mapping",
|
|
60
|
+
"feature-adaptation",
|
|
61
|
+
];
|
|
62
|
+
this.projectPath = projectPath;
|
|
63
|
+
this.aiClient = new hybridAIClient_1.HybridAIClient();
|
|
64
|
+
}
|
|
65
|
+
async run(context) {
|
|
66
|
+
const startTime = Date.now();
|
|
67
|
+
console.log(chalk_1.default.cyan("🎭 Role-Based Generator starting..."));
|
|
68
|
+
try {
|
|
69
|
+
const roleFeatures = new Map();
|
|
70
|
+
const errors = [];
|
|
71
|
+
const warnings = [];
|
|
72
|
+
// Generate features for each role, starting with admin
|
|
73
|
+
const sortedRoles = this.sortRolesByHierarchy(context.targetRoles, context.roleHierarchy);
|
|
74
|
+
for (const role of sortedRoles) {
|
|
75
|
+
console.log(chalk_1.default.gray(` 🎯 Generating features for role: ${role}`));
|
|
76
|
+
try {
|
|
77
|
+
let features;
|
|
78
|
+
if (role === "admin") {
|
|
79
|
+
// Admin gets all features with full permissions
|
|
80
|
+
features = context.adminFeatures;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Other roles get subset of admin features with restricted permissions
|
|
84
|
+
features = await this.generateRoleFeatures(role, context.adminFeatures, context.roleHierarchy);
|
|
85
|
+
}
|
|
86
|
+
roleFeatures.set(role, features);
|
|
87
|
+
console.log(chalk_1.default.green(` ✓ Generated ${features.length} features for ${role}`));
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const errorMsg = `Failed to generate features for ${role}: ${error}`;
|
|
91
|
+
errors.push(errorMsg);
|
|
92
|
+
console.log(chalk_1.default.red(` ✗ ${errorMsg}`));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Save role-specific feature bundles
|
|
96
|
+
await this.saveRoleFeatures(roleFeatures, context.outputPath);
|
|
97
|
+
const processingTime = Date.now() - startTime;
|
|
98
|
+
const result = {
|
|
99
|
+
success: errors.length === 0,
|
|
100
|
+
roleFeatures,
|
|
101
|
+
errors,
|
|
102
|
+
warnings,
|
|
103
|
+
metadata: {
|
|
104
|
+
totalRoles: roleFeatures.size,
|
|
105
|
+
totalFeatures: Array.from(roleFeatures.values()).reduce((sum, features) => sum + features.length, 0),
|
|
106
|
+
processingTime,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
console.log(chalk_1.default.green(`✅ Role-Based Generation completed in ${processingTime}ms`));
|
|
110
|
+
console.log(chalk_1.default.blue(` Generated features for ${result.metadata.totalRoles} roles`));
|
|
111
|
+
console.log(chalk_1.default.blue(` Total features: ${result.metadata.totalFeatures}`));
|
|
112
|
+
return result;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.log(chalk_1.default.red(`❌ Role-Based Generation failed: ${error}`));
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
roleFeatures: new Map(),
|
|
119
|
+
errors: [error instanceof Error ? error.message : String(error)],
|
|
120
|
+
warnings: [],
|
|
121
|
+
metadata: {
|
|
122
|
+
totalRoles: 0,
|
|
123
|
+
totalFeatures: 0,
|
|
124
|
+
processingTime: Date.now() - startTime,
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
sortRolesByHierarchy(roles, hierarchy) {
|
|
130
|
+
// Sort roles by their level in the hierarchy (admin first, then user, then guest)
|
|
131
|
+
return roles.sort((a, b) => {
|
|
132
|
+
const roleA = hierarchy.roles.find((r) => r.name === a);
|
|
133
|
+
const roleB = hierarchy.roles.find((r) => r.name === b);
|
|
134
|
+
if (!roleA || !roleB)
|
|
135
|
+
return 0;
|
|
136
|
+
return roleB.level - roleA.level; // Higher level first (admin = 4, user = 2, guest = 1)
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
async generateRoleFeatures(role, adminFeatures, hierarchy) {
|
|
140
|
+
const roleDefinition = hierarchy.roles.find((r) => r.name === role);
|
|
141
|
+
if (!roleDefinition) {
|
|
142
|
+
throw new Error(`Role definition not found for ${role}`);
|
|
143
|
+
}
|
|
144
|
+
const roleFeatures = [];
|
|
145
|
+
for (const adminFeature of adminFeatures) {
|
|
146
|
+
try {
|
|
147
|
+
const roleFeature = await this.generateRoleFeature(role, adminFeature, roleDefinition, hierarchy);
|
|
148
|
+
roleFeatures.push(roleFeature);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.log(chalk_1.default.yellow(` ⚠️ Skipping feature ${adminFeature.name} for role ${role}: ${error}`));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return roleFeatures;
|
|
155
|
+
}
|
|
156
|
+
async generateRoleFeature(role, adminFeature, roleDefinition, hierarchy) {
|
|
157
|
+
// Create a copy of the admin feature
|
|
158
|
+
const roleFeature = JSON.parse(JSON.stringify(adminFeature));
|
|
159
|
+
// Update role
|
|
160
|
+
roleFeature.role = role;
|
|
161
|
+
// Filter components based on role permissions
|
|
162
|
+
roleFeature.components = await this.filterComponentsForRole(roleFeature.components, role, roleDefinition);
|
|
163
|
+
// Filter actions based on role permissions
|
|
164
|
+
roleFeature.actions = roleFeature.actions.filter((action) => this.hasPermissionForRole(action.permissions, role, roleDefinition));
|
|
165
|
+
// Filter hooks based on role permissions
|
|
166
|
+
roleFeature.hooks = roleFeature.hooks.filter((hook) => this.hasPermissionForRole(hook.dependencies, role, roleDefinition));
|
|
167
|
+
// Filter routes based on role permissions
|
|
168
|
+
roleFeature.routes = roleFeature.routes.filter((route) => this.hasPermissionForRole(route.permissions, role, roleDefinition));
|
|
169
|
+
// Update permissions to match role
|
|
170
|
+
roleFeature.permissions = roleFeature.permissions.filter((permission) => this.hasPermissionForRole([permission.action], role, roleDefinition));
|
|
171
|
+
// Add role-specific restrictions
|
|
172
|
+
roleFeature.permissions = this.applyRoleRestrictions(roleFeature.permissions, roleDefinition);
|
|
173
|
+
// Update metadata
|
|
174
|
+
roleFeature.metadata.updatedAt = new Date().toISOString();
|
|
175
|
+
roleFeature.metadata.dependencies = this.filterDependenciesForRole(roleFeature.metadata.dependencies, role);
|
|
176
|
+
return roleFeature;
|
|
177
|
+
}
|
|
178
|
+
async filterComponentsForRole(components, role, roleDefinition) {
|
|
179
|
+
// Filter components based on role permissions
|
|
180
|
+
const allowedComponents = components.filter((component) => {
|
|
181
|
+
const componentName = component.toLowerCase();
|
|
182
|
+
// Admin can see all components
|
|
183
|
+
if (role === "admin")
|
|
184
|
+
return true;
|
|
185
|
+
// User can see most components except admin-only ones
|
|
186
|
+
if (role === "user") {
|
|
187
|
+
return (!componentName.includes("admin") &&
|
|
188
|
+
!componentName.includes("manage") &&
|
|
189
|
+
!componentName.includes("settings"));
|
|
190
|
+
}
|
|
191
|
+
// Guest can only see public components
|
|
192
|
+
if (role === "guest") {
|
|
193
|
+
return (componentName.includes("public") ||
|
|
194
|
+
componentName.includes("view") ||
|
|
195
|
+
componentName.includes("display"));
|
|
196
|
+
}
|
|
197
|
+
return true;
|
|
198
|
+
});
|
|
199
|
+
return allowedComponents;
|
|
200
|
+
}
|
|
201
|
+
hasPermissionForRole(permissions, role, roleDefinition) {
|
|
202
|
+
// Check if role has any of the required permissions
|
|
203
|
+
return permissions.some((permission) => {
|
|
204
|
+
const rolePermission = roleDefinition.permissions.find((p) => p.action === permission || p.resource === permission);
|
|
205
|
+
return !!rolePermission;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
applyRoleRestrictions(permissions, roleDefinition) {
|
|
209
|
+
return permissions.map((permission) => {
|
|
210
|
+
// Apply role-specific conditions
|
|
211
|
+
const rolePermission = roleDefinition.permissions.find((p) => p.resource === permission.resource && p.action === permission.action);
|
|
212
|
+
if (rolePermission) {
|
|
213
|
+
return {
|
|
214
|
+
...permission,
|
|
215
|
+
conditions: rolePermission.conditions || permission.conditions,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
return permission;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
filterDependenciesForRole(dependencies, role) {
|
|
222
|
+
// Filter dependencies based on role needs
|
|
223
|
+
const roleSpecificDeps = {
|
|
224
|
+
admin: ["@radix-ui/react-dialog", "@radix-ui/react-dropdown-menu", "zod"],
|
|
225
|
+
moderator: [
|
|
226
|
+
"@radix-ui/react-dialog",
|
|
227
|
+
"@radix-ui/react-avatar",
|
|
228
|
+
"react-hook-form",
|
|
229
|
+
],
|
|
230
|
+
editor: ["@radix-ui/react-avatar", "react-hook-form"],
|
|
231
|
+
user: ["@radix-ui/react-avatar", "react-hook-form"],
|
|
232
|
+
guest: ["@radix-ui/react-avatar"],
|
|
233
|
+
};
|
|
234
|
+
const roleDeps = roleSpecificDeps[role] || [];
|
|
235
|
+
return dependencies.filter((dep) => roleDeps.includes(dep));
|
|
236
|
+
}
|
|
237
|
+
async saveRoleFeatures(roleFeatures, outputPath) {
|
|
238
|
+
const roleBundlesDir = path.join(outputPath, ".mycontext", "role-bundles");
|
|
239
|
+
await fs.mkdir(roleBundlesDir, { recursive: true });
|
|
240
|
+
for (const [role, features] of roleFeatures) {
|
|
241
|
+
const roleDir = path.join(roleBundlesDir, role);
|
|
242
|
+
await fs.mkdir(roleDir, { recursive: true });
|
|
243
|
+
// Save individual feature bundles
|
|
244
|
+
for (const feature of features) {
|
|
245
|
+
const featureFile = path.join(roleDir, `${feature.name}.json`);
|
|
246
|
+
await fs.writeFile(featureFile, JSON.stringify(feature, null, 2));
|
|
247
|
+
}
|
|
248
|
+
// Save role summary
|
|
249
|
+
const roleSummary = {
|
|
250
|
+
role,
|
|
251
|
+
features: features.map((f) => ({
|
|
252
|
+
name: f.name,
|
|
253
|
+
description: f.description,
|
|
254
|
+
components: f.components.length,
|
|
255
|
+
actions: f.actions.length,
|
|
256
|
+
hooks: f.hooks.length,
|
|
257
|
+
routes: f.routes.length,
|
|
258
|
+
})),
|
|
259
|
+
metadata: {
|
|
260
|
+
totalFeatures: features.length,
|
|
261
|
+
totalComponents: features.reduce((sum, f) => sum + f.components.length, 0),
|
|
262
|
+
totalActions: features.reduce((sum, f) => sum + f.actions.length, 0),
|
|
263
|
+
totalHooks: features.reduce((sum, f) => sum + f.hooks.length, 0),
|
|
264
|
+
totalRoutes: features.reduce((sum, f) => sum + f.routes.length, 0),
|
|
265
|
+
generatedAt: new Date().toISOString(),
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
const summaryFile = path.join(roleDir, "summary.json");
|
|
269
|
+
await fs.writeFile(summaryFile, JSON.stringify(roleSummary, null, 2));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Generate a default role hierarchy
|
|
274
|
+
*/
|
|
275
|
+
static createDefaultRoleHierarchy() {
|
|
276
|
+
return {
|
|
277
|
+
roles: [
|
|
278
|
+
{
|
|
279
|
+
name: "admin",
|
|
280
|
+
displayName: "Administrator",
|
|
281
|
+
description: "Full system access with all permissions",
|
|
282
|
+
level: 4,
|
|
283
|
+
permissions: [
|
|
284
|
+
{
|
|
285
|
+
id: "admin-all",
|
|
286
|
+
resource: "all",
|
|
287
|
+
action: "manage",
|
|
288
|
+
description: "Full system access",
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
metadata: {
|
|
292
|
+
color: "#dc2626",
|
|
293
|
+
icon: "shield",
|
|
294
|
+
badge: "Admin",
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: "user",
|
|
299
|
+
displayName: "User",
|
|
300
|
+
description: "Standard user with limited permissions",
|
|
301
|
+
level: 2,
|
|
302
|
+
permissions: [
|
|
303
|
+
{
|
|
304
|
+
id: "user-read",
|
|
305
|
+
resource: "users",
|
|
306
|
+
action: "read",
|
|
307
|
+
conditions: [
|
|
308
|
+
{
|
|
309
|
+
field: "id",
|
|
310
|
+
operator: "equals",
|
|
311
|
+
value: "{{userId}}",
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
description: "Read own user data",
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: "user-update",
|
|
318
|
+
resource: "users",
|
|
319
|
+
action: "update",
|
|
320
|
+
conditions: [
|
|
321
|
+
{
|
|
322
|
+
field: "id",
|
|
323
|
+
operator: "equals",
|
|
324
|
+
value: "{{userId}}",
|
|
325
|
+
},
|
|
326
|
+
],
|
|
327
|
+
description: "Update own user data",
|
|
328
|
+
},
|
|
329
|
+
],
|
|
330
|
+
inherits: ["guest"],
|
|
331
|
+
metadata: {
|
|
332
|
+
color: "#2563eb",
|
|
333
|
+
icon: "user",
|
|
334
|
+
badge: "User",
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
name: "guest",
|
|
339
|
+
displayName: "Guest",
|
|
340
|
+
description: "Limited access for unauthenticated users",
|
|
341
|
+
level: 1,
|
|
342
|
+
permissions: [
|
|
343
|
+
{
|
|
344
|
+
id: "guest-read-public",
|
|
345
|
+
resource: "public",
|
|
346
|
+
action: "read",
|
|
347
|
+
description: "Read public content",
|
|
348
|
+
},
|
|
349
|
+
],
|
|
350
|
+
metadata: {
|
|
351
|
+
color: "#6b7280",
|
|
352
|
+
icon: "eye",
|
|
353
|
+
badge: "Guest",
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
inheritance: [
|
|
358
|
+
{
|
|
359
|
+
child: "user",
|
|
360
|
+
parent: "guest",
|
|
361
|
+
type: "full",
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
defaultRole: "user",
|
|
365
|
+
fallbackRole: "guest",
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.RoleBasedGenerator = RoleBasedGenerator;
|
|
370
|
+
//# sourceMappingURL=RoleBasedGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoleBasedGenerator.js","sourceRoot":"","sources":["../../../src/agents/implementations/RoleBasedGenerator.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,+DAA4D;AAQ5D,gDAAkC;AAClC,2CAA6B;AAC7B,kDAA0B;AAsB1B,MAAa,kBAAkB;IAc7B,YAAY,WAAmB;QAbf,SAAI,GAAG,oBAAoB,CAAC;QAC5B,gBAAW,GAAG,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AI;oCACX,QAAQ,EAAE,QAAQ;oCAClB,KAAK,EAAE,YAAY;iCACpB;6BACF;4BACD,WAAW,EAAE,oBAAoB;yBAClC;wBACD;4BACE,EAAE,EAAE,aAAa;4BACjB,QAAQ,EAAE,OAAO;4BACjB,MAAM,EAAE,QAAQ;4BAChB,UAAU,EAAE;gCACV;oCACE,KAAK,EAAE,IAAI;oCACX,QAAQ,EAAE,QAAQ;oCAClB,KAAK,EAAE,YAAY;iCACpB;6BACF;4BACD,WAAW,EAAE,sBAAsB;yBACpC;qBACF;oBACD,QAAQ,EAAE,CAAC,OAAO,CAAC;oBACnB,QAAQ,EAAE;wBACR,KAAK,EAAE,SAAS;wBAChB,IAAI,EAAE,MAAM;wBACZ,KAAK,EAAE,MAAM;qBACd;iBACF;gBACD;oBACE,IAAI,EAAE,OAAO;oBACb,WAAW,EAAE,OAAO;oBACpB,WAAW,EAAE,0CAA0C;oBACvD,KAAK,EAAE,CAAC;oBACR,WAAW,EAAE;wBACX;4BACE,EAAE,EAAE,mBAAmB;4BACvB,QAAQ,EAAE,QAAQ;4BAClB,MAAM,EAAE,MAAM;4BACd,WAAW,EAAE,qBAAqB;yBACnC;qBACF;oBACD,QAAQ,EAAE;wBACR,KAAK,EAAE,SAAS;wBAChB,IAAI,EAAE,KAAK;wBACX,KAAK,EAAE,OAAO;qBACf;iBACF;aACF;YACD,WAAW,EAAE;gBACX;oBACE,KAAK,EAAE,MAAM;oBACb,MAAM,EAAE,OAAO;oBACf,IAAI,EAAE,MAAM;iBACb;aACF;YACD,WAAW,EAAE,MAAM;YACnB,YAAY,EAAE,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AArcD,gDAqcC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
38
|
};
|
|
@@ -22,7 +55,6 @@ const update_1 = require("./commands/update");
|
|
|
22
55
|
const agent_flow_1 = require("./commands/agent-flow");
|
|
23
56
|
const clean_1 = require("./utils/clean");
|
|
24
57
|
const predict_1 = require("./commands/predict");
|
|
25
|
-
const build_app_1 = require("./commands/build-app");
|
|
26
58
|
const analyze_1 = require("./commands/analyze");
|
|
27
59
|
const promote_1 = require("./commands/promote");
|
|
28
60
|
const migrate_1 = require("./commands/migrate");
|
|
@@ -43,6 +75,7 @@ const generate_context_files_1 = require("./commands/generate-context-files");
|
|
|
43
75
|
const compile_prd_1 = require("./commands/compile-prd");
|
|
44
76
|
const build_strategy_1 = require("./commands/build-strategy");
|
|
45
77
|
const health_check_1 = require("./commands/health-check");
|
|
78
|
+
const design_analyze_1 = require("./commands/design-analyze");
|
|
46
79
|
const PreCommandValidator_1 = require("./utils/PreCommandValidator");
|
|
47
80
|
// Import sub-agent system
|
|
48
81
|
const SubAgentOrchestrator_1 = require("./agents/orchestrator/SubAgentOrchestrator");
|
|
@@ -173,6 +206,7 @@ program
|
|
|
173
206
|
.option("--full", "Generate full context (PRD + A/B/C/D files) - for 'context' type only")
|
|
174
207
|
.option("--files-only", "Generate only A/B/C/D files (requires existing PRD) - for 'context' type only")
|
|
175
208
|
.option("--auto-continue", "Automatically continue to next logical steps after completion")
|
|
209
|
+
.option("--from-schema", "Generate types from InstantDB schema (for 'types' type only)")
|
|
176
210
|
.action(async (type, options) => {
|
|
177
211
|
try {
|
|
178
212
|
const generateCommand = new generate_1.GenerateCommand();
|
|
@@ -274,12 +308,64 @@ program
|
|
|
274
308
|
process.exit(1);
|
|
275
309
|
}
|
|
276
310
|
});
|
|
311
|
+
// Preview components command
|
|
312
|
+
program
|
|
313
|
+
.command("preview:components")
|
|
314
|
+
.description("Open component library preview in browser")
|
|
315
|
+
.option("--validate", "Run validation checks on all components")
|
|
316
|
+
.action(async (options) => {
|
|
317
|
+
try {
|
|
318
|
+
const { PreviewComponentsCommand } = await Promise.resolve().then(() => __importStar(require("./commands/preview-components")));
|
|
319
|
+
const previewCommand = new PreviewComponentsCommand();
|
|
320
|
+
await previewCommand.execute(options);
|
|
321
|
+
}
|
|
322
|
+
catch (error) {
|
|
323
|
+
console.error(chalk_1.default.red("❌ Preview command failed:"), error);
|
|
324
|
+
process.exit(1);
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
// Review context command
|
|
328
|
+
program
|
|
329
|
+
.command("review:context")
|
|
330
|
+
.description("Review auto-generated features and address context gaps")
|
|
331
|
+
.option("--auto-approve", "Automatically approve all features")
|
|
332
|
+
.option("--skip-gaps", "Skip gap resolution")
|
|
333
|
+
.action(async (options) => {
|
|
334
|
+
try {
|
|
335
|
+
const { ReviewContextCommand } = await Promise.resolve().then(() => __importStar(require("./commands/review-context")));
|
|
336
|
+
const reviewCommand = new ReviewContextCommand();
|
|
337
|
+
await reviewCommand.execute(options);
|
|
338
|
+
}
|
|
339
|
+
catch (error) {
|
|
340
|
+
console.error(chalk_1.default.red("❌ Review context failed:"), error);
|
|
341
|
+
process.exit(1);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
// Refine component command
|
|
345
|
+
program
|
|
346
|
+
.command("refine:component <componentName>")
|
|
347
|
+
.description("Refine a specific component with AI suggestions")
|
|
348
|
+
.option("--variant <variant>", "Component variant (mobile/desktop/both)", "both")
|
|
349
|
+
.option("--update-context", "Update context files and regenerate all components")
|
|
350
|
+
.option("--in-place", "Refine only this component file")
|
|
351
|
+
.action(async (componentName, options) => {
|
|
352
|
+
try {
|
|
353
|
+
const { RefineComponentCommand } = await Promise.resolve().then(() => __importStar(require("./commands/refine-component")));
|
|
354
|
+
const refineCommand = new RefineComponentCommand();
|
|
355
|
+
await refineCommand.execute(componentName, options);
|
|
356
|
+
}
|
|
357
|
+
catch (error) {
|
|
358
|
+
console.error(chalk_1.default.red("❌ Component refinement failed:"), error);
|
|
359
|
+
process.exit(1);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
277
362
|
// Generate components command
|
|
278
363
|
const generateComponentsCmd = program
|
|
279
364
|
.command("generate-components [target]")
|
|
280
365
|
.description("Generate React components using local AI")
|
|
281
366
|
.option("--group <group>", "Component group to generate")
|
|
282
367
|
.option("--all", "Generate all components (alias for target 'all')")
|
|
368
|
+
.option("--core-only", "Generate only the first 10 components for validation")
|
|
283
369
|
.option("--temperature <number>", "Generation temperature (0.1-1.0)", "0.7")
|
|
284
370
|
.option("--max-tokens <number>", "Maximum tokens for generation", "4000")
|
|
285
371
|
.option("--local", "Use local AI generation (no authentication required)")
|
|
@@ -294,9 +380,10 @@ const generateComponentsCmd = program
|
|
|
294
380
|
try {
|
|
295
381
|
const generateComponentsCommand = new generate_components_1.GenerateComponentsCommand();
|
|
296
382
|
// If --all is provided but no target, use 'all' as target
|
|
297
|
-
|
|
383
|
+
// If --core-only is provided, use 'core' as target
|
|
384
|
+
const actualTarget = target || (options.all ? "all" : options.coreOnly ? "core" : undefined);
|
|
298
385
|
if (!actualTarget) {
|
|
299
|
-
console.error(chalk_1.default.red("❌ Please specify a target or use --
|
|
386
|
+
console.error(chalk_1.default.red("❌ Please specify a target, use --all flag, or use --core-only flag"));
|
|
300
387
|
process.exit(1);
|
|
301
388
|
}
|
|
302
389
|
await generateComponentsCommand.execute(actualTarget, {
|
|
@@ -314,6 +401,27 @@ PreCommandValidator_1.PreCommandValidator.addValidationHook(generateComponentsCm
|
|
|
314
401
|
autoFix: true,
|
|
315
402
|
strict: false,
|
|
316
403
|
});
|
|
404
|
+
// Design analyze command
|
|
405
|
+
program
|
|
406
|
+
.command("design")
|
|
407
|
+
.description("Design system analysis and manifest generation")
|
|
408
|
+
.option("--analyze", "Analyze context files and generate design manifest")
|
|
409
|
+
.option("--validate", "Validate all context files")
|
|
410
|
+
.option("--summary", "Show design manifest summary")
|
|
411
|
+
.option("--regenerate", "Force regenerate design manifest")
|
|
412
|
+
.option("--resume", "Resume from last failed phase")
|
|
413
|
+
.action(async (options) => {
|
|
414
|
+
try {
|
|
415
|
+
const designCommand = new design_analyze_1.DesignAnalyzeCommand();
|
|
416
|
+
await designCommand.execute(options);
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
console.error(chalk_1.default.red("❌ Design analysis failed:"), error);
|
|
420
|
+
process.exit(1);
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
// Feature Assembly command
|
|
424
|
+
// Clone Starter command
|
|
317
425
|
// Agent Flow command (BETA - Agentic workflow orchestration)
|
|
318
426
|
program
|
|
319
427
|
.command("agent-flow <action>")
|
|
@@ -516,52 +624,6 @@ exportProgressCommand.register(program);
|
|
|
516
624
|
// PM Integration command (comprehensive PM integration management)
|
|
517
625
|
const pmIntegrationCommand = new pm_integration_1.PMIntegrationCommand();
|
|
518
626
|
pmIntegrationCommand.register(program);
|
|
519
|
-
// Build App command (agent-driven workflow with looping)
|
|
520
|
-
const buildAppCmd = program
|
|
521
|
-
.command("build-app")
|
|
522
|
-
.description("Build a complete app with agent-driven workflow and user interaction")
|
|
523
|
-
.option("--description <desc>", "App description/PRD")
|
|
524
|
-
.option("--output <dir>", "Output directory", "mycontext-app")
|
|
525
|
-
.option("--framework <type>", "Framework type", "nextjs")
|
|
526
|
-
.option("--with-tests", "Generate unit tests")
|
|
527
|
-
.option("--existing", "Work with existing project")
|
|
528
|
-
.option("--migrate", "Migrate existing project to MyContext structure")
|
|
529
|
-
.option("--verbose", "Verbose output")
|
|
530
|
-
.option("--interactive", "Enable interactive mode with user prompts and confirmations")
|
|
531
|
-
.option("--skip-validation", "Skip validation and quality assurance steps")
|
|
532
|
-
.option("--max-retries <number>", "Maximum retry attempts for failed steps", "3")
|
|
533
|
-
.option("--pm-plan <file>", "Use mycontext PM project plan JSON file")
|
|
534
|
-
.option("--auto-sync", "Automatically sync progress with mycontext PM")
|
|
535
|
-
.option("--webhook-url <url>", "Webhook URL for progress updates")
|
|
536
|
-
.action(async (options) => {
|
|
537
|
-
try {
|
|
538
|
-
const command = new build_app_1.BuildAppCommand();
|
|
539
|
-
await command.execute({
|
|
540
|
-
description: options.description,
|
|
541
|
-
output: options.output,
|
|
542
|
-
framework: options.framework,
|
|
543
|
-
withTests: Boolean(options.withTests),
|
|
544
|
-
existing: Boolean(options.existing),
|
|
545
|
-
migrate: Boolean(options.migrate),
|
|
546
|
-
verbose: Boolean(options.verbose),
|
|
547
|
-
interactive: Boolean(options.interactive),
|
|
548
|
-
skipValidation: Boolean(options.skipValidation),
|
|
549
|
-
maxRetries: parseInt(options.maxRetries) || 3,
|
|
550
|
-
pmPlan: options.pmPlan,
|
|
551
|
-
autoSync: Boolean(options.autoSync),
|
|
552
|
-
webhookUrl: options.webhookUrl,
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
catch (error) {
|
|
556
|
-
console.error(chalk_1.default.red("❌ Build app failed:"), error);
|
|
557
|
-
process.exit(1);
|
|
558
|
-
}
|
|
559
|
-
});
|
|
560
|
-
// Add validation hook to build-app command
|
|
561
|
-
PreCommandValidator_1.PreCommandValidator.addValidationHook(buildAppCmd, {
|
|
562
|
-
autoFix: true,
|
|
563
|
-
strict: true,
|
|
564
|
-
});
|
|
565
627
|
// Analyze command for existing projects
|
|
566
628
|
program
|
|
567
629
|
.command("analyze")
|
|
@@ -793,14 +855,12 @@ program
|
|
|
793
855
|
console.log(chalk_1.default.gray(" echo 'MYCONTEXT_QWEN_API_KEY=sk-or-xxx' > .mycontext/.env"));
|
|
794
856
|
console.log(chalk_1.default.gray(" mycontext generate context --full --description 'Modern todo app'"));
|
|
795
857
|
console.log(chalk_1.default.gray(" mycontext compile-prd"));
|
|
796
|
-
console.log(chalk_1.default.gray(" mycontext build-app --interactive"));
|
|
797
858
|
console.log(chalk_1.default.gray(" mycontext validate prd"));
|
|
798
859
|
console.log(chalk_1.default.gray(" mycontext generate components-list"));
|
|
799
860
|
console.log(chalk_1.default.gray(" mycontext generate-components all --with-tests\n"));
|
|
800
861
|
console.log(chalk_1.default.yellow("Available Commands:"));
|
|
801
862
|
console.log(chalk_1.default.gray(" init <project-name> - Initialize a new project"));
|
|
802
863
|
console.log(chalk_1.default.gray(" analyze - Analyze existing project and generate context"));
|
|
803
|
-
console.log(chalk_1.default.gray(" build-app - Build complete app from PRD (v0-like)"));
|
|
804
864
|
console.log(chalk_1.default.gray(" generate <type> - Generate context files"));
|
|
805
865
|
console.log(chalk_1.default.gray(" generate-components <target> - Generate React components"));
|
|
806
866
|
console.log(chalk_1.default.gray(" enhance <target> - Enhance components with AI"));
|
|
@@ -840,10 +900,6 @@ program
|
|
|
840
900
|
console.log(chalk_1.default.gray(" generated - Preview generated components"));
|
|
841
901
|
console.log(chalk_1.default.gray(" <group-name> - Preview specific component group\n"));
|
|
842
902
|
console.log(chalk_1.default.yellow("Examples:"));
|
|
843
|
-
console.log(chalk_1.default.gray(' mycontext build-app --description "A modern todo app with dark mode" --output "todo-app"'));
|
|
844
|
-
console.log(chalk_1.default.gray(' mycontext build-app --description "Enhance my existing app" --existing --migrate'));
|
|
845
|
-
console.log(chalk_1.default.gray(' mycontext build-app --description "Interactive app building" --interactive --max-retries 5'));
|
|
846
|
-
console.log(chalk_1.default.gray(' mycontext build-app --description "Fast build without validation" --skip-validation'));
|
|
847
903
|
console.log(chalk_1.default.gray(' mycontext init todo-app --description "A simple todo application"'));
|
|
848
904
|
console.log(chalk_1.default.gray(" mycontext init . --analyze # Analyze existing project"));
|
|
849
905
|
console.log(chalk_1.default.gray(" mycontext analyze --generate-context # Analyze and generate context"));
|
|
@@ -888,7 +944,6 @@ program.action(() => {
|
|
|
888
944
|
console.log(chalk_1.default.gray(" mycontext init my-project"));
|
|
889
945
|
console.log(chalk_1.default.gray(" mycontext generate context --full --description 'Your project'"));
|
|
890
946
|
console.log(chalk_1.default.gray(" mycontext compile-prd"));
|
|
891
|
-
console.log(chalk_1.default.gray(" mycontext build-app --interactive\n"));
|
|
892
947
|
console.log(chalk_1.default.gray('Run "mycontext help" for detailed information.\n'));
|
|
893
948
|
});
|
|
894
949
|
// Parse command line arguments
|