@oh-my-tool/cli 0.3.3 → 0.3.5

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": "@oh-my-tool/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "description": "Oh My Tool CLI - local and enterprise tools for agents",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@clack/prompts": "^1.7.0",
31
31
  "@modelcontextprotocol/client": "2.0.0",
32
- "@oh-my-tool/sdk": "0.3.3",
32
+ "@oh-my-tool/sdk": "0.3.5",
33
33
  "open": "11.0.0"
34
34
  },
35
35
  "engines": {
@@ -24,8 +24,13 @@ export async function createRuntime(options: RuntimeOptions = {}) {
24
24
  const secrets = new SecretsManager();
25
25
  const extensionConnections = sanitizeExtensionConnections(config);
26
26
  const nativeProvider = new NativeExtensionProvider(paths);
27
- validateConfiguredConnections(config, nativeProvider.installedExtensions());
28
- const nativeTarget = options.targetTool !== undefined && await nativeProvider.hasTool(options.targetTool);
27
+ const nativeTargetExtension = options.targetTool === undefined
28
+ ? undefined
29
+ : nativeProvider.extensionForTool(options.targetTool);
30
+ if (nativeTargetExtension !== undefined) {
31
+ validateConfiguredConnections(config, nativeProvider.installedExtensions(), nativeTargetExtension);
32
+ }
33
+ const nativeTarget = nativeTargetExtension !== undefined;
29
34
  const mcpProviders = options.includeMcp === false || nativeTarget ? [] : Object.entries(config.mcp.servers)
30
35
  .sort(([a], [b]) => a.localeCompare(b))
31
36
  .filter((entry): entry is [string, McpEnabledServerConfig] => entry[1].enabled)
@@ -213,9 +213,11 @@ export function sanitizeExtensionConnections(cfg: Config): Record<string, Record
213
213
  export function validateConfiguredConnections(
214
214
  cfg: Config,
215
215
  installedExtensions: readonly InstalledExtension[],
216
+ targetExtensionId?: string,
216
217
  ): void {
217
218
  const manifests = new Map(installedExtensions.map((extension) => [extension.id, extension.manifest]));
218
219
  for (const [extensionId, extension] of Object.entries(cfg.extensions)) {
220
+ if (targetExtensionId !== undefined && targetExtensionId !== extensionId) continue;
219
221
  const schema = manifests.get(extensionId)?.connectionSchema;
220
222
  if (schema === undefined) continue;
221
223
  for (const [name, connection] of Object.entries(extension.connections)) {
@@ -24,8 +24,21 @@ export interface NpmExtensionSpec {
24
24
 
25
25
  export class ExtensionInstallError extends Error {}
26
26
 
27
+ export function npmExecutableForPlatform(platform: string = process.platform): string {
28
+ return platform === "win32" ? "npm.cmd" : "npm";
29
+ }
30
+
31
+ export function npmShellForPlatform(platform: string = process.platform): boolean {
32
+ return platform === "win32";
33
+ }
34
+
27
35
  export interface NpmInstallDependencies {
28
36
  install(spec: string, tempDir: string): Promise<void>;
37
+ execFile?(
38
+ file: string,
39
+ args: string[],
40
+ options: { cwd: string; shell: boolean; timeout: number; maxBuffer: number },
41
+ ): Promise<unknown>;
29
42
  }
30
43
 
31
44
  export function normalizeNpmExtensionSpec(spec: string): NpmExtensionSpec {
@@ -95,19 +108,23 @@ export async function installNpmExtension(
95
108
  if (dependencies.install !== undefined) {
96
109
  await dependencies.install(normalized.npmSpec, temp);
97
110
  } else {
98
- await execFile("npm", [
111
+ const runNpm: NonNullable<NpmInstallDependencies["execFile"]> = dependencies.execFile ?? (async (file, args, options) => {
112
+ await execFile(file, args, options);
113
+ });
114
+ await runNpm(npmExecutableForPlatform(), [
99
115
  "install",
100
- "--prefix", temp,
116
+ "--prefix", ".",
101
117
  "--ignore-scripts",
102
118
  "--no-save",
103
119
  "--no-package-lock",
104
120
  "--omit=dev",
105
121
  "--registry=https://registry.npmjs.org",
106
122
  "--", normalized.npmSpec,
107
- ], { timeout: 120_000, maxBuffer: 4 * 1024 * 1024 });
123
+ ], { cwd: temp, timeout: 120_000, maxBuffer: 4 * 1024 * 1024, shell: npmShellForPlatform() });
108
124
  }
109
- } catch {
110
- throw new ExtensionInstallError(`failed to download npm extension '${normalized.npmSpec}'`);
125
+ } catch (error) {
126
+ const message = error instanceof Error ? error.message : String(error);
127
+ throw new ExtensionInstallError(`failed to download npm extension '${normalized.npmSpec}': ${message}`);
111
128
  }
112
129
 
113
130
  const packageDir = join(temp, "node_modules", ...normalized.packageName.split("/"));
@@ -64,6 +64,10 @@ export class NativeExtensionProvider implements ToolProvider {
64
64
  return this.getSnapshot().extensions;
65
65
  }
66
66
 
67
+ extensionForTool(toolId: string): string | undefined {
68
+ return this.getSnapshot().routes.get(toolId)?.manifest.id;
69
+ }
70
+
67
71
  private getSnapshot(): { extensions: InstalledExtension[]; routes: Map<string, InstalledExtension> } {
68
72
  if (this.snapshot) return this.snapshot;
69
73
  const extensions = this.discover(this.home());
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.3.3";
1
+ export const VERSION = "0.3.5";