cli4ai 0.9.0 → 0.9.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli4ai",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "The package manager for AI CLI tools - cli4ai.com",
5
5
  "type": "module",
6
6
  "bin": {
@@ -63,9 +63,27 @@ async function getLatestVersions(packageNames: string[]): Promise<Map<string, st
63
63
  }
64
64
 
65
65
  /**
66
- * Update a single package (async)
66
+ * Update a single package using cli4ai add -g (reinstalls to ~/.cli4ai/packages/)
67
67
  */
68
- async function updatePackageAsync(packageName: string): Promise<boolean> {
68
+ async function updateCli4aiPackage(packageName: string): Promise<boolean> {
69
+ return new Promise((resolve) => {
70
+ // Use cli4ai add -g to reinstall the package (same location as original install)
71
+ const proc = spawn('cli4ai', ['add', '-g', packageName, '-y'], {
72
+ stdio: 'pipe'
73
+ });
74
+ proc.on('close', (code) => {
75
+ resolve(code === 0);
76
+ });
77
+ proc.on('error', () => {
78
+ resolve(false);
79
+ });
80
+ });
81
+ }
82
+
83
+ /**
84
+ * Update cli4ai itself via npm
85
+ */
86
+ async function updateNpmPackage(packageName: string): Promise<boolean> {
69
87
  return new Promise((resolve) => {
70
88
  const proc = spawn('npm', ['install', '-g', `${packageName}@latest`], {
71
89
  stdio: 'pipe'
@@ -99,14 +117,30 @@ export async function checkForUpdates(): Promise<{ hasUpdate: boolean; current:
99
117
  */
100
118
  function getUpdateablePackages(): Array<{ name: string; npmName: string; version: string }> {
101
119
  const packages: Array<{ name: string; npmName: string; version: string }> = [];
120
+ const seen = new Set<string>();
121
+
122
+ // Get packages from ~/.cli4ai/packages/ (where cli4ai add -g installs)
123
+ for (const pkg of getGlobalPackages()) {
124
+ if (!seen.has(pkg.name)) {
125
+ seen.add(pkg.name);
126
+ packages.push({
127
+ name: pkg.name,
128
+ npmName: `@cli4ai/${pkg.name}`,
129
+ version: pkg.version
130
+ });
131
+ }
132
+ }
102
133
 
103
- // Get npm global @cli4ai packages
134
+ // Also check npm global @cli4ai packages (for packages installed via npm directly)
104
135
  for (const pkg of getNpmGlobalPackages()) {
105
- packages.push({
106
- name: pkg.name,
107
- npmName: `@cli4ai/${pkg.name}`,
108
- version: pkg.version
109
- });
136
+ if (!seen.has(pkg.name)) {
137
+ seen.add(pkg.name);
138
+ packages.push({
139
+ name: pkg.name,
140
+ npmName: `@cli4ai/${pkg.name}`,
141
+ version: pkg.version
142
+ });
143
+ }
110
144
  }
111
145
 
112
146
  return packages;
@@ -123,7 +157,7 @@ export async function updateCommand(options: UpdateOptions): Promise<void> {
123
157
 
124
158
  if (hasUpdate) {
125
159
  log(` ${CYAN}↑${RESET} cli4ai ${DIM}${current}${RESET} → ${GREEN}${latest}${RESET}`);
126
- const success = await updatePackageAsync('cli4ai');
160
+ const success = await updateNpmPackage('cli4ai');
127
161
 
128
162
  if (success) {
129
163
  log(` ${GREEN}✓${RESET} cli4ai updated\n`);
@@ -183,7 +217,8 @@ export async function updateCommand(options: UpdateOptions): Promise<void> {
183
217
 
184
218
  const updateResults: Array<(typeof toUpdate)[number] & { success: boolean }> = [];
185
219
  for (const pkg of toUpdate) {
186
- const success = await updatePackageAsync(pkg.npmName);
220
+ // Use cli4ai add -g to update packages in ~/.cli4ai/packages/
221
+ const success = await updateCli4aiPackage(pkg.name);
187
222
  updateResults.push({ ...pkg, success });
188
223
  }
189
224
 
package/src/lib/cli.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  import { Command } from 'commander';
7
7
 
8
8
  export const BRAND = 'cli4ai - cli4ai.com';
9
- export const VERSION = '0.8.3';
9
+ export const VERSION = '0.9.2';
10
10
 
11
11
  // ═══════════════════════════════════════════════════════════════════════════
12
12
  // TYPES