@vypdev/copilot 3.7.0 → 3.8.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.
Files changed (2) hide show
  1. package/build/cli/index.js +204 -59
  2. package/package.json +1 -1
@@ -72385,7 +72385,7 @@ class UpgradeCliUseCase {
72385
72385
  this.cliUpgradePort = cliUpgradePort;
72386
72386
  }
72387
72387
  async execute() {
72388
- await this.cliUpgradePort.upgrade();
72388
+ return this.cliUpgradePort.upgrade();
72389
72389
  }
72390
72390
  }
72391
72391
  exports.UpgradeCliUseCase = UpgradeCliUseCase;
@@ -74107,10 +74107,10 @@ exports.registerUpgradeCommand = registerUpgradeCommand;
74107
74107
  const cli_upgrade_composition_root_1 = __nccwpck_require__(74142);
74108
74108
  const application_error_1 = __nccwpck_require__(75999);
74109
74109
  async function runUpgradeCommand(runner = (0, cli_upgrade_composition_root_1.createUpgradeCliUseCase)()) {
74110
- console.log('⬆️ Updating the global @vypdev/copilot installation...');
74110
+ console.log('⬆️ Updating the active @vypdev/copilot installation and verifying "copilot --version"...');
74111
74111
  try {
74112
- await runner.execute();
74113
- console.log('✅ Copilot was upgraded successfully. Run "copilot --version" to verify.');
74112
+ const result = await runner.execute();
74113
+ console.log(`✅ Copilot ${result.version} was upgraded successfully via ${result.packageManager}. "copilot --version" verified.`);
74114
74114
  }
74115
74115
  catch (error) {
74116
74116
  const semanticError = (0, application_error_1.toApplicationError)(error, 'provider.unavailable', 'Unable to upgrade Copilot.');
@@ -74121,7 +74121,7 @@ async function runUpgradeCommand(runner = (0, cli_upgrade_composition_root_1.cre
74121
74121
  function registerUpgradeCommand(program) {
74122
74122
  program
74123
74123
  .command('upgrade')
74124
- .description('Upgrade the global @vypdev/copilot installation to the latest published version')
74124
+ .description('Upgrade the active npm or pnpm @vypdev/copilot installation and verify its effective version')
74125
74125
  .action(() => runUpgradeCommand());
74126
74126
  }
74127
74127
 
@@ -93717,6 +93717,203 @@ function invalid(reason, code) {
93717
93717
  }
93718
93718
 
93719
93719
 
93720
+ /***/ }),
93721
+
93722
+ /***/ 56489:
93723
+ /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
93724
+
93725
+ "use strict";
93726
+
93727
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
93728
+ exports.ActiveCliUpgradeAdapter = void 0;
93729
+ exports.isSameCliPath = isSameCliPath;
93730
+ exports.resolveCliExecutable = resolveCliExecutable;
93731
+ const exec_1 = __nccwpck_require__(18538);
93732
+ const node_fs_1 = __nccwpck_require__(87561);
93733
+ const node_path_1 = __nccwpck_require__(49411);
93734
+ const application_error_1 = __nccwpck_require__(75999);
93735
+ const copilot_package_1 = __nccwpck_require__(76182);
93736
+ const VERSION_PATTERN = /^\d+\.\d+\.\d+(?:-[\da-zA-Z.-]+)?(?:\+[\da-zA-Z.-]+)?$/u;
93737
+ /** Compare canonical paths using the filesystem's platform rules, including .CMD casing. */
93738
+ function isSameCliPath(left, right, platform = process.platform) {
93739
+ return (platform === 'win32' ? node_path_1.win32 : node_path_1.posix).relative(left, right) === '';
93740
+ }
93741
+ /** Retain the PATH spelling: pnpm wrappers and npm links are replaced in place. */
93742
+ function resolveCliExecutable(name, environment, platform = process.platform) {
93743
+ const extensions = platform === 'win32'
93744
+ ? (environment.PATHEXT || '.EXE;.CMD;.BAT;.COM').split(';')
93745
+ : [''];
93746
+ for (const directory of (environment.PATH || environment.Path || '').split(node_path_1.delimiter)) {
93747
+ for (const extension of extensions) {
93748
+ const candidate = (0, node_path_1.resolve)(directory || '.', `${name}${extension}`);
93749
+ try {
93750
+ (0, node_fs_1.accessSync)(candidate, node_fs_1.constants.X_OK);
93751
+ if ((0, node_fs_1.statSync)(candidate).isFile())
93752
+ return candidate;
93753
+ }
93754
+ catch {
93755
+ // Continue to the next PATH candidate.
93756
+ }
93757
+ }
93758
+ }
93759
+ throw new application_error_1.ApplicationError('configuration.invalid', `The ${name} command is unavailable on PATH. Restore the active installation's command and retry.`);
93760
+ }
93761
+ function readInstalledPackage(packagePath) {
93762
+ const root = (0, node_fs_1.realpathSync)(packagePath);
93763
+ const metadata = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(root, 'package.json'), 'utf8'));
93764
+ const bin = metadata.bin?.copilot;
93765
+ if (metadata.name !== copilot_package_1.COPILOT_PACKAGE_NAME || typeof metadata.version !== 'string'
93766
+ || !VERSION_PATTERN.test(metadata.version) || typeof bin !== 'string' || (0, node_path_1.isAbsolute)(bin)) {
93767
+ throw new Error('Invalid Copilot package identity or executable.');
93768
+ }
93769
+ const entrypoint = (0, node_fs_1.realpathSync)((0, node_path_1.resolve)(root, bin));
93770
+ const relation = (0, node_path_1.relative)(root, entrypoint);
93771
+ if (!relation || relation === '..' || relation.startsWith(`..${node_path_1.sep}`) || (0, node_path_1.isAbsolute)(relation)) {
93772
+ throw new Error('Copilot executable escaped its package.');
93773
+ }
93774
+ if (!(0, node_fs_1.statSync)(entrypoint).isFile())
93775
+ throw new Error('Copilot executable is not a file.');
93776
+ return { root, version: metadata.version, entrypoint };
93777
+ }
93778
+ function readInvokedPackage(entrypoint, platform) {
93779
+ const invoked = (0, node_fs_1.realpathSync)(entrypoint);
93780
+ let directory = (0, node_path_1.dirname)(invoked);
93781
+ while (directory !== (0, node_path_1.dirname)(directory)) {
93782
+ try {
93783
+ const installed = readInstalledPackage(directory);
93784
+ if (isSameCliPath(installed.entrypoint, invoked, platform))
93785
+ return installed;
93786
+ }
93787
+ catch {
93788
+ // The published package root is above build/cli, not necessarily cwd.
93789
+ }
93790
+ directory = (0, node_path_1.dirname)(directory);
93791
+ }
93792
+ throw new application_error_1.ApplicationError('configuration.unsupported', 'The running Copilot package could not be identified. Reinstall it globally with npm or pnpm and retry.');
93793
+ }
93794
+ /** System adapter owns package-manager discovery, mutation and fresh process probes. */
93795
+ class ActiveCliUpgradeAdapter {
93796
+ constructor(options = {}) {
93797
+ this.environment = {};
93798
+ for (const [name, value] of Object.entries(options.environment ?? process.env)) {
93799
+ if (typeof value === 'string')
93800
+ this.environment[name] = value;
93801
+ }
93802
+ this.platform = options.platform ?? process.platform;
93803
+ this.entrypoint = options.entrypoint ?? process.argv[1];
93804
+ this.run = options.run ?? (async (executable, args, inheritOutput = false) => {
93805
+ // The toolkit handles Windows .cmd quoting as well as native executables.
93806
+ const result = await (0, exec_1.getExecOutput)(`"${executable.replace(/"/gu, '\\"')}"`, args, {
93807
+ env: this.environment,
93808
+ silent: !inheritOutput,
93809
+ });
93810
+ return result.stdout.trim();
93811
+ });
93812
+ }
93813
+ async upgrade() {
93814
+ const invoked = readInvokedPackage(this.entrypoint, this.platform);
93815
+ const installation = await this.resolveInstallation(invoked);
93816
+ this.assertEffectiveCommand(installation, false);
93817
+ let version;
93818
+ try {
93819
+ const response = JSON.parse(await this.run(installation.managerExecutable, ['view', `${copilot_package_1.COPILOT_PACKAGE_NAME}@latest`, 'version', '--json']));
93820
+ if (typeof response !== 'string' || !VERSION_PATTERN.test(response))
93821
+ throw new Error('Invalid version.');
93822
+ version = response;
93823
+ }
93824
+ catch (cause) {
93825
+ throw new application_error_1.ApplicationError('provider.unavailable', 'Unable to determine the latest Copilot version. No installation was changed; check the package registry connection and retry.', { cause });
93826
+ }
93827
+ try {
93828
+ const verb = installation.packageManager === 'npm' ? 'install' : 'add';
93829
+ await this.run(installation.managerExecutable, [verb, '--global', ...installation.locationArgs, `${copilot_package_1.COPILOT_PACKAGE_NAME}@${version}`], true);
93830
+ }
93831
+ catch (cause) {
93832
+ throw new application_error_1.ApplicationError('provider.unavailable', `The ${installation.packageManager} upgrade did not complete. Check its output and the active installation's permissions before retrying.`, { cause });
93833
+ }
93834
+ try {
93835
+ const installed = readInstalledPackage(installation.packagePath);
93836
+ const effectiveCommand = this.assertEffectiveCommand(installation, true);
93837
+ if (installation.packageManager === 'npm' && this.platform !== 'win32'
93838
+ && !isSameCliPath((0, node_fs_1.realpathSync)(effectiveCommand), installed.entrypoint, this.platform))
93839
+ throw new Error('The npm executable points outside its package.');
93840
+ const effectiveVersion = (await this.run(effectiveCommand, ['--version'])).trim();
93841
+ if (installed.version !== version || effectiveVersion !== version)
93842
+ throw new Error('Version mismatch.');
93843
+ return { version, packageManager: installation.packageManager, executablePath: effectiveCommand };
93844
+ }
93845
+ catch (cause) {
93846
+ throw new application_error_1.ApplicationError('workflow.failed', 'The installer completed, but the effective Copilot version could not be verified. Check "copilot --version" and PATH, refresh your shell command cache or open a new terminal, then retry. The installation may already be updated.', { cause });
93847
+ }
93848
+ }
93849
+ async resolveInstallation(invoked) {
93850
+ // A pnpm store package is not an npm prefix, even on Windows.
93851
+ const modules = (0, node_path_1.dirname)((0, node_path_1.dirname)(invoked.root));
93852
+ const npmPrefix = this.platform === 'win32' ? (0, node_path_1.dirname)(modules) : (0, node_path_1.dirname)((0, node_path_1.dirname)(modules));
93853
+ if ((0, node_path_1.basename)(modules) === 'node_modules' && !modules.includes(`${node_path_1.sep}.pnpm${node_path_1.sep}`)
93854
+ && (this.platform === 'win32' || (0, node_path_1.basename)((0, node_path_1.dirname)(modules)) === 'lib')) {
93855
+ try {
93856
+ const managerExecutable = resolveCliExecutable('npm', this.environment, this.platform);
93857
+ const root = (await this.run(managerExecutable, ['root', '--global', '--prefix', npmPrefix])).trim();
93858
+ const packagePath = (0, node_path_1.join)(root, ...copilot_package_1.COPILOT_PACKAGE_NAME.split('/'));
93859
+ const bin = this.platform === 'win32' ? npmPrefix : (0, node_path_1.join)(npmPrefix, 'bin');
93860
+ if ((0, node_path_1.isAbsolute)(root) && isSameCliPath(readInstalledPackage(packagePath).root, invoked.root, this.platform)) {
93861
+ (0, node_fs_1.accessSync)((0, node_path_1.join)(bin, this.commandName()), node_fs_1.constants.X_OK);
93862
+ if (this.platform !== 'win32' && !isSameCliPath((0, node_fs_1.realpathSync)((0, node_path_1.join)(bin, this.commandName())), invoked.entrypoint, this.platform)) {
93863
+ throw new Error('The npm executable does not belong to the invoked package.');
93864
+ }
93865
+ return {
93866
+ packageManager: 'npm', managerExecutable, packagePath,
93867
+ commandPath: (0, node_path_1.join)(bin, this.commandName()), locationArgs: ['--prefix', npmPrefix],
93868
+ };
93869
+ }
93870
+ }
93871
+ catch {
93872
+ // Probe pnpm rather than installing into an unrelated npm prefix.
93873
+ }
93874
+ }
93875
+ try {
93876
+ const managerExecutable = resolveCliExecutable('pnpm', this.environment, this.platform);
93877
+ const root = (await this.run(managerExecutable, ['root', '--global'])).trim();
93878
+ const packagePath = (0, node_path_1.join)(root, ...copilot_package_1.COPILOT_PACKAGE_NAME.split('/'));
93879
+ if ((0, node_path_1.isAbsolute)(root) && isSameCliPath(readInstalledPackage(packagePath).root, invoked.root, this.platform)) {
93880
+ const relation = (0, node_path_1.relative)((0, node_fs_1.realpathSync)(root), invoked.root);
93881
+ if (relation === '..' || relation.startsWith(`..${node_path_1.sep}`) || (0, node_path_1.isAbsolute)(relation)) {
93882
+ throw new Error('A linked source checkout is not an installed pnpm package.');
93883
+ }
93884
+ const bin = (await this.run(managerExecutable, ['bin', '--global'])).trim();
93885
+ if (!(0, node_path_1.isAbsolute)(bin))
93886
+ throw new Error('Invalid global bin directory.');
93887
+ // pnpm appends its layout version (e.g. 5) to --global-dir itself.
93888
+ const globalDirectory = (0, node_path_1.dirname)((0, node_path_1.dirname)(root));
93889
+ return {
93890
+ packageManager: 'pnpm', managerExecutable, packagePath,
93891
+ commandPath: (0, node_path_1.join)(bin, this.commandName()),
93892
+ locationArgs: ['--global-dir', globalDirectory, '--global-bin-dir', bin],
93893
+ };
93894
+ }
93895
+ }
93896
+ catch {
93897
+ // Unknown/local/linked installations must not mutate another installation.
93898
+ }
93899
+ throw new application_error_1.ApplicationError('configuration.unsupported', 'The active Copilot installation could not be matched to npm or pnpm. Restore its original package manager or reinstall it globally, then retry. No installation was changed.');
93900
+ }
93901
+ commandName() {
93902
+ return this.platform === 'win32' ? 'copilot.cmd' : 'copilot';
93903
+ }
93904
+ assertEffectiveCommand(installation, afterInstall) {
93905
+ const effective = resolveCliExecutable('copilot', this.environment, this.platform);
93906
+ if (!isSameCliPath((0, node_fs_1.realpathSync)(effective), (0, node_fs_1.realpathSync)(installation.commandPath), this.platform)) {
93907
+ throw new application_error_1.ApplicationError('configuration.invalid', afterInstall
93908
+ ? 'Another Copilot installation is taking priority on PATH.'
93909
+ : 'The running Copilot installation differs from the command on PATH. Fix PATH or invoke its active command, then retry. No installation was changed.');
93910
+ }
93911
+ return effective;
93912
+ }
93913
+ }
93914
+ exports.ActiveCliUpgradeAdapter = ActiveCliUpgradeAdapter;
93915
+
93916
+
93720
93917
  /***/ }),
93721
93918
 
93722
93919
  /***/ 76182:
@@ -93844,58 +94041,6 @@ class NpmCliUpdateCheckAdapter {
93844
94041
  exports.NpmCliUpdateCheckAdapter = NpmCliUpdateCheckAdapter;
93845
94042
 
93846
94043
 
93847
- /***/ }),
93848
-
93849
- /***/ 64975:
93850
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
93851
-
93852
- "use strict";
93853
-
93854
- Object.defineProperty(exports, "__esModule", ({ value: true }));
93855
- exports.PnpmCliUpgradeAdapter = void 0;
93856
- exports.resolvePnpmExecutable = resolvePnpmExecutable;
93857
- const node_child_process_1 = __nccwpck_require__(17718);
93858
- const copilot_package_1 = __nccwpck_require__(76182);
93859
- function resolvePnpmExecutable(platform = process.platform) {
93860
- return platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
93861
- }
93862
- /** Executes the pnpm installation without invoking a shell or interpolating user input. */
93863
- class PnpmCliUpgradeAdapter {
93864
- upgrade() {
93865
- const executable = resolvePnpmExecutable();
93866
- const args = ['add', '--global', `${copilot_package_1.COPILOT_PACKAGE_NAME}@latest`];
93867
- return new Promise((resolve, reject) => {
93868
- const child = (0, node_child_process_1.spawn)(executable, args, {
93869
- shell: false,
93870
- stdio: 'inherit',
93871
- });
93872
- let settled = false;
93873
- const fail = (error) => {
93874
- if (settled)
93875
- return;
93876
- settled = true;
93877
- reject(error);
93878
- };
93879
- child.once('error', (error) => {
93880
- fail(Object.assign(new Error('Unable to start the pnpm upgrade process.'), { cause: error }));
93881
- });
93882
- child.once('close', (code, signal) => {
93883
- if (settled)
93884
- return;
93885
- settled = true;
93886
- if (code === 0) {
93887
- resolve();
93888
- return;
93889
- }
93890
- const status = signal ? `signal ${signal}` : `exit code ${code ?? 'unknown'}`;
93891
- reject(new Error(`pnpm upgrade failed with ${status}.`));
93892
- });
93893
- });
93894
- }
93895
- }
93896
- exports.PnpmCliUpgradeAdapter = PnpmCliUpgradeAdapter;
93897
-
93898
-
93899
94044
  /***/ }),
93900
94045
 
93901
94046
  /***/ 233:
@@ -94190,8 +94335,8 @@ function createCliUpdateCheckUseCase() {
94190
94335
  Object.defineProperty(exports, "__esModule", ({ value: true }));
94191
94336
  exports.createUpgradeCliUseCase = createUpgradeCliUseCase;
94192
94337
  const upgrade_cli_use_case_1 = __nccwpck_require__(45762);
94193
- const pnpm_cli_upgrade_adapter_1 = __nccwpck_require__(64975);
94194
- function createUpgradeCliUseCase(cliUpgradePort = new pnpm_cli_upgrade_adapter_1.PnpmCliUpgradeAdapter()) {
94338
+ const active_cli_upgrade_adapter_1 = __nccwpck_require__(56489);
94339
+ function createUpgradeCliUseCase(cliUpgradePort = new active_cli_upgrade_adapter_1.ActiveCliUpgradeAdapter()) {
94195
94340
  return new upgrade_cli_use_case_1.UpgradeCliUseCase(cliUpgradePort);
94196
94341
  }
94197
94342
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vypdev/copilot",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "packageManager": "pnpm@10.12.4",
5
5
  "pnpm": {
6
6
  "overrides": {