fraim-framework 2.0.45 → 2.0.47

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.
@@ -8,6 +8,7 @@ const commander_1 = require("commander");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const chalk_1 = __importDefault(require("chalk"));
11
+ const child_process_1 = require("child_process");
11
12
  const digest_utils_1 = require("../../utils/digest-utils");
12
13
  const config_loader_1 = require("../../fraim/config-loader");
13
14
  const version_utils_1 = require("../../utils/version-utils");
@@ -19,6 +20,8 @@ const runSync = async (options) => {
19
20
  const workflowsRelativePath = config.customizations?.workflowsPath || '.fraim/workflows';
20
21
  const workflowsDir = path_1.default.resolve(projectRoot, workflowsRelativePath);
21
22
  const digestPath = path_1.default.join(fraimDir, '.digest');
23
+ // Check for CLI updates first
24
+ await checkAndUpdateCLI();
22
25
  // In npm package, stubs are in node_modules/@fraim/framework/registry/stubs/workflows
23
26
  // We need to handle both "running from source" (src/cli/commands) and "running from dist" (dist/src/cli/commands)
24
27
  // Try 4 levels up (dist/src/cli/commands -> root)
@@ -163,6 +166,107 @@ const runSync = async (options) => {
163
166
  }
164
167
  };
165
168
  exports.runSync = runSync;
169
+ async function checkAndUpdateCLI() {
170
+ try {
171
+ console.log(chalk_1.default.blue('🔍 Checking for FRAIM CLI updates...'));
172
+ const currentVersion = (0, version_utils_1.getFraimVersion)();
173
+ const latestVersion = await getLatestNpmVersionHttp('fraim-framework');
174
+ if (!latestVersion) {
175
+ console.log(chalk_1.default.yellow('⚠️ Could not check for updates. Continuing with current version.'));
176
+ return;
177
+ }
178
+ if (isVersionUpToDate(currentVersion, latestVersion)) {
179
+ console.log(chalk_1.default.green(`✅ FRAIM CLI is up to date (${currentVersion})`));
180
+ return;
181
+ }
182
+ console.log(chalk_1.default.yellow(`📦 New version available: ${currentVersion} → ${latestVersion}`));
183
+ console.log(chalk_1.default.blue('🔄 Auto-updating FRAIM CLI...'));
184
+ const success = await updateGlobalPackageHttp('fraim-framework', latestVersion);
185
+ if (success) {
186
+ console.log(chalk_1.default.green(`✅ Successfully updated to FRAIM ${latestVersion}`));
187
+ console.log(chalk_1.default.gray(' Restart may be required for some changes to take effect.'));
188
+ }
189
+ else {
190
+ console.log(chalk_1.default.yellow('⚠️ Auto-update failed. Please run: npm install -g fraim-framework@latest'));
191
+ }
192
+ }
193
+ catch (error) {
194
+ console.log(chalk_1.default.yellow('⚠️ Could not check for updates. Continuing with current version.'));
195
+ }
196
+ }
197
+ async function getLatestNpmVersionHttp(packageName) {
198
+ try {
199
+ // Use Node.js built-in https module instead of spawn
200
+ const https = require('https');
201
+ return new Promise((resolve) => {
202
+ const req = https.get(`https://registry.npmjs.org/${packageName}/latest`, {
203
+ timeout: 5000,
204
+ headers: {
205
+ 'User-Agent': 'fraim-framework-cli'
206
+ }
207
+ }, (res) => {
208
+ let data = '';
209
+ res.on('data', (chunk) => {
210
+ data += chunk;
211
+ });
212
+ res.on('end', () => {
213
+ try {
214
+ const packageInfo = JSON.parse(data);
215
+ resolve(packageInfo.version || null);
216
+ }
217
+ catch (e) {
218
+ resolve(null);
219
+ }
220
+ });
221
+ });
222
+ req.on('error', () => {
223
+ resolve(null);
224
+ });
225
+ req.on('timeout', () => {
226
+ req.destroy();
227
+ resolve(null);
228
+ });
229
+ });
230
+ }
231
+ catch (error) {
232
+ return null;
233
+ }
234
+ }
235
+ function isVersionUpToDate(current, latest) {
236
+ // Simple version comparison - assumes semantic versioning
237
+ const currentParts = current.split('.').map(n => parseInt(n, 10));
238
+ const latestParts = latest.split('.').map(n => parseInt(n, 10));
239
+ for (let i = 0; i < Math.max(currentParts.length, latestParts.length); i++) {
240
+ const currentPart = currentParts[i] || 0;
241
+ const latestPart = latestParts[i] || 0;
242
+ if (currentPart < latestPart)
243
+ return false;
244
+ if (currentPart > latestPart)
245
+ return true;
246
+ }
247
+ return true; // Versions are equal
248
+ }
249
+ async function updateGlobalPackageHttp(packageName, version) {
250
+ return new Promise((resolve) => {
251
+ console.log(chalk_1.default.gray(` Running: npm install -g ${packageName}@${version}`));
252
+ // Use npm.cmd on Windows, npm on Unix
253
+ const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
254
+ const npmProcess = (0, child_process_1.spawn)(npmCommand, ['install', '-g', `${packageName}@${version}`], {
255
+ stdio: ['ignore', 'ignore', 'ignore'] // Suppress output for cleaner experience
256
+ });
257
+ npmProcess.on('close', (code) => {
258
+ resolve(code === 0);
259
+ });
260
+ npmProcess.on('error', () => {
261
+ resolve(false);
262
+ });
263
+ // Timeout after 30 seconds
264
+ setTimeout(() => {
265
+ npmProcess.kill();
266
+ resolve(false);
267
+ }, 30000);
268
+ });
269
+ }
166
270
  exports.syncCommand = new commander_1.Command('sync')
167
271
  .description('Sync workflow stubs from the framework registry')
168
272
  .option('-f, --force', 'Force sync even if digest matches')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fraim-framework",
3
- "version": "2.0.45",
3
+ "version": "2.0.47",
4
4
  "description": "FRAIM v2: Framework for Rigor-based AI Management - Transform from solo developer to AI manager orchestrating production-ready code with enterprise-grade discipline",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -86,7 +86,6 @@
86
86
  "cors": "^2.8.5",
87
87
  "dotenv": "^16.4.7",
88
88
  "express": "^5.2.1",
89
- "fraim-framework": "^2.0.38",
90
89
  "markdown-it": "^14.1.0",
91
90
  "markdown-it-highlightjs": "^4.2.0",
92
91
  "mongodb": "^7.0.0",