Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions apps/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,53 @@
# Changelog

## 1.0.0 - 2025-10-23

### 🎉 Major Release: Stash System

Git-inspired stash system for complete conflict management and backups.

#### Added

**Stash System Core**:
- HashCalculator with SHA-256 for file integrity
- StashLogger with JSONL logging
- StashManager for complete lifecycle
- ConflictDetector for automatic detection
- ConflictResolver with interactive prompts

**CLI Commands** (8 new commands):
- `vdt stash list` - List all stashes
- `vdt stash show <id>` - Show details
- `vdt stash apply <id>` - Apply (keep)
- `vdt stash pop <id>` - Apply and remove
- `vdt stash remove <id>` - Remove stash
- `vdt stash diff <id>` - Show differences
- `vdt stash save [files]` - Manual stash
- `vdt stash clear` - Clear all

**Update Command**:
- `vdt update <package> --version <ver>`
- `vdt update <package> --latest`
- `vdt update <package> --dry-run`

**Install Enhancements**:
- Automatic conflict detection
- Interactive resolution (overwrite/stash/cancel)
- `--dry-run` flag for preview
- Stash metadata with versions

#### Changed

- Install now uses `force: true` after conflicts resolved
- Install shows stash info on success

#### Dependencies

- Added `inquirer@^9.2.0`
- Added `diff@^5.1.0`
- Added `@types/inquirer@^9.0.0`
- Added `@types/diff@^5.0.0`

## 0.7.1

### Patch Changes
Expand Down
232 changes: 232 additions & 0 deletions apps/cli/STASH-SYSTEM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# Stash System

Sistema de gestão de conflitos e backups para vibe-devtools, inspirado no `git stash`.

## Overview

O Stash System permite que você gerencie arquivos durante instalação/atualização de packages com controle total sobre o que sobrescrever, manter ou arquivar.

### Features

- ✅ Detecção automática de conflitos via SHA-256 hash
- ✅ Backup seguro com full copy (não patch)
- ✅ Comandos CLI familiares (inspirados no git stash)
- ✅ FILO ordering com renumeração automática
- ✅ Logging completo em JSONL
- ✅ Dry-run support
- ✅ Integration com install e update commands

## Quick Start

### Install com Detecção de Conflitos

```bash
npx vibe-devtools install @vibe-devtools/basic
```

Se houver conflitos, você verá:

```
⚠️ Conflicts detected (3 files)

1. vibes/configs/constitution.md
Local: abc123...
Package: def456...

How to resolve conflicts?
[1] Overwrite with package version
[2] Stash local and install package
[3] Cancel installation
```

Escolha opção 2 para criar backup automático.

### Update com Stash

```bash
npx vibe-devtools update @vibe-devtools/basic --latest
npx vibe-devtools update @vibe-devtools/basic --version 1.0.3
npx vibe-devtools update @vibe-devtools/basic --dry-run
```

### Dry Run

Preview mudanças sem instalar:

```bash
npx vibe-devtools install @vibe-devtools/basic --dry-run
```

## Comandos Stash

### List

Lista todos os stashes:

```bash
npx vibe-devtools stash list
```

Output:
```
stash{0} - @vibe-devtools/basic
install • 2025-10-23 14:30 • 3 files

stash{1} - manual
manual • 2025-10-23 15:45 • 2 files

Total: 2 stashes
```

### Show

Mostra detalhes de um stash:

```bash
npx vibe-devtools stash show 0
```

### Apply

Aplica stash (mantém no histórico):

```bash
npx vibe-devtools stash apply 0
```

### Pop

Aplica stash e remove do histórico:

```bash
npx vibe-devtools stash pop 0
```

### Remove

Remove um stash:

```bash
npx vibe-devtools stash remove 0
```

### Diff

Mostra diferenças entre stash e arquivos atuais:

```bash
npx vibe-devtools stash diff 0
npx vibe-devtools stash diff 0 --editor # abre no IDE
```

### Save

Cria stash manual:

```bash
npx vibe-devtools stash save file1.ts file2.ts
npx vibe-devtools stash save # prompt interativo
```

### Clear

Remove todos os stashes:

```bash
npx vibe-devtools stash clear
npx vibe-devtools stash clear --force # sem confirmação
```

## Architecture

### Components

- **HashCalculator**: SHA-256 hash calculation
- **StashLogger**: JSONL logging system
- **StashManager**: Core lifecycle management
- **ConflictDetector**: Hash-based conflict detection
- **ConflictResolver**: CLI prompts & diff display

### Storage

```
~/.vibes/stash/
├── index.json # Lista de stashes
├── stash-0/
│ ├── metadata.json # Metadata do stash
│ └── files/ # Full copy dos arquivos
└── stash-1/
├── metadata.json
└── files/
```

### Logging

```
~/.vibes/logs/stash.log
```

Format: JSONL (1 JSON per line)

## Technical Details

### Hash Algorithm

SHA-256 via Node.js crypto (nativo)

### Storage Strategy

Full copy (não patch) para:
- Simplicidade e confiabilidade
- Suporte a qualquer tipo de arquivo
- Sempre funciona (não corrompe)

### Ordering

FILO (First In Last Out) com renumeração:
- `stash{0}` é sempre o mais recente
- Após `pop` ou `remove`, IDs são renumerados
- Igual ao `git stash`

## Error Handling

### Permission Denied

Se erro de permissão em `~/.vibes/stash/`:

```bash
sudo chown -R $USER ~/.vibes
```

### Stash Corrupted

Sistema valida integridade via hash antes de aplicar. Se corrompido:

```bash
npx vibe-devtools stash remove <stash-id>
```

### Disk Full

Libere espaço ou:

```bash
npx vibe-devtools stash clear
```

## Performance

- Hash calculation: < 100ms (arquivos < 1MB)
- Stash creation: < 1s (< 100 arquivos)
- Stash apply: < 1s (< 100 arquivos)

## Dependencies

- `inquirer@^9.2.0` - CLI prompts
- `diff@^5.1.0` - Diff display

## Compatibility

- Node.js >= 18.0.0
- Works on: macOS, Linux, Windows

2 changes: 1 addition & 1 deletion apps/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vibe-devtools",
"version": "0.7.1",
"version": "1.0.0",
"description": "CLI tool to install and manage vibes (agentic command packages)",
"type": "module",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion apps/cli/src/adapters/copilot-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export class CopilotAdapter extends BaseAdapter {
const promptPath = path.join(promptsDir, `${cmdName}.prompt.md`);

let content = `# ${cmdName} Command Prompt\n\n`;

if (frontmatter.description) {
content += `**Description**: ${frontmatter.description}\n\n`;
}
Expand Down
Loading