@open-agent-toolkit/cli 0.2.15 → 0.2.16

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.
@@ -1,6 +1,6 @@
1
1
  {
2
- "cli": "0.2.15",
3
- "docs-config": "0.2.15",
4
- "docs-theme": "0.2.15",
5
- "docs-transforms": "0.2.15"
2
+ "cli": "0.2.16",
3
+ "docs-config": "0.2.16",
4
+ "docs-theme": "0.2.16",
5
+ "docs-transforms": "0.2.16"
6
6
  }
@@ -5,12 +5,13 @@ export interface GlobalCliInstallerOptions {
5
5
  platform: NodeJS.Platform;
6
6
  nodeExecutable: string;
7
7
  fileExists: (path: string) => boolean;
8
+ readFile?: (path: string) => string;
8
9
  }
9
10
  export interface GlobalCliInstallerInvocation {
10
11
  file: string;
11
12
  args: string[];
12
13
  }
13
14
  export declare function detectGlobalCliPackageManager(argv: string[], env: NodeJS.ProcessEnv): GlobalCliPackageManager;
14
- export declare function formatGlobalCliInstallCommand(packageSpec: string, argv: string[], env: NodeJS.ProcessEnv): string;
15
+ export declare function formatGlobalCliInstallCommand(packageSpec: string, argv: string[], env: NodeJS.ProcessEnv, fileExists?: (path: string) => boolean, readFile?: (path: string) => string): string;
15
16
  export declare function resolveGlobalCliInstallerInvocation(packageSpec: string, options: GlobalCliInstallerOptions): GlobalCliInstallerInvocation | null;
16
17
  //# sourceMappingURL=global-cli-installer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"global-cli-installer.d.ts","sourceRoot":"","sources":["../../src/app/global-cli-installer.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAEtE,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,cAAc,EAAE,MAA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AA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,UAAU,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAqB,EACnD,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAClC,MAAM,CAmBR;AAQD,wBAAgB,mCAAmC,CACjD,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,yBAAyB,GACjC,4BAA4B,GAAG,IAAI,CAmBrC"}
@@ -1,4 +1,5 @@
1
- import { win32 } from 'node:path';
1
+ import { readFileSync } from 'node:fs';
2
+ import { join, win32 } from 'node:path';
2
3
  function normalizePathForDetection(path) {
3
4
  return path.replaceAll('\\', '/').toLowerCase().replace(/\/+$/, '');
4
5
  }
@@ -39,12 +40,56 @@ export function detectGlobalCliPackageManager(argv, env) {
39
40
  }
40
41
  return 'npm';
41
42
  }
42
- function installArgsForManager(manager, packageSpec) {
43
+ function readPnpmStoreDir(argv, env, fileExists, readFile) {
44
+ const modulesYamlPath = resolvePnpmGlobalModulesYamlPath(argv, env, fileExists);
45
+ if (!modulesYamlPath) {
46
+ return null;
47
+ }
48
+ try {
49
+ const match = readFile(modulesYamlPath).match(/^storeDir:\s*(.+)$/m);
50
+ return match?.[1]?.trim() ?? null;
51
+ }
52
+ catch {
53
+ return null;
54
+ }
55
+ }
56
+ function resolvePnpmGlobalModulesYamlPath(argv, env, fileExists) {
57
+ for (const arg of argv.slice(0, 3)) {
58
+ const normalized = arg.replaceAll('\\', '/');
59
+ const match = normalized.match(/^(.*\/global\/\d+)\//);
60
+ if (match?.[1]) {
61
+ const candidate = `${match[1]}/node_modules/.modules.yaml`;
62
+ if (fileExists(candidate)) {
63
+ return candidate;
64
+ }
65
+ }
66
+ }
67
+ const pnpmHome = env.PNPM_HOME?.trim();
68
+ if (pnpmHome) {
69
+ const candidate = join(pnpmHome, 'global', '5', 'node_modules', '.modules.yaml');
70
+ if (fileExists(candidate)) {
71
+ return candidate;
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ function resolvePnpmInstallContext(argv, env, fileExists, readFile) {
77
+ const read = readFile ?? ((path) => readFileSync(path, 'utf8'));
78
+ return {
79
+ storeDir: readPnpmStoreDir(argv, env, fileExists, read),
80
+ };
81
+ }
82
+ function installArgsForManager(manager, packageSpec, pnpmStoreDir) {
43
83
  switch (manager) {
44
84
  case 'npm':
45
85
  return ['install', '--global', packageSpec];
46
- case 'pnpm':
47
- return ['add', '-g', packageSpec];
86
+ case 'pnpm': {
87
+ const args = ['add', '-g', packageSpec];
88
+ if (pnpmStoreDir) {
89
+ args.push('--store-dir', pnpmStoreDir);
90
+ }
91
+ return args;
92
+ }
48
93
  case 'yarn':
49
94
  return ['global', 'add', packageSpec];
50
95
  case 'bun':
@@ -58,6 +103,9 @@ function resolveWindowsManagerInvocation(manager, packageSpec, options) {
58
103
  if (manager === 'npm') {
59
104
  return resolveNpmWindowsInvocation(packageSpec, options);
60
105
  }
106
+ const pnpmStoreDir = manager === 'pnpm'
107
+ ? resolvePnpmInstallContext(options.argv, options.env, options.fileExists, options.readFile).storeDir
108
+ : null;
61
109
  const comspec = options.env.ComSpec?.trim() || 'cmd.exe';
62
110
  return {
63
111
  file: comspec,
@@ -66,7 +114,7 @@ function resolveWindowsManagerInvocation(manager, packageSpec, options) {
66
114
  '/s',
67
115
  '/c',
68
116
  manager,
69
- ...installArgsForManager(manager, packageSpec),
117
+ ...installArgsForManager(manager, packageSpec, pnpmStoreDir),
70
118
  ],
71
119
  };
72
120
  }
@@ -86,26 +134,38 @@ function resolveNpmWindowsInvocation(packageSpec, options) {
86
134
  args: [npmCliPath, ...npmArgs],
87
135
  };
88
136
  }
89
- export function formatGlobalCliInstallCommand(packageSpec, argv, env) {
137
+ export function formatGlobalCliInstallCommand(packageSpec, argv, env, fileExists = () => false, readFile) {
90
138
  const manager = detectGlobalCliPackageManager(argv, env);
139
+ const pnpmStoreDir = manager === 'pnpm'
140
+ ? resolvePnpmInstallContext(argv, env, fileExists, readFile).storeDir
141
+ : null;
142
+ const pnpmStoreFlag = pnpmStoreDir === null ? '' : ` --store-dir ${quoteShellWord(pnpmStoreDir)}`;
91
143
  switch (manager) {
92
144
  case 'npm':
93
145
  return `npm install --global ${packageSpec}`;
94
146
  case 'pnpm':
95
- return `pnpm add -g ${packageSpec}`;
147
+ return `pnpm add -g ${packageSpec}${pnpmStoreFlag}`;
96
148
  case 'yarn':
97
149
  return `yarn global add ${packageSpec}`;
98
150
  case 'bun':
99
151
  return `bun install -g ${packageSpec}`;
100
152
  }
101
153
  }
154
+ function quoteShellWord(value) {
155
+ return /[\s"'`$\\]/.test(value)
156
+ ? `'${value.replaceAll("'", `'"'"'`)}'`
157
+ : value;
158
+ }
102
159
  export function resolveGlobalCliInstallerInvocation(packageSpec, options) {
103
160
  const manager = detectGlobalCliPackageManager(options.argv, options.env);
161
+ const pnpmStoreDir = manager === 'pnpm'
162
+ ? resolvePnpmInstallContext(options.argv, options.env, options.fileExists, options.readFile).storeDir
163
+ : null;
104
164
  if (options.platform === 'win32') {
105
165
  return resolveWindowsManagerInvocation(manager, packageSpec, options);
106
166
  }
107
167
  return {
108
168
  file: executableForManager(manager),
109
- args: installArgsForManager(manager, packageSpec),
169
+ args: installArgsForManager(manager, packageSpec, pnpmStoreDir),
110
170
  };
111
171
  }
@@ -1 +1 @@
1
- {"version":3,"file":"tool-bundle-update-guard.d.ts","sourceRoot":"","sources":["../../src/app/tool-bundle-update-guard.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAI/D,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,aAAa,GAAG,YAAY,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,4BAA6B,SAAQ,qBAAqB;IACzE,WAAW,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,CAAC,iCAAiC,CAAM,GACzD,OAAO,CAAC,OAAO,CAAC,CA8ElB"}
@@ -81,7 +81,7 @@ export async function guardBundledToolMutation(options, overrides = {}) {
81
81
  'can only install its own bundled tool versions. The available CLI may ' +
82
82
  'bundle newer tool versions.');
83
83
  const packageSpec = `${CLI_PACKAGE}@${availableVersion}`;
84
- const installCommand = formatGlobalCliInstallCommand(packageSpec, options.argv, options.env);
84
+ const installCommand = formatGlobalCliInstallCommand(packageSpec, options.argv, options.env, dependencies.fileExists);
85
85
  let accepted = false;
86
86
  try {
87
87
  accepted = await dependencies.confirmAction(`Update the OAT CLI to ${availableVersion} before running ${options.commandPath}?`, { interactive: options.interactive });
@@ -114,7 +114,7 @@ export async function guardBundledToolMutation(options, overrides = {}) {
114
114
  }
115
115
  catch {
116
116
  throw new CliError(`Failed to update the OAT CLI to ${availableVersion}. ` +
117
- `No tools were changed. Fix the npm installation issue and run: ${installCommand}`, 2);
117
+ `No tools were changed. Fix the package manager installation issue and run: ${installCommand}`, 2);
118
118
  }
119
119
  options.logger.info(`Updated the OAT CLI to ${availableVersion}. To let the new CLI install ` +
120
120
  `its bundled tools, rerun in ${options.rerunCommand.shell}:\n${options.rerunCommand.command}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-agent-toolkit/cli",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "private": false,
5
5
  "description": "Open Agent Toolkit CLI",
6
6
  "homepage": "https://github.com/voxmedia/open-agent-toolkit/tree/main/packages/cli",
@@ -34,7 +34,7 @@
34
34
  "ora": "^9.0.0",
35
35
  "yaml": "2.8.2",
36
36
  "zod": "^3.25.76",
37
- "@open-agent-toolkit/control-plane": "0.2.15"
37
+ "@open-agent-toolkit/control-plane": "0.2.16"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/node": "^22.10.0",