algomath-extract 1.0.2 → 1.0.4

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.
Files changed (2) hide show
  1. package/bin/install.js +84 -17
  2. package/package.json +1 -1
package/bin/install.js CHANGED
@@ -21,12 +21,55 @@ const isGlobal = args.includes('--global') || args.includes('-g');
21
21
  const isLocal = args.includes('--local') || args.includes('-l');
22
22
  const skipPrompts = isOpencode || isClaude || isGlobal || isLocal;
23
23
 
24
+ function compareVersions(v1, v2) {
25
+ const parts1 = v1.split('.').map(Number);
26
+ const parts2 = v2.split('.').map(Number);
27
+
28
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
29
+ const p1 = parts1[i] || 0;
30
+ const p2 = parts2[i] || 0;
31
+ if (p1 > p2) return 1;
32
+ if (p1 < p2) return -1;
33
+ }
34
+ return 0;
35
+ }
36
+
37
+ async function checkForUpdates() {
38
+ try {
39
+ const latestVersion = execSync('npm view algomath-extract version', {
40
+ encoding: 'utf8',
41
+ stdio: 'pipe',
42
+ timeout: 5000
43
+ }).trim();
44
+
45
+ const currentVersion = require('../package.json').version;
46
+ const comparison = compareVersions(currentVersion, latestVersion);
47
+
48
+ if (comparison < 0) {
49
+ // Current is older than npm
50
+ console.log(`\n⚠️ A newer version is available: v${latestVersion} (you have v${currentVersion})`);
51
+ console.log(' Run: npm i -g algomath-extract@latest\n');
52
+ return { hasUpdate: true, latestVersion, currentVersion };
53
+ } else if (comparison > 0) {
54
+ // Current is newer than npm (development/local build)
55
+ console.log(`\nℹ️ Development version: v${currentVersion} (npm has v${latestVersion})\n`);
56
+ }
57
+ return { hasUpdate: false };
58
+ } catch (e) {
59
+ // Network error or npm not available, silently continue
60
+ return { hasUpdate: false };
61
+ }
62
+ }
63
+
24
64
  async function main() {
25
65
  console.log('\n╔════════════════════════════════════════════════════╗');
26
66
  console.log('║ AlgoMath Framework Installer ║');
27
67
  console.log('║ Mathematical Algorithm Extraction & Code ║');
28
68
  console.log('╚════════════════════════════════════════════════════╝\n');
29
69
 
70
+ // Check for updates
71
+ await checkForUpdates();
72
+
30
73
  try {
31
74
  // Step 1: Check Python
32
75
  console.log('Step 1: Checking Python installation...');
@@ -135,27 +178,51 @@ return cmd;
135
178
  return null;
136
179
  }
137
180
 
138
- async function promptForRuntimes() {
139
- // Simple prompt (in real version would use inquirer)
140
- console.log('Select runtime(s):');
141
- console.log(' 1. OpenCode (recommended)');
142
- console.log(' 2. Claude Code');
143
- console.log(' 3. Both');
144
- console.log(' 4. Skip\n');
181
+ const readline = require('readline');
145
182
 
146
- // For now, auto-select OpenCode
147
- console.log('Auto-selecting: OpenCode\n');
148
- return ['opencode'];
183
+ function askQuestion(query) {
184
+ const rl = readline.createInterface({
185
+ input: process.stdin,
186
+ output: process.stdout,
187
+ });
188
+ return new Promise(resolve => rl.question(query, ans => {
189
+ rl.close();
190
+ resolve(ans);
191
+ }));
149
192
  }
150
193
 
151
- async function promptForLocation() {
152
- console.log('Installation location:');
153
- console.log(' 1. Global (~/.opencode/) - All projects');
154
- console.log(' 2. Local (./.opencode/) - This project only\n');
194
+ async function promptForRuntimes() {
195
+ console.log('\n📦 Select runtime(s) to install:');
196
+ console.log(' 1. OpenCode (recommended)');
197
+ console.log(' 2. Claude Code');
198
+ console.log(' 3. Both');
199
+ console.log(' 4. Skip\n');
200
+
201
+ const answer = await askQuestion('Enter choice (1-4) [1]: ');
202
+
203
+ switch (answer.trim()) {
204
+ case '2': return ['claude'];
205
+ case '3': return ['opencode', 'claude'];
206
+ case '4': return [];
207
+ case '1':
208
+ case '':
209
+ default: return ['opencode'];
210
+ }
211
+ }
155
212
 
156
- // For now, auto-select global
157
- console.log('Auto-selecting: Global\n');
158
- return 'global';
213
+ async function promptForLocation() {
214
+ console.log('\n📂 Select installation location:');
215
+ console.log(' 1. Global (~/.config/opencode/) - Available in all projects');
216
+ console.log(' 2. Local (./.opencode/) - This project only\n');
217
+
218
+ const answer = await askQuestion('Enter choice (1-2) [1]: ');
219
+
220
+ switch (answer.trim()) {
221
+ case '2': return 'local';
222
+ case '1':
223
+ case '':
224
+ default: return 'global';
225
+ }
159
226
  }
160
227
 
161
228
  function checkPythonDeps() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "algomath-extract",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "AlgoMath Framework - Transform AI assistants into reliable mathematical problem-solving environments",
5
5
  "main": "index.js",
6
6
  "bin": {