cli4ai 1.1.5 → 1.2.0
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 +1 -1
- package/src/cli.ts +3 -0
- package/src/commands/info.ts +31 -0
- package/src/commands/list.ts +24 -1
- package/src/commands/search.ts +38 -1
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -93,6 +93,7 @@ export function createProgram(): Command {
|
|
|
93
93
|
.alias('ls')
|
|
94
94
|
.description('List installed packages')
|
|
95
95
|
.option('-g, --global', 'List global packages')
|
|
96
|
+
.option('-r, --remote <name>', 'List packages on a remote server')
|
|
96
97
|
.option('--json', 'Output as JSON')
|
|
97
98
|
.action(withErrorHandling(listCommand));
|
|
98
99
|
|
|
@@ -143,12 +144,14 @@ Remote Execution:
|
|
|
143
144
|
.command('info <package>')
|
|
144
145
|
.description('Show package information')
|
|
145
146
|
.option('--versions', 'Show all available versions')
|
|
147
|
+
.option('-r, --remote <name>', 'Get info from a remote server')
|
|
146
148
|
.action(withErrorHandling(infoCommand));
|
|
147
149
|
|
|
148
150
|
program
|
|
149
151
|
.command('search <query>')
|
|
150
152
|
.description('Search for packages')
|
|
151
153
|
.option('-l, --limit <n>', 'Max results', '20')
|
|
154
|
+
.option('-r, --remote <name>', 'Search packages on a remote server')
|
|
152
155
|
.action(withErrorHandling(searchCommand));
|
|
153
156
|
|
|
154
157
|
program
|
package/src/commands/info.ts
CHANGED
|
@@ -8,12 +8,43 @@ import { output, outputError, log } from '../lib/cli.js';
|
|
|
8
8
|
import { findPackage, loadConfig } from '../core/config.js';
|
|
9
9
|
import { loadManifest, tryLoadManifest, type Manifest } from '../core/manifest.js';
|
|
10
10
|
import { existsSync } from 'fs';
|
|
11
|
+
import { remotePackageInfo, RemoteConnectionError, RemoteApiError } from '../core/remote-client.js';
|
|
11
12
|
|
|
12
13
|
interface InfoOptions {
|
|
13
14
|
versions?: boolean;
|
|
15
|
+
remote?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export async function infoCommand(packageName: string, options: InfoOptions): Promise<void> {
|
|
19
|
+
// Handle remote info
|
|
20
|
+
if (options.remote) {
|
|
21
|
+
try {
|
|
22
|
+
const info = await remotePackageInfo(options.remote, packageName);
|
|
23
|
+
if (!info) {
|
|
24
|
+
outputError('NOT_FOUND', `Package not found on remote: ${packageName}`, {
|
|
25
|
+
remote: options.remote
|
|
26
|
+
});
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
output({
|
|
30
|
+
remote: options.remote,
|
|
31
|
+
name: info.name,
|
|
32
|
+
version: info.version,
|
|
33
|
+
description: info.description,
|
|
34
|
+
commands: info.commands ? Object.keys(info.commands) : [],
|
|
35
|
+
commandDetails: info.commands
|
|
36
|
+
});
|
|
37
|
+
} catch (err) {
|
|
38
|
+
if (err instanceof RemoteConnectionError) {
|
|
39
|
+
outputError('NETWORK_ERROR', err.message, { remote: err.remoteName, url: err.url });
|
|
40
|
+
} else if (err instanceof RemoteApiError) {
|
|
41
|
+
outputError(err.code, err.message, { remote: err.remoteName, details: err.details });
|
|
42
|
+
} else {
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
17
48
|
// First check if it's installed
|
|
18
49
|
const installed = findPackage(packageName, process.cwd());
|
|
19
50
|
|
package/src/commands/list.ts
CHANGED
|
@@ -2,22 +2,45 @@
|
|
|
2
2
|
* cli4ai list - Show installed packages
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { output } from '../lib/cli.js';
|
|
5
|
+
import { output, outputError } from '../lib/cli.js';
|
|
6
6
|
import {
|
|
7
7
|
getGlobalPackages,
|
|
8
8
|
getLocalPackages,
|
|
9
9
|
getNpmGlobalPackages,
|
|
10
10
|
type InstalledPackage
|
|
11
11
|
} from '../core/config.js';
|
|
12
|
+
import { remoteListPackages, RemoteConnectionError, RemoteApiError } from '../core/remote-client.js';
|
|
12
13
|
|
|
13
14
|
interface ListOptions {
|
|
14
15
|
global?: boolean;
|
|
15
16
|
json?: boolean;
|
|
17
|
+
remote?: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
type PackageWithScope = InstalledPackage & { scope: 'local' | 'cli4ai' | 'npm' };
|
|
19
21
|
|
|
20
22
|
export async function listCommand(options: ListOptions): Promise<void> {
|
|
23
|
+
// Handle remote listing
|
|
24
|
+
if (options.remote) {
|
|
25
|
+
try {
|
|
26
|
+
const result = await remoteListPackages(options.remote);
|
|
27
|
+
output({
|
|
28
|
+
remote: options.remote,
|
|
29
|
+
packages: result.packages,
|
|
30
|
+
count: result.packages.length
|
|
31
|
+
});
|
|
32
|
+
} catch (err) {
|
|
33
|
+
if (err instanceof RemoteConnectionError) {
|
|
34
|
+
outputError('NETWORK_ERROR', err.message, { remote: err.remoteName, url: err.url });
|
|
35
|
+
} else if (err instanceof RemoteApiError) {
|
|
36
|
+
outputError(err.code, err.message, { remote: err.remoteName, details: err.details });
|
|
37
|
+
} else {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
21
44
|
let packages: PackageWithScope[];
|
|
22
45
|
|
|
23
46
|
// Get all package sources
|
package/src/commands/search.ts
CHANGED
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
import { readdirSync, existsSync } from 'fs';
|
|
6
6
|
import { resolve } from 'path';
|
|
7
7
|
import { spawnSync } from 'child_process';
|
|
8
|
-
import { output, log } from '../lib/cli.js';
|
|
8
|
+
import { output, outputError, log } from '../lib/cli.js';
|
|
9
9
|
import { loadConfig, getGlobalPackages, getLocalPackages } from '../core/config.js';
|
|
10
10
|
import { tryLoadManifest, type Manifest } from '../core/manifest.js';
|
|
11
|
+
import { remoteListPackages, RemoteConnectionError, RemoteApiError } from '../core/remote-client.js';
|
|
11
12
|
|
|
12
13
|
interface SearchOptions {
|
|
13
14
|
limit?: string;
|
|
15
|
+
remote?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
interface SearchResult {
|
|
@@ -26,6 +28,41 @@ export async function searchCommand(query: string, options: SearchOptions): Prom
|
|
|
26
28
|
const limit = parseInt(options.limit || '20', 10);
|
|
27
29
|
const queryLower = query.toLowerCase();
|
|
28
30
|
|
|
31
|
+
// Handle remote search
|
|
32
|
+
if (options.remote) {
|
|
33
|
+
try {
|
|
34
|
+
const packageList = await remoteListPackages(options.remote);
|
|
35
|
+
const results = packageList.packages
|
|
36
|
+
.filter(pkg =>
|
|
37
|
+
pkg.name.toLowerCase().includes(queryLower) ||
|
|
38
|
+
pkg.path.toLowerCase().includes(queryLower)
|
|
39
|
+
)
|
|
40
|
+
.slice(0, limit)
|
|
41
|
+
.map(pkg => ({
|
|
42
|
+
name: pkg.name,
|
|
43
|
+
version: pkg.version,
|
|
44
|
+
source: 'remote' as const,
|
|
45
|
+
installed: true
|
|
46
|
+
}));
|
|
47
|
+
|
|
48
|
+
output({
|
|
49
|
+
remote: options.remote,
|
|
50
|
+
query,
|
|
51
|
+
results,
|
|
52
|
+
count: results.length
|
|
53
|
+
});
|
|
54
|
+
} catch (err) {
|
|
55
|
+
if (err instanceof RemoteConnectionError) {
|
|
56
|
+
outputError('NETWORK_ERROR', err.message, { remote: err.remoteName, url: err.url });
|
|
57
|
+
} else if (err instanceof RemoteApiError) {
|
|
58
|
+
outputError(err.code, err.message, { remote: err.remoteName, details: err.details });
|
|
59
|
+
} else {
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
29
66
|
const results: SearchResult[] = [];
|
|
30
67
|
const seen = new Set<string>();
|
|
31
68
|
|