refactor(monorepo): reorganización lógica + renames + SDDs + split CHANGELOG

Reorganización física de crates/:
- core/ (mezclaba 6 propósitos) se divide en protocol/, init/, runtime/, compat/
- shared/ (3 crates) se redistribuye en protocol/ e init/
- lapaloma (sub-módulo de ui_engine) se promueve a modules/pineal/

Renames de proyectos:
- shipote → shuma (runtime de sandboxes)
- nouser → akasha (explorador de Mónadas)
- yahweh → nahual (motor GPUI, antes ui_engine/)
- lapaloma → pineal (data-viz agnóstica)

Fraccionamiento UI → core agnóstico:
- vista-core (DeckState + snap, 175 LOC, 5 tests verdes)
- barra-core (Task + render_html + sanitize, 90 LOC, 5 tests verdes)
- vista-web y barra-web ahora son thin DOM bindings

Documentación nueva:
- 16 SDDs por subdirectorio (≤80 LOC c/u): protocol/init/runtime/compat
  + 10 módulos + apps/
- docs/STATUS.md con cifras reales por proyecto
- docs/ROADMAP.md con plan a finalización (6 hitos, ~6-8 semanas)
- CHANGELOG.md particionado en docs/changelog/<proyecto>.md (7 buckets)

Automatización:
- scripts/reorg.py — script idempotente que: git mv directorios, renombra
  package names, recomputa path = refs, reescribe imports rust, actualiza
  workspace Cargo.toml. Soporta --dry-run.
- scripts/split-changelog.py — particiona CHANGELOG por componente.

Validación:
- cargo check --workspace pasa (124 crates + 2 nuevos cores).
- 10 tests adicionales (5 en vista-core + 5 en barra-core) verdes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sergio
2026-05-19 14:48:34 +00:00
parent 86fb6ae20b
commit 550c98f275
375 changed files with 8512 additions and 7155 deletions
@@ -0,0 +1,140 @@
//! `LayoutModel` — fuente de verdad mutable del árbol de layout.
//!
//! Distinguimos dos clases de cambio:
//!
//! - [`LayoutModelEvent::StructureChanged`]: cambios que requieren rebuild
//! del árbol de entidades (kind, children, params relevantes). Estos
//! también invocan `cx.notify()` para que los `cx.observe` (StatusPanel,
//! etc.) refresquen.
//! - [`LayoutModelEvent::FlexChanged`]: actualización de `flex` de un
//! nodo (típicamente proviene de un drag de divisor). NO requiere
//! rebuild — el SplitContainer ya tiene el flex aplicado en su Vec; solo
//! nos importa para persistir. Por eso no llamamos `cx.notify()`: solo
//! emitimos el evento, así los `cx.observe` (que rebuilden) se mantienen
//! silenciosos durante el drag.
//!
//! El `Persister` (ver `shell/persister.rs`) se subscribe vía
//! `cx.subscribe` y reacciona a los dos.
use gpui::{Context, EventEmitter};
use nahual_core::{LayerConfig, NodeId};
#[derive(Clone, Debug)]
pub enum LayoutModelEvent {
/// Estructural — kind / children / params. Triggerea rebuild en
/// `LayoutHost` y persist.
StructureChanged,
/// Solo flex de un nodo. Triggerea persist; NO rebuild.
FlexChanged,
}
pub struct LayoutModel {
tree: LayerConfig,
}
impl EventEmitter<LayoutModelEvent> for LayoutModel {}
impl LayoutModel {
pub fn new(tree: LayerConfig) -> Self {
Self { tree }
}
pub fn tree(&self) -> &LayerConfig {
&self.tree
}
/// Reemplazo completo del árbol — para hot-reload del JSON.
pub fn replace_tree(&mut self, tree: LayerConfig, cx: &mut Context<Self>) {
self.tree = tree;
cx.emit(LayoutModelEvent::StructureChanged);
cx.notify();
}
/// Cambia el `kind` del nodo cuyo id JSON coincide con `target_id`.
pub fn set_kind(
&mut self,
target_id: &NodeId,
new_kind: &str,
cx: &mut Context<Self>,
) {
let changed = mutate_node(&mut self.tree, target_id, &mut |node| {
if node.kind != new_kind {
node.kind = new_kind.to_string();
true
} else {
false
}
});
if changed {
cx.emit(LayoutModelEvent::StructureChanged);
cx.notify();
}
}
/// Setea el flex de un nodo. Solo emite `FlexChanged` (no notify) —
/// usado al final de un drag de divisor para persistir sin
/// triggerear rebuild.
pub fn set_flex(&mut self, target_id: &NodeId, flex: f32, cx: &mut Context<Self>) {
let new_val = Some(flex as f64);
let changed = mutate_node(&mut self.tree, target_id, &mut |node| {
if node.flex != new_val {
node.flex = new_val;
true
} else {
false
}
});
if changed {
cx.emit(LayoutModelEvent::FlexChanged);
}
}
/// Intercambia dos children del nodo `parent_id`. Triggerea
/// `StructureChanged` (rebuild + persist), porque cambia el orden de
/// instanciación. Si los índices son iguales o están out-of-bounds,
/// es no-op.
pub fn swap_children(
&mut self,
parent_id: &NodeId,
idx_a: usize,
idx_b: usize,
cx: &mut Context<Self>,
) {
if idx_a == idx_b {
return;
}
let mut did_swap = false;
mutate_node(&mut self.tree, parent_id, &mut |node| {
if idx_a < node.children.len() && idx_b < node.children.len() {
node.children.swap(idx_a, idx_b);
did_swap = true;
true
} else {
false
}
});
if did_swap {
cx.emit(LayoutModelEvent::StructureChanged);
cx.notify();
}
}
}
fn mutate_node(
node: &mut LayerConfig,
target: &NodeId,
f: &mut impl FnMut(&mut LayerConfig) -> bool,
) -> bool {
if let Some(id) = &node.id {
if id == target.as_str() {
return f(node);
}
}
for child in node.children.iter_mut() {
if mutate_node(child, target, f) {
return true;
}
}
false
}