beth-copilot 1.0.1 → 1.0.3
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/bin/cli.js +50 -2
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -3,11 +3,17 @@
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { dirname, join, relative } from 'path';
|
|
5
5
|
import { existsSync, mkdirSync, readdirSync, statSync, copyFileSync, readFileSync, writeFileSync } from 'fs';
|
|
6
|
+
import { createRequire } from 'module';
|
|
6
7
|
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
7
9
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
10
|
const __dirname = dirname(__filename);
|
|
9
11
|
const TEMPLATES_DIR = join(__dirname, '..', 'templates');
|
|
10
12
|
|
|
13
|
+
// Get current package version
|
|
14
|
+
const packageJson = require('../package.json');
|
|
15
|
+
const CURRENT_VERSION = packageJson.version;
|
|
16
|
+
|
|
11
17
|
const COLORS = {
|
|
12
18
|
reset: '\x1b[0m',
|
|
13
19
|
bright: '\x1b[1m',
|
|
@@ -37,6 +43,37 @@ function logInfo(message) {
|
|
|
37
43
|
log(` ${message}`, COLORS.cyan);
|
|
38
44
|
}
|
|
39
45
|
|
|
46
|
+
async function checkForUpdates() {
|
|
47
|
+
try {
|
|
48
|
+
const response = await fetch('https://registry.npmjs.org/beth-copilot/latest', {
|
|
49
|
+
signal: AbortSignal.timeout(3000) // 3 second timeout
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (!response.ok) return null;
|
|
53
|
+
|
|
54
|
+
const data = await response.json();
|
|
55
|
+
const latestVersion = data.version;
|
|
56
|
+
|
|
57
|
+
if (latestVersion && latestVersion !== CURRENT_VERSION) {
|
|
58
|
+
// Compare versions (simple semver check)
|
|
59
|
+
const current = CURRENT_VERSION.split('.').map(Number);
|
|
60
|
+
const latest = latestVersion.split('.').map(Number);
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < 3; i++) {
|
|
63
|
+
if (latest[i] > current[i]) {
|
|
64
|
+
return latestVersion;
|
|
65
|
+
} else if (latest[i] < current[i]) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
} catch {
|
|
72
|
+
// Network error, timeout, etc. - silently continue
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
40
77
|
function showHelp() {
|
|
41
78
|
console.log(`
|
|
42
79
|
${COLORS.bright}Beth${COLORS.reset} - AI Orchestrator for GitHub Copilot
|
|
@@ -101,10 +138,21 @@ function copyDirRecursive(src, dest, options = {}) {
|
|
|
101
138
|
return copiedFiles;
|
|
102
139
|
}
|
|
103
140
|
|
|
104
|
-
function init(options = {}) {
|
|
141
|
+
async function init(options = {}) {
|
|
105
142
|
const { force = false, skipBacklog = false, skipMcp = false } = options;
|
|
106
143
|
const cwd = process.cwd();
|
|
107
144
|
|
|
145
|
+
// Check for updates
|
|
146
|
+
const latestVersion = await checkForUpdates();
|
|
147
|
+
if (latestVersion) {
|
|
148
|
+
console.log(`
|
|
149
|
+
${COLORS.yellow}╔════════════════════════════════════════════════════════════╗
|
|
150
|
+
║ ${COLORS.bright}Update available!${COLORS.reset}${COLORS.yellow} ${CURRENT_VERSION} → ${latestVersion} ║
|
|
151
|
+
║ Run: ${COLORS.cyan}npx beth-copilot@latest init${COLORS.yellow} to get the latest ║
|
|
152
|
+
╚════════════════════════════════════════════════════════════╝${COLORS.reset}
|
|
153
|
+
`);
|
|
154
|
+
}
|
|
155
|
+
|
|
108
156
|
console.log(`
|
|
109
157
|
${COLORS.bright}🤠 Beth is moving in.${COLORS.reset}
|
|
110
158
|
${COLORS.cyan}"I don't do excuses. I do results."${COLORS.reset}
|
|
@@ -237,7 +285,7 @@ if (unknownFlags.length > 0) {
|
|
|
237
285
|
|
|
238
286
|
switch (command) {
|
|
239
287
|
case 'init':
|
|
240
|
-
init(options);
|
|
288
|
+
await init(options);
|
|
241
289
|
break;
|
|
242
290
|
case 'help':
|
|
243
291
|
case '--help':
|