@vibe-assurance/cli 1.7.1 → 1.7.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": "@vibe-assurance/cli",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Vibe Assurance CLI - Connect AI coding agents to your governance platform via MCP",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -8,7 +8,7 @@
8
8
 
9
9
  const chalk = require('chalk');
10
10
  const ora = require('ora');
11
- const { getEnvironment, setEnvironment, isAdmin, hasValidCredentials } = require('../config/credentials');
11
+ const { getEnvironment, setEnvironment, isAdmin, hasValidCredentials, deleteCredentials } = require('../config/credentials');
12
12
  const {
13
13
  ENVIRONMENTS,
14
14
  getEnvironmentConfig,
@@ -91,10 +91,12 @@ async function listEnvironments() {
91
91
  /**
92
92
  * CR-2026-061: Switch to a specific environment
93
93
  * Internal environments require admin role
94
+ * Switching environments clears credentials and requires re-login
94
95
  * @param {string} envName - Environment name (prod, dev, local)
95
96
  */
96
97
  async function switchEnvironment(envName) {
97
98
  const config = getEnvironmentConfig(envName);
99
+ const currentEnv = await getEnvironment();
98
100
 
99
101
  if (!config) {
100
102
  console.error(chalk.red(`Unknown environment: ${envName}`));
@@ -102,6 +104,12 @@ async function switchEnvironment(envName) {
102
104
  process.exit(1);
103
105
  }
104
106
 
107
+ // Already on this environment?
108
+ if (envName === currentEnv) {
109
+ console.log(chalk.yellow(`Already using ${config.name} environment.`));
110
+ return;
111
+ }
112
+
105
113
  // Check if internal environment - require admin
106
114
  if (isInternalOnly(envName)) {
107
115
  // Must be logged in first
@@ -125,6 +133,10 @@ async function switchEnvironment(envName) {
125
133
  const spinner = ora(`Switching to ${config.name}...`).start();
126
134
 
127
135
  try {
136
+ // Clear existing credentials - different environments have different auth
137
+ await deleteCredentials();
138
+
139
+ // Store only the new environment (no auth tokens)
128
140
  await setEnvironment(envName);
129
141
  spinner.succeed(`Switched to ${chalk.bold(config.name)}`);
130
142
 
@@ -134,11 +146,10 @@ async function switchEnvironment(envName) {
134
146
  if (config.internal) {
135
147
  console.log('');
136
148
  console.log(chalk.yellow('⚠ You are now using an internal environment.'));
137
- console.log(chalk.dim(' Run `vibe env prod` to switch back to production.'));
138
149
  }
139
150
 
140
151
  console.log('');
141
- console.log(chalk.dim('Note: You may need to run `vibe login` to authenticate with this environment.'));
152
+ console.log(chalk.cyan('You have been logged out. Run `vibe login` to authenticate with this environment.'));
142
153
  console.log('');
143
154
  } catch (err) {
144
155
  spinner.fail('Failed to switch environment');