Skip to content

Commit 91c6b83

Browse files
committed
fix: ajuste no workflow para dist no npm
1 parent 7c755ca commit 91c6b83

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

apps/cli/src/commands/install.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ export async function installCommand(
158158
source: string,
159159
options: { conflict?: string; agent?: string; dryRun?: boolean } = {}
160160
): Promise<void> {
161+
const projectRoot = path.resolve(process.cwd());
162+
const criticalPaths = [
163+
'/', '/usr', '/etc', '/var', '/System', '/Library', '/bin', '/sbin', '/opt', '/boot',
164+
'/private/etc', '/private/var', '/private/tmp'
165+
];
166+
167+
const isCriticalDir = criticalPaths.some(critical => {
168+
const resolvedCritical = path.resolve(critical);
169+
return projectRoot === resolvedCritical || projectRoot.startsWith(resolvedCritical + path.sep);
170+
});
171+
172+
if (isCriticalDir) {
173+
console.error(chalk.red(`❌ Cannot install in critical system directory: ${projectRoot}`));
174+
console.error(chalk.yellow('Please run from a safe project directory.'));
175+
throw new Error(`Installation blocked: critical system directory`);
176+
}
177+
161178
const spinner = ora('Installing vibe...').start();
162179

163180
try {
@@ -197,7 +214,6 @@ export async function installCommand(
197214

198215
spinner.text = 'Detecting agents...';
199216

200-
const projectRoot = process.cwd();
201217
const adapters = AdapterRegistry.getAllAdapters();
202218
const detector = new AgentDetector(adapters);
203219
let detectedAgents = await detector.detectAll();

apps/cli/src/commands/update.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ export async function updateCommand(
6363
dryRun?: boolean;
6464
} = {}
6565
): Promise<void> {
66+
const projectRoot = path.resolve(process.cwd());
67+
const criticalPaths = [
68+
'/', '/usr', '/etc', '/var', '/System', '/Library', '/bin', '/sbin', '/opt', '/boot',
69+
'/private/etc', '/private/var', '/private/tmp'
70+
];
71+
72+
const isCriticalDir = criticalPaths.some(critical => {
73+
const resolvedCritical = path.resolve(critical);
74+
return projectRoot === resolvedCritical || projectRoot.startsWith(resolvedCritical + path.sep);
75+
});
76+
77+
if (isCriticalDir) {
78+
console.error(chalk.red(`❌ Cannot update in critical system directory: ${projectRoot}`));
79+
console.error(chalk.yellow('Please run from a safe project directory.'));
80+
throw new Error(`Update blocked: critical system directory`);
81+
}
82+
6683
const spinner = ora('Updating vibe...').start();
6784

6885
try {
@@ -92,7 +109,6 @@ export async function updateCommand(
92109
vibeManifest = result.manifest;
93110
}
94111

95-
const projectRoot = process.cwd();
96112
const vibeDir = getVibePackageDir(vibeManifest.name, vibeManifest.version);
97113

98114
if (!vibeManifest.symlinks) {

apps/cli/src/stash/conflict-detector.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { existsSync, statSync } from 'node:fs';
22
import path from 'node:path';
3+
import crypto from 'node:crypto';
34
import { HashCalculator } from './hash-calculator.js';
45

56
export interface Conflict {
@@ -68,7 +69,9 @@ export class ConflictDetector {
6869
if (stats.isDirectory()) {
6970
const hashes = await this.hashCalculator.calculateDirectory(filePath);
7071
const allHashes = Array.from(hashes.values()).join('');
71-
return this.hashCalculator.calculateFile(Buffer.from(allHashes) as any) || allHashes.substring(0, 64);
72+
const hash = crypto.createHash('sha256');
73+
hash.update(allHashes);
74+
return hash.digest('hex');
7275
}
7376

7477
return this.hashCalculator.calculateFile(filePath);

0 commit comments

Comments
 (0)