Skip to content

Commit 32c1578

Browse files
committed
feat(cli): introduce stash system for conflict management and backups
- Added a comprehensive stash system inspired by Git, allowing users to manage file conflicts during installations and updates. - Implemented new CLI commands for stashing, including `stash list`, `stash show`, `stash apply`, `stash pop`, `stash remove`, `stash diff`, `stash save`, and `stash clear`. - Enhanced install and update commands with automatic conflict detection and interactive resolution options. - Introduced `HashCalculator`, `StashLogger`, `StashManager`, `ConflictDetector`, and `ConflictResolver` for managing stashes and conflicts. - Updated dependencies: `inquirer@^9.2.0`, `diff@^5.1.0`, `@types/inquirer@^9.0.0`, `@types/diff@^5.0.0`. - Version bumped to 1.0.0 to reflect major changes.
1 parent 9ad1803 commit 32c1578

9 files changed

Lines changed: 1000 additions & 10 deletions

File tree

apps/cli/CHANGELOG.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,53 @@
11
# Changelog
22

3+
## 1.0.0 - 2025-10-23
4+
5+
### 🎉 Major Release: Stash System
6+
7+
Git-inspired stash system for complete conflict management and backups.
8+
9+
#### Added
10+
11+
**Stash System Core**:
12+
- HashCalculator with SHA-256 for file integrity
13+
- StashLogger with JSONL logging
14+
- StashManager for complete lifecycle
15+
- ConflictDetector for automatic detection
16+
- ConflictResolver with interactive prompts
17+
18+
**CLI Commands** (8 new commands):
19+
- `vdt stash list` - List all stashes
20+
- `vdt stash show <id>` - Show details
21+
- `vdt stash apply <id>` - Apply (keep)
22+
- `vdt stash pop <id>` - Apply and remove
23+
- `vdt stash remove <id>` - Remove stash
24+
- `vdt stash diff <id>` - Show differences
25+
- `vdt stash save [files]` - Manual stash
26+
- `vdt stash clear` - Clear all
27+
28+
**Update Command**:
29+
- `vdt update <package> --version <ver>`
30+
- `vdt update <package> --latest`
31+
- `vdt update <package> --dry-run`
32+
33+
**Install Enhancements**:
34+
- Automatic conflict detection
35+
- Interactive resolution (overwrite/stash/cancel)
36+
- `--dry-run` flag for preview
37+
- Stash metadata with versions
38+
39+
#### Changed
40+
41+
- Install now uses `force: true` after conflicts resolved
42+
- Install shows stash info on success
43+
44+
#### Dependencies
45+
46+
- Added `inquirer@^9.2.0`
47+
- Added `diff@^5.1.0`
48+
- Added `@types/inquirer@^9.0.0`
49+
- Added `@types/diff@^5.0.0`
50+
351
## 0.7.1
452

553
### Patch Changes

apps/cli/STASH-SYSTEM.md

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
# Stash System
2+
3+
Sistema de gestão de conflitos e backups para vibe-devtools, inspirado no `git stash`.
4+
5+
## Overview
6+
7+
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.
8+
9+
### Features
10+
11+
- ✅ Detecção automática de conflitos via SHA-256 hash
12+
- ✅ Backup seguro com full copy (não patch)
13+
- ✅ Comandos CLI familiares (inspirados no git stash)
14+
- ✅ FILO ordering com renumeração automática
15+
- ✅ Logging completo em JSONL
16+
- ✅ Dry-run support
17+
- ✅ Integration com install e update commands
18+
19+
## Quick Start
20+
21+
### Install com Detecção de Conflitos
22+
23+
```bash
24+
npx vibe-devtools install @vibe-devtools/basic
25+
```
26+
27+
Se houver conflitos, você verá:
28+
29+
```
30+
⚠️ Conflicts detected (3 files)
31+
32+
1. vibes/configs/constitution.md
33+
Local: abc123...
34+
Package: def456...
35+
36+
How to resolve conflicts?
37+
[1] Overwrite with package version
38+
[2] Stash local and install package
39+
[3] Cancel installation
40+
```
41+
42+
Escolha opção 2 para criar backup automático.
43+
44+
### Update com Stash
45+
46+
```bash
47+
npx vibe-devtools update @vibe-devtools/basic --latest
48+
npx vibe-devtools update @vibe-devtools/basic --version 1.0.3
49+
npx vibe-devtools update @vibe-devtools/basic --dry-run
50+
```
51+
52+
### Dry Run
53+
54+
Preview mudanças sem instalar:
55+
56+
```bash
57+
npx vibe-devtools install @vibe-devtools/basic --dry-run
58+
```
59+
60+
## Comandos Stash
61+
62+
### List
63+
64+
Lista todos os stashes:
65+
66+
```bash
67+
npx vibe-devtools stash list
68+
```
69+
70+
Output:
71+
```
72+
stash{0} - @vibe-devtools/basic
73+
install • 2025-10-23 14:30 • 3 files
74+
75+
stash{1} - manual
76+
manual • 2025-10-23 15:45 • 2 files
77+
78+
Total: 2 stashes
79+
```
80+
81+
### Show
82+
83+
Mostra detalhes de um stash:
84+
85+
```bash
86+
npx vibe-devtools stash show 0
87+
```
88+
89+
### Apply
90+
91+
Aplica stash (mantém no histórico):
92+
93+
```bash
94+
npx vibe-devtools stash apply 0
95+
```
96+
97+
### Pop
98+
99+
Aplica stash e remove do histórico:
100+
101+
```bash
102+
npx vibe-devtools stash pop 0
103+
```
104+
105+
### Remove
106+
107+
Remove um stash:
108+
109+
```bash
110+
npx vibe-devtools stash remove 0
111+
```
112+
113+
### Diff
114+
115+
Mostra diferenças entre stash e arquivos atuais:
116+
117+
```bash
118+
npx vibe-devtools stash diff 0
119+
npx vibe-devtools stash diff 0 --editor # abre no IDE
120+
```
121+
122+
### Save
123+
124+
Cria stash manual:
125+
126+
```bash
127+
npx vibe-devtools stash save file1.ts file2.ts
128+
npx vibe-devtools stash save # prompt interativo
129+
```
130+
131+
### Clear
132+
133+
Remove todos os stashes:
134+
135+
```bash
136+
npx vibe-devtools stash clear
137+
npx vibe-devtools stash clear --force # sem confirmação
138+
```
139+
140+
## Architecture
141+
142+
### Components
143+
144+
- **HashCalculator**: SHA-256 hash calculation
145+
- **StashLogger**: JSONL logging system
146+
- **StashManager**: Core lifecycle management
147+
- **ConflictDetector**: Hash-based conflict detection
148+
- **ConflictResolver**: CLI prompts & diff display
149+
150+
### Storage
151+
152+
```
153+
~/.vibes/stash/
154+
├── index.json # Lista de stashes
155+
├── stash-0/
156+
│ ├── metadata.json # Metadata do stash
157+
│ └── files/ # Full copy dos arquivos
158+
└── stash-1/
159+
├── metadata.json
160+
└── files/
161+
```
162+
163+
### Logging
164+
165+
```
166+
~/.vibes/logs/stash.log
167+
```
168+
169+
Format: JSONL (1 JSON per line)
170+
171+
## Technical Details
172+
173+
### Hash Algorithm
174+
175+
SHA-256 via Node.js crypto (nativo)
176+
177+
### Storage Strategy
178+
179+
Full copy (não patch) para:
180+
- Simplicidade e confiabilidade
181+
- Suporte a qualquer tipo de arquivo
182+
- Sempre funciona (não corrompe)
183+
184+
### Ordering
185+
186+
FILO (First In Last Out) com renumeração:
187+
- `stash{0}` é sempre o mais recente
188+
- Após `pop` ou `remove`, IDs são renumerados
189+
- Igual ao `git stash`
190+
191+
## Error Handling
192+
193+
### Permission Denied
194+
195+
Se erro de permissão em `~/.vibes/stash/`:
196+
197+
```bash
198+
sudo chown -R $USER ~/.vibes
199+
```
200+
201+
### Stash Corrupted
202+
203+
Sistema valida integridade via hash antes de aplicar. Se corrompido:
204+
205+
```bash
206+
npx vibe-devtools stash remove <stash-id>
207+
```
208+
209+
### Disk Full
210+
211+
Libere espaço ou:
212+
213+
```bash
214+
npx vibe-devtools stash clear
215+
```
216+
217+
## Performance
218+
219+
- Hash calculation: < 100ms (arquivos < 1MB)
220+
- Stash creation: < 1s (< 100 arquivos)
221+
- Stash apply: < 1s (< 100 arquivos)
222+
223+
## Dependencies
224+
225+
- `inquirer@^9.2.0` - CLI prompts
226+
- `diff@^5.1.0` - Diff display
227+
228+
## Compatibility
229+
230+
- Node.js >= 18.0.0
231+
- Works on: macOS, Linux, Windows
232+

apps/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vibe-devtools",
3-
"version": "0.7.1",
3+
"version": "1.0.0",
44
"description": "CLI tool to install and manage vibes (agentic command packages)",
55
"type": "module",
66
"main": "dist/index.js",

apps/cli/src/adapters/copilot-adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export class CopilotAdapter extends BaseAdapter {
139139
const promptPath = path.join(promptsDir, `${cmdName}.prompt.md`);
140140

141141
let content = `# ${cmdName} Command Prompt\n\n`;
142-
142+
143143
if (frontmatter.description) {
144144
content += `**Description**: ${frontmatter.description}\n\n`;
145145
}

0 commit comments

Comments
 (0)