@sylphai/adal-cli 0.5.0-beta.1 → 0.5.0-beta.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/adal-cli.js CHANGED
@@ -52,8 +52,18 @@ function loadCachedPath() {
52
52
  try {
53
53
  if (fs.existsSync(cacheFile)) {
54
54
  const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
55
- // Verify the cached path still exists
55
+ // Verify the cached path still exists AND points to wrapper (not adal-cli.js)
56
+ const expectedWrapper = platform === 'win32' ? 'adal.cmd' : 'adal';
56
57
  if (cache.path && fs.existsSync(cache.path)) {
58
+ // CRITICAL: Reject cache if it points to adal-cli.js (stale Bun migration cache)
59
+ if (cache.path.endsWith('adal-cli.js')) {
60
+ // Stale cache from before Bun migration - must find wrapper instead
61
+ return null;
62
+ }
63
+ // Verify path ends with expected wrapper name
64
+ if (!cache.path.endsWith(expectedWrapper)) {
65
+ return null;
66
+ }
57
67
  // Check if it's been less than 30 days since last cache
58
68
  const cacheAge = Date.now() - cache.timestamp;
59
69
  if (cacheAge < 30 * 24 * 60 * 60 * 1000) { // 30 days in milliseconds
@@ -69,6 +79,7 @@ function loadCachedPath() {
69
79
 
70
80
  // Save path to cache
71
81
  function saveCachedPath(platformPath) {
82
+ const expectedWrapper = platform === 'win32' ? 'adal.cmd' : 'adal';
72
83
  try {
73
84
  if (!fs.existsSync(cacheDir)) {
74
85
  fs.mkdirSync(cacheDir, { recursive: true });
@@ -77,6 +88,7 @@ function saveCachedPath(platformPath) {
77
88
  path: platformPath,
78
89
  platform: platformKey,
79
90
  package: packageName,
91
+ wrapperType: expectedWrapper,
80
92
  timestamp: Date.now()
81
93
  }, null, 2));
82
94
  } catch (e) {
@@ -97,16 +109,16 @@ function findPlatformPackage() {
97
109
  }
98
110
 
99
111
  // If no cache or cache is stale, search for the package
112
+ // Look for the 'adal' wrapper script (not adal-cli.js) which uses bundled Bun
113
+ const wrapperName = platform === 'win32' ? 'adal.cmd' : 'adal';
100
114
  const possiblePaths = [
101
- // When installed globally
102
- path.join(__dirname, '..', '..', packageName, 'adal-cli.js'),
115
+ // When installed globally - platform package is in main package's node_modules
116
+ path.join(__dirname, '..', 'node_modules', packageName, wrapperName),
103
117
  // When installed locally in a project
104
- path.join(process.cwd(), 'node_modules', packageName, 'adal-cli.js'),
105
- // When running from development
106
- path.join(__dirname, '..', 'node_modules', packageName, 'adal-cli.js'),
107
- // Alternative global location
108
- require.resolve.paths(packageName).map(p => path.join(p, packageName, 'adal-cli.js')).filter(Boolean)
109
- ].flat();
118
+ path.join(process.cwd(), 'node_modules', packageName, wrapperName),
119
+ // Alternative: sibling in global node_modules (flat install)
120
+ path.join(__dirname, '..', '..', '..', packageName, wrapperName),
121
+ ];
110
122
 
111
123
  for (const testPath of possiblePaths) {
112
124
  if (fs.existsSync(testPath)) {
@@ -118,7 +130,7 @@ function findPlatformPackage() {
118
130
  // Try using require.resolve as last resort
119
131
  try {
120
132
  const packagePath = require.resolve(`${packageName}/package.json`);
121
- const platformBinary = path.join(path.dirname(packagePath), 'adal-cli.js');
133
+ const platformBinary = path.join(path.dirname(packagePath), wrapperName);
122
134
  if (fs.existsSync(platformBinary)) {
123
135
  saveCachedPath(platformBinary); // Cache the found path
124
136
  return platformBinary;
@@ -144,10 +156,11 @@ if (!platformBinary) {
144
156
  process.exit(1);
145
157
  }
146
158
 
147
- // Execute the platform-specific binary with all arguments
148
- const child = spawn(process.execPath, [platformBinary, ...process.argv.slice(2)], {
159
+ // Execute the platform-specific wrapper (uses bundled Bun runtime)
160
+ const child = spawn(platformBinary, process.argv.slice(2), {
149
161
  stdio: 'inherit',
150
162
  env: process.env,
163
+ shell: platform === 'win32', // Windows needs shell for .cmd files
151
164
  });
152
165
 
153
166
  // Forward the exit code
@@ -35,30 +35,20 @@ const cacheFile = path.join(cacheDir, 'platform-path.json');
35
35
 
36
36
  // Find the platform package during installation
37
37
  function findAndCachePlatformPackage() {
38
+ // Look for wrapper script (uses bundled Bun), not adal-cli.js
39
+ const wrapperName = platform === 'win32' ? 'adal.cmd' : 'adal';
38
40
  const possiblePaths = [
39
- // When installed globally
40
- path.join(__dirname, '..', '..', packageName, 'adal-cli.js'),
41
+ // When installed globally - platform package is in main package's node_modules
42
+ path.join(__dirname, '..', 'node_modules', packageName, wrapperName),
41
43
  // When installed locally in a project
42
- path.join(process.cwd(), 'node_modules', packageName, 'adal-cli.js'),
43
- // When running from development
44
- path.join(__dirname, '..', 'node_modules', packageName, 'adal-cli.js'),
44
+ path.join(process.cwd(), 'node_modules', packageName, wrapperName),
45
+ // Alternative: sibling in global node_modules (flat install)
46
+ path.join(__dirname, '..', '..', '..', packageName, wrapperName),
45
47
  ];
46
48
 
47
- // Also check require.resolve paths
48
- try {
49
- const resolvePaths = require.resolve.paths(packageName);
50
- if (resolvePaths) {
51
- resolvePaths.forEach(p => {
52
- possiblePaths.push(path.join(p, packageName, 'adal-cli.js'));
53
- });
54
- }
55
- } catch (e) {
56
- // Ignore errors
57
- }
58
-
59
49
  for (const testPath of possiblePaths) {
60
50
  if (fs.existsSync(testPath)) {
61
- // Found the platform package, cache it
51
+ // Found the platform wrapper, cache it
62
52
  try {
63
53
  if (!fs.existsSync(cacheDir)) {
64
54
  fs.mkdirSync(cacheDir, { recursive: true });
@@ -67,13 +57,14 @@ function findAndCachePlatformPackage() {
67
57
  path: testPath,
68
58
  platform: platformKey,
69
59
  package: packageName,
60
+ wrapperType: wrapperName,
70
61
  timestamp: Date.now(),
71
62
  installedAt: new Date().toISOString()
72
63
  }, null, 2));
73
- console.log(`✅ Cached platform package path: ${packageName}`);
64
+ console.log(`✅ Cached platform wrapper path: ${packageName}/${wrapperName}`);
74
65
  } catch (e) {
75
66
  // Cache write failed, not critical
76
- console.log(`⚠️ Could not cache platform package path: ${e.message}`);
67
+ console.log(`⚠️ Could not cache platform wrapper path: ${e.message}`);
77
68
  }
78
69
  return;
79
70
  }
@@ -82,7 +73,7 @@ function findAndCachePlatformPackage() {
82
73
  // Try using require.resolve as last resort
83
74
  try {
84
75
  const packagePath = require.resolve(`${packageName}/package.json`);
85
- const platformBinary = path.join(path.dirname(packagePath), 'adal-cli.js');
76
+ const platformBinary = path.join(path.dirname(packagePath), wrapperName);
86
77
  if (fs.existsSync(platformBinary)) {
87
78
  // Cache the found path
88
79
  if (!fs.existsSync(cacheDir)) {
@@ -92,10 +83,11 @@ function findAndCachePlatformPackage() {
92
83
  path: platformBinary,
93
84
  platform: platformKey,
94
85
  package: packageName,
86
+ wrapperType: wrapperName,
95
87
  timestamp: Date.now(),
96
88
  installedAt: new Date().toISOString()
97
89
  }, null, 2));
98
- console.log(`✅ Cached platform package path: ${packageName}`);
90
+ console.log(`✅ Cached platform wrapper path: ${packageName}/${wrapperName}`);
99
91
  }
100
92
  } catch (e) {
101
93
  // Platform package not found during install, will be found at runtime
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sylphai/adal-cli",
3
- "version": "0.5.0-beta.1",
3
+ "version": "0.5.0-beta.3",
4
4
  "description": "AI-powered CLI for development and research tasks",
5
5
  "bin": {
6
6
  "adal": "bin/adal-cli.js"
@@ -9,10 +9,10 @@
9
9
  "postinstall": "node lib/setup-cache.js"
10
10
  },
11
11
  "optionalDependencies": {
12
- "@sylphai/adal-cli-darwin-arm64": "0.5.0-beta.1",
13
- "@sylphai/adal-cli-darwin-x64": "0.5.0-beta.1",
14
- "@sylphai/adal-cli-linux-x64": "0.5.0-beta.1",
15
- "@sylphai/adal-cli-win32-x64": "0.5.0-beta.1"
12
+ "@sylphai/adal-cli-darwin-arm64": "0.5.0-beta.3",
13
+ "@sylphai/adal-cli-darwin-x64": "0.5.0-beta.3",
14
+ "@sylphai/adal-cli-linux-x64": "0.5.0-beta.3",
15
+ "@sylphai/adal-cli-win32-x64": "0.5.0-beta.3"
16
16
  },
17
17
  "files": [
18
18
  "bin/",