peridot-cli 0.4.1__tar.gz

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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Francisco Puga Lojo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,417 @@
1
+ Metadata-Version: 2.4
2
+ Name: peridot-cli
3
+ Version: 0.4.1
4
+ Summary: Visual CLI for portable configuration bundles
5
+ Author: Francisco Puga Lojo
6
+ Project-URL: Homepage, https://github.com/pugafran/peridot
7
+ Project-URL: Repository, https://github.com/pugafran/peridot
8
+ Project-URL: Issues, https://github.com/pugafran/peridot/issues
9
+ Project-URL: Changelog, https://github.com/pugafran/peridot/blob/main/CHANGELOG.md
10
+ Keywords: dotfiles,backup,cli,config,portable,terminal
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: Microsoft :: Windows
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Topic :: System :: Archiving
20
+ Classifier: Topic :: Utilities
21
+ Requires-Python: >=3.11
22
+ Description-Content-Type: text/markdown
23
+ License-File: LICENSE
24
+ Requires-Dist: cryptography<46.0.0,>=42.0.0
25
+ Requires-Dist: questionary<3.0.0,>=2.1.0
26
+ Requires-Dist: rich<15.0.0,>=13.7.0
27
+ Requires-Dist: zstandard<1.0.0,>=0.23.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
30
+ Dynamic: license-file
31
+
32
+ ![Showcase](misc/showcase.png)
33
+
34
+ # Peridot
35
+
36
+ ![CI](https://github.com/pugafran/peridot/actions/workflows/ci.yml/badge.svg)
37
+
38
+ Current release: `0.4.1`. See `CHANGELOG.md` for release notes.
39
+
40
+ Peridot es una herramienta de terminal para empaquetar configuraciones en bundles `.peridot`, inspeccionarlos antes de aplicar nada y restaurarlos en otra maquina con una UX visual cuidada.
41
+
42
+ La idea es simple:
43
+
44
+ - creas un bundle con tus dotfiles o carpetas de config
45
+ - el bundle lleva una ficha visible con metadata, plataforma objetivo y listado de archivos
46
+ - el contenido va comprimido y cifrado, pero el `manifest.json` queda accesible para poder revisar el paquete antes de aplicarlo
47
+ - todo ocurre en terminal; no hay dashboard web ni dependencia de frontend externo
48
+
49
+ Peridot comprime y luego cifra cada fichero. Eso reduce tamaño, pero puede hacer `pack` mas lento. Por defecto ahora usa compresion rapida (`compression_level = 1`) para priorizar velocidad. El codec principal es `zstd`; si la dependencia no esta disponible en ese Python, cae automaticamente a `gzip`. El contenedor `.peridot` exterior no recomprime payloads ya cifrados, asi que `pack` es mas rapido que antes.
50
+
51
+ ## Que es un `.peridot`
52
+
53
+ Un archivo `.peridot` es un ZIP con esta estructura:
54
+
55
+ ```text
56
+ my-setup.peridot
57
+ ├── manifest.json
58
+ └── payloads/
59
+ ├── 0001-....bin
60
+ ├── 0002-....bin
61
+ └── ...
62
+ ```
63
+
64
+ `manifest.json` contiene la ficha del bundle:
65
+
66
+ - nombre y descripcion
67
+ - sistema objetivo: `macos`, `linux`, `windows` o `any`
68
+ - shell o runtime principal: `fish`, `zsh`, `bash`, `powershell`, etc.
69
+ - arquitectura objetivo
70
+ - tags
71
+ - host y usuario que generaron el bundle
72
+ - numero de archivos y peso total
73
+ - lista de archivos con `path`, `mode`, `sha256` y payload asociado
74
+
75
+ Los payloads contienen el contenido real de cada fichero, comprimido con `zstd` cuando compensa y con fallback a `gzip` si ese Python no tiene `zstandard`, y cifrado con `AES-GCM`.
76
+
77
+ ## Instalacion
78
+
79
+ ### Windows (recomendado): pipx
80
+
81
+ Nota: el nombre en PyPI será **peridot-cli** ("peridot" ya está ocupado).
82
+
83
+ `pipx` instala CLIs de Python en un entorno aislado y te deja el comando en PATH.
84
+
85
+ 1) Instala **Python 3.11+** (desde python.org o Microsoft Store) y asegúrate de que está en PATH.
86
+ 2) Instala `pipx`:
87
+
88
+ ```powershell
89
+ python -m pip install --user pipx
90
+ python -m pipx ensurepath
91
+ ```
92
+
93
+ Cierra y vuelve a abrir la terminal.
94
+
95
+ 3) Instala Peridot:
96
+
97
+ Si está publicado en PyPI:
98
+
99
+ ```powershell
100
+ pipx install peridot-cli
101
+ peridot --version
102
+ ```
103
+
104
+ Si quieres instalarlo desde GitHub:
105
+
106
+ ```powershell
107
+ pipx install "git+https://github.com/pugafran/peridot.git"
108
+ peridot --version
109
+ ```
110
+
111
+ ### macOS / Linux
112
+
113
+ Recomendado (modo dev, con tests):
114
+
115
+ ```bash
116
+ ./install.sh
117
+ # opcional: instala dependencias de desarrollo (pytest, etc.)
118
+ PERIDOT_INSTALL_DEV=1 ./install.sh
119
+
120
+ peridot --version
121
+ ```
122
+
123
+ Con `pip`:
124
+
125
+ ```bash
126
+ python3 -m pip install .
127
+ ```
128
+
129
+ Durante desarrollo:
130
+
131
+ ```bash
132
+ python3 -m venv .venv
133
+ .venv/bin/pip install -e '.[dev]'
134
+ ```
135
+
136
+ Tests:
137
+
138
+ ```bash
139
+ . .venv/bin/activate
140
+ pytest -q
141
+ ```
142
+
143
+ Instalacion automatica del repo:
144
+
145
+ ```bash
146
+ ./install.sh
147
+ ```
148
+
149
+ Eso crea una `.venv`, instala Peridot en modo editable y deja el comando `peridot` enlazado en `~/.local/bin/peridot`.
150
+
151
+ ## Quickstart (3 comandos)
152
+
153
+ ```bash
154
+ peridot init
155
+ peridot pack "Mi bundle" --output mi-bundle.peridot ~/.config
156
+ peridot apply mi-bundle.peridot --dry-run
157
+ ```
158
+
159
+ Notas:
160
+ - Si ejecutas `pack` sin TTY (scripts/CI) y no pasas nombre, Peridot genera uno por defecto.
161
+ - Recomendación: prueba siempre primero con `--dry-run`.
162
+
163
+ Si quieres incluir tambien dependencias de desarrollo (por ejemplo `pytest`):
164
+
165
+ ```bash
166
+ PERIDOT_INSTALL_DEV=1 ./install.sh
167
+ ```
168
+
169
+ ## Flujo principal
170
+
171
+ Generar o comprobar la clave:
172
+
173
+ ```bash
174
+ peridot keygen
175
+ ```
176
+
177
+ Abrir el modo visual:
178
+
179
+ ```bash
180
+ peridot ui
181
+ ```
182
+
183
+ `peridot ui` abre un command center en terminal con:
184
+
185
+ - tabla de bundles `.peridot` detectados en el directorio actual
186
+ - catalogo clasificado de configuraciones detectables
187
+ - hub visual de acciones
188
+ - tabla de presets de dotfiles
189
+ - editor de settings persistentes
190
+ - asistente de empaquetado
191
+ - inspeccion guiada
192
+ - aplicacion guiada con `dry-run`, target y backups
193
+
194
+ Empaquetar tu setup actual:
195
+
196
+ ```bash
197
+ peridot pack "MacBook Fish Setup" \
198
+ --description "Dotfiles personales para macOS + fish" \
199
+ --platform macos \
200
+ --shell fish \
201
+ --tag work \
202
+ --tag terminal \
203
+ --output macbook-fish.peridot \
204
+ ~/.config/fish ~/.gitconfig ~/.zshrc
205
+ ```
206
+
207
+ Si quieres priorizar velocidad:
208
+
209
+ ```bash
210
+ peridot pack --compression-level 0 --jobs 8
211
+ ```
212
+
213
+ Si quieres priorizar tamaño:
214
+
215
+ ```bash
216
+ peridot pack --compression-level 9
217
+ ```
218
+
219
+ Si quieres fijar defaults persistentes:
220
+
221
+ ```bash
222
+ peridot settings
223
+ peridot settings --show
224
+ peridot settings --set compression_level=0 --set jobs=8
225
+ ```
226
+
227
+ El editor `settings` muestra una barra textual del nivel de compresion y deja claro el tradeoff:
228
+
229
+ - `0` = mas rapido, bundles mas grandes
230
+ - `1-2` = rapido
231
+ - `3-6` = equilibrado
232
+ - `7-9` = mas pequeño, mas lento
233
+
234
+ `jobs` controla cuantos workers usa `pack` en paralelo. En general, subirlo ayuda cuando hay muchos archivos y CPU libre.
235
+
236
+ Peridot intenta ademas autorregular `pack` si detecta poca memoria disponible: puede arrancar con menos concurrencia, bajar trabajos en vuelo por mitades hasta `1` si hace falta, y volver a subirlos gradualmente hasta el maximo pedido cuando la memoria se recupera. Antes del empaquetado veras tambien una fase explicita de `Scanning files`, que suele ser la parte lenta antes de que aparezcan los avisos de sensibles.
237
+
238
+ Si ejecutas simplemente:
239
+
240
+ ```bash
241
+ peridot pack
242
+ ```
243
+
244
+ Peridot entra en modo asistido y te va preguntando:
245
+
246
+ - nombre del bundle
247
+ - descripcion
248
+ - plataforma objetivo
249
+ - shell principal
250
+ - arquitectura
251
+ - tags
252
+ - grupos clasificados de configuracion con toggles tipo checkbox
253
+ - edicion visual de rutas sugeridas con checkboxes en terminal
254
+ - rutas manuales solo como fallback
255
+ - nombre del archivo de salida
256
+
257
+ Puedes ver ese catalogo sin empezar un bundle:
258
+
259
+ ```bash
260
+ peridot catalog
261
+ ```
262
+
263
+ Tambien puedes arrancar desde un preset de dotfiles:
264
+
265
+ ```bash
266
+ peridot pack --preset macos-fish
267
+ peridot pack --preset linux-zsh
268
+ peridot pack --preset windows-powershell
269
+ peridot pack --preset custom
270
+ ```
271
+
272
+ Presets disponibles:
273
+
274
+ - `macos-fish`
275
+ - `macos-zsh`
276
+ - `linux-zsh`
277
+ - `linux-bash`
278
+ - `windows-powershell`
279
+
280
+ Inspeccionar la ficha antes de tocar nada:
281
+
282
+ ```bash
283
+ peridot inspect macbook-fish.peridot --files
284
+ ```
285
+
286
+ Previsualizar una aplicacion sin escribir:
287
+
288
+ ```bash
289
+ peridot apply macbook-fish.peridot --dry-run
290
+ ```
291
+
292
+ Aplicar el bundle con backups previos:
293
+
294
+ ```bash
295
+ peridot apply macbook-fish.peridot \
296
+ --backup-dir ~/.peridot-backups \
297
+ --target ~
298
+ ```
299
+
300
+ Comparar un bundle con tu sistema antes de aplicar:
301
+
302
+ ```bash
303
+ peridot diff macbook-fish.peridot --target ~
304
+ ```
305
+
306
+ Verificar integridad:
307
+
308
+ ```bash
309
+ peridot verify macbook-fish.peridot
310
+ peridot verify macbook-fish.peridot --deep
311
+ ```
312
+
313
+ Guardar un perfil reutilizable:
314
+
315
+ ```bash
316
+ peridot profile save work-macos \
317
+ --preset macos-fish \
318
+ --platform macos \
319
+ --shell fish \
320
+ --path ~/.config/fish \
321
+ --exclude '.ssh/*'
322
+ ```
323
+
324
+ Usar un perfil:
325
+
326
+ ```bash
327
+ peridot pack --profile work-macos
328
+ ```
329
+
330
+ Rotar clave y migrar bundles:
331
+
332
+ ```bash
333
+ peridot rekey --all-local
334
+ ```
335
+
336
+ Exportar ficha CLI-friendly:
337
+
338
+ ```bash
339
+ peridot share macbook-fish.peridot --format md
340
+ peridot share macbook-fish.peridot --format json
341
+ ```
342
+
343
+ Fusionar y partir bundles:
344
+
345
+ ```bash
346
+ peridot merge a.peridot b.peridot --output merged.peridot --name "Merged"
347
+ peridot split merged.peridot --prefix .config/fish --output fish-only.peridot --name "Fish Only"
348
+ ```
349
+
350
+ Ver el manifest crudo:
351
+
352
+ ```bash
353
+ peridot manifest macbook-fish.peridot
354
+ ```
355
+
356
+ ## Plataformas
357
+
358
+ Peridot no se limita a dotfiles Unix. Puedes generar bundles para distintos entornos:
359
+
360
+ - `macos`: `.zshrc`, `.config/fish`, `.gitconfig`, `Library/Application Support/...`
361
+ - `linux`: `.bashrc`, `.config`, `.local/share`, configuraciones de WM/terminal
362
+ - `windows`: `.gitconfig`, `.wslconfig`, `AppData/Roaming`, perfiles de PowerShell, Windows Terminal
363
+
364
+ El bundle guarda `platform.os`, `platform.shell` y `platform.arch`, y `peridot apply` comprueba compatibilidad antes de restaurar. Si quieres saltarte esa comprobacion, usa `--ignore-platform`.
365
+
366
+ ## Comandos
367
+
368
+ - `peridot keygen`: crea o muestra la clave activa
369
+ - `peridot doctor`: diagnostica el entorno local
370
+ - `peridot ui`: abre el command center visual
371
+ - `peridot catalog`: enseña grupos clasificados detectables por plataforma
372
+ - `peridot pack`: crea un bundle `.peridot`
373
+ - `peridot inspect`: muestra la ficha visual del bundle
374
+ - `peridot apply`: restaura el bundle
375
+ - `peridot diff`: compara el bundle con un destino
376
+ - `peridot verify`: valida estructura e integridad
377
+ - `peridot share`: exporta una ficha en `md` o `json`
378
+ - `peridot history`: lista snapshots de un bundle
379
+ - `peridot manifest`: imprime el `manifest.json`
380
+ - `peridot rekey`: genera una nueva clave y migra paquetes existentes
381
+ - `peridot delete`: elimina paquetes `.peridot`
382
+ - `peridot profile`: guarda/lista/muestra/elimina perfiles reutilizables
383
+ - `peridot merge`: fusiona bundles
384
+ - `peridot split`: parte un bundle en otro
385
+
386
+ Tambien existen alias para la nomenclatura antigua:
387
+
388
+ - `peridot export` -> `peridot pack`
389
+ - `peridot import` -> `peridot apply`
390
+
391
+ ## Filosofia del formato
392
+
393
+ Peridot intenta equilibrar tres cosas:
394
+
395
+ 1. Portabilidad real. El bundle es un archivo unico, facil de subir, compartir o versionar.
396
+ 2. Inspeccion previa. Puedes abrir el `manifest.json` sin descifrar el contenido.
397
+ 3. Seguridad razonable. El payload va comprimido y cifrado; la clave se gestiona aparte.
398
+
399
+ Importante:
400
+
401
+ - sin la clave puedes inspeccionar el `manifest.json`, pero no leer ni aplicar los payloads cifrados
402
+ - si rotas la clave, usa `peridot rekey` para migrar los paquetes existentes a la nueva clave
403
+ - `pack` puede avisarte de rutas sensibles y aceptar exclusiones por glob
404
+
405
+ ## Limitaciones actuales
406
+
407
+ - Los symlinks no se empaquetan todavia.
408
+ - No hay merge inteligente entre configuraciones; `apply` restaura ficheros completos.
409
+ - El cifrado depende de una clave local `AES-GCM`, que tienes que conservar junto al bundle si quieres moverlo a otra maquina.
410
+
411
+ ## Roadmap natural
412
+
413
+ - soporte de symlinks
414
+ - perfiles declarativos por plataforma
415
+ - filtros de inclusion/exclusion por glob
416
+ - plugin system para apps concretas
417
+ - diff visual antes de sobrescribir archivos