refactor(naming): A1 — ente→arje, vista→revista, pluma→fana
Rename batch de la Fase A del PLAN_MACRO: - 25 crates ente-* → arje-* (protocol/init/runtime/compat). El linaje arje (init Linux) queda con prefijo coherente. - vista → revista (revista-core + revista-web). - pluma → fana (fana-md + fana-md-reader-web). fana absorbe el linaje markdown de pluma; será el writer DAG editor (prioridad alta). Cambios: - git mv de 29 crate dirs + 2 SDDs - package/lib/bin names + path refs + imports .rs reescritos - workspace Cargo.toml + comentarios de sección - SDDs de init/runtime/compat/protocol actualizados a arje- - SDD de revista + SDD de fana (reescrito: writer DAG editor) - docs/STATUS.md, ROADMAP.md, PLAN_MACRO.md, arje-boot.md, arje-replace-systemd.md actualizados - docs/changelog/akasha.md → chasqui.md scripts/rename-fase-a.py idempotente (--dry-run soportado). cargo check --workspace verde. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# modules/fana/ — Writer DAG editor (absorbe pluma)
|
||||
|
||||
**Propósito.** Editor de escritura multidimensional: el documento es un
|
||||
DAG de átomos narrativos con ramas (timelines), tracking de coherencia,
|
||||
e indexación semántica. Absorbe el linaje markdown de `pluma`. Prioridad
|
||||
alta entre las apps.
|
||||
|
||||
## Estado
|
||||
|
||||
- **Existente (de pluma)**: `fana-md` (parser markdown, ex `pluma-md`),
|
||||
`fana-md-reader-web` (lector DOM, ex `pluma-reader-web`, aún dep de
|
||||
`gioser-web`).
|
||||
- **Planeado**: el resto de sub-crates (writer DAG editor completo).
|
||||
|
||||
## Crates (objetivo)
|
||||
|
||||
| crate | tipo | rol |
|
||||
| ---------------------- | ---- | ---------------------------------------------------- |
|
||||
| `fana-core` | lib | `NarrativeAtom` + `NarrativeGraph` + `CoherenceState`|
|
||||
| `fana-md` | lib | Parser markdown (ex pluma-md) |
|
||||
| `fana-graph` | lib | DAG ops + `propagate_mutation` topológico |
|
||||
| `fana-semantic` | lib | Cliente `verbo` + scoring de intensidad adjetiva |
|
||||
| `fana-store` | lib | Persistencia sled/RocksDB + bincode/rkyv zero-copy |
|
||||
| `fana-llm` | lib | Cliente HTTP a LLMs remotos (evaluación + merge) |
|
||||
| `fana-render-plan` | lib | DrawCommands agnósticos (editor + sidepane + ghost) |
|
||||
| `fana-editor-gpui` | lib | WorkspaceEditor View + OscilloscopeSidepane + Ghost |
|
||||
| `fana-md-reader-web` | lib | Lector markdown DOM (ex pluma-reader-web) |
|
||||
| `fana-editor-web` | lib | (futuro) editor WASM |
|
||||
|
||||
## Modelo de datos
|
||||
|
||||
```rust
|
||||
enum CoherenceState { Valid, InConflict { origin, reason }, PendingEvaluation }
|
||||
|
||||
struct NarrativeAtom {
|
||||
id: Uuid,
|
||||
content_hash: [u8; 32], // SHA-256 estricto
|
||||
content: Arc<String>, // texto compartido (zero-alloc al ramificar)
|
||||
semantic_vectors: HashMap<String, f32>, // concepto → intensidad
|
||||
dependencies: Vec<Uuid>, // nodos prerrequisito
|
||||
branch_id: String,
|
||||
coherence: CoherenceState,
|
||||
}
|
||||
|
||||
struct NarrativeGraph {
|
||||
nodes: HashMap<Uuid, NarrativeAtom>,
|
||||
adjacency_list: HashMap<Uuid, Vec<Uuid>>, // padre → hijos dependientes
|
||||
}
|
||||
```
|
||||
|
||||
## Dependencias
|
||||
|
||||
- `fana-semantic` ← `verbo` (embeddings, instancia modelo ligero ~384d).
|
||||
- `fana-md` puro (sin deps de host).
|
||||
- `fana-md-reader-web` + `fana-editor-web` ← `wasm-bindgen`, `web-sys`.
|
||||
- `fana-editor-gpui` ← `gpui`, `nahual`.
|
||||
- `gioser-web` sigue consumiendo `fana-md-reader-web`.
|
||||
|
||||
## Invariantes
|
||||
|
||||
- Toda mutación de texto valida contra el hash binario del contenido.
|
||||
- Branches comparten texto vía `Arc<String>` — clonar una rama es O(1).
|
||||
- `propagate_mutation` marca `PendingEvaluation` en cascada topológica
|
||||
cuando un átomo origen cambia (shock-wave lógica).
|
||||
- Separabilidad UI estricta: `fana-core/md/graph/semantic/store/llm/
|
||||
render-plan` agnósticos; `fana-editor-{gpui,web}` intercambiables.
|
||||
|
||||
## Apps
|
||||
|
||||
- `apps/fana` — binario GPUI (prioridad alta).
|
||||
- `apps/fana-web` — (futuro) cdylib WASM.
|
||||
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "fana-md-reader-web"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
fana-md = { path = "../fana-md" }
|
||||
wasm-bindgen.workspace = true
|
||||
wasm-bindgen-futures.workspace = true
|
||||
js-sys.workspace = true
|
||||
|
||||
[dependencies.web-sys]
|
||||
workspace = true
|
||||
features = [
|
||||
"Window",
|
||||
"Document",
|
||||
"Element",
|
||||
"HtmlElement",
|
||||
"CssStyleDeclaration",
|
||||
"Response",
|
||||
"console",
|
||||
]
|
||||
@@ -0,0 +1,88 @@
|
||||
//! Pluma reader — visor de markdown elegante para WASM/web.
|
||||
//!
|
||||
//! Toma un `<div>` que actúa como contenedor y le inyecta el HTML
|
||||
//! producido por `pluma-md`. El styling (fonts, colores, animaciones)
|
||||
//! lo provee el CSS del host: este crate no inyecta estilos, sólo
|
||||
//! marcado y `data-pluma-theme="…"` para que el CSS reaccione.
|
||||
//!
|
||||
//! Patrón de uso:
|
||||
//!
|
||||
//! ```ignore
|
||||
//! let container = document.get_element_by_id("drawer-aire-content")?
|
||||
//! .dyn_into::<HtmlElement>()?;
|
||||
//! let reader = Reader::new(container);
|
||||
//! reader.show_loading();
|
||||
//! wasm_bindgen_futures::spawn_local(async move {
|
||||
//! let _ = reader.open_url("./md/aire.md", "aire").await;
|
||||
//! });
|
||||
//! ```
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
use web_sys::{HtmlElement, Response};
|
||||
|
||||
pub struct Reader {
|
||||
container: HtmlElement,
|
||||
}
|
||||
|
||||
impl Reader {
|
||||
pub fn new(container: HtmlElement) -> Self {
|
||||
Self { container }
|
||||
}
|
||||
|
||||
pub fn container(&self) -> &HtmlElement {
|
||||
&self.container
|
||||
}
|
||||
|
||||
/// Inyecta un mensaje de carga mientras se resuelve `open_url`.
|
||||
pub fn show_loading(&self) {
|
||||
self.container.set_inner_html(
|
||||
r#"<div class="pluma-loading" aria-live="polite">…</div>"#,
|
||||
);
|
||||
}
|
||||
|
||||
/// Inyecta un mensaje de error visible.
|
||||
pub fn show_error(&self, msg: &str) {
|
||||
let safe: String = msg.replace('<', "<").replace('>', ">");
|
||||
self.container.set_inner_html(&format!(
|
||||
r#"<div class="pluma-error">{}</div>"#,
|
||||
safe
|
||||
));
|
||||
}
|
||||
|
||||
/// Renderea un string markdown directamente, sin fetch.
|
||||
pub fn render_md(&self, md: &str, theme: &str) {
|
||||
let html = fana_md::to_themed_html(md, theme);
|
||||
self.container.set_inner_html(&html);
|
||||
}
|
||||
|
||||
/// Inyecta HTML pre-renderizado (sin parsear). Útil si el caller ya
|
||||
/// hizo el parse en otro lado.
|
||||
pub fn render_html(&self, html: &str) {
|
||||
self.container.set_inner_html(html);
|
||||
}
|
||||
|
||||
/// Limpia el contenedor.
|
||||
pub fn clear(&self) {
|
||||
self.container.set_inner_html("");
|
||||
}
|
||||
|
||||
/// Fetcha la URL, parsea el markdown y lo renderea con el tema dado.
|
||||
/// El loader muestra un placeholder mientras la promesa está pendiente.
|
||||
pub async fn open_url(&self, url: &str, theme: &str) -> Result<(), JsValue> {
|
||||
let window = web_sys::window().ok_or_else(|| JsValue::from_str("no window"))?;
|
||||
self.show_loading();
|
||||
let resp_value = JsFuture::from(window.fetch_with_str(url)).await?;
|
||||
let resp: Response = resp_value.dyn_into()?;
|
||||
if !resp.ok() {
|
||||
let err = format!("HTTP {} para {}", resp.status(), url);
|
||||
self.show_error(&err);
|
||||
return Err(JsValue::from_str(&err));
|
||||
}
|
||||
let text_value = JsFuture::from(resp.text()?).await?;
|
||||
let md = text_value.as_string().unwrap_or_default();
|
||||
self.render_md(&md, theme);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "fana-md"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
pulldown-cmark = { workspace = true }
|
||||
@@ -0,0 +1,90 @@
|
||||
//! Pluma — parser markdown agnóstico, listo para envolver en cualquier viewer.
|
||||
//!
|
||||
//! Es deliberadamente delgado: wrappea `pulldown-cmark` (todas las
|
||||
//! extensiones GFM habilitadas) y emite HTML envuelto en `<div class="pluma-doc">`
|
||||
//! con un `data-pluma-theme="…"` para que el CSS del viewer aplique colores
|
||||
//! por tema sin necesidad de re-renderear.
|
||||
//!
|
||||
//! No tiene deps de web/DOM/wasm: corre igual en server, terminal, WASM o
|
||||
//! tests. Si necesitás emitir Markdown-AST en lugar de HTML, usá la API
|
||||
//! `events()` y construí tu propio renderer.
|
||||
|
||||
use pulldown_cmark::{html, Event, Options, Parser};
|
||||
|
||||
/// Opciones por default — GFM completo: tables, footnotes, tasklists, strikethrough,
|
||||
/// smart punctuation, heading anchors.
|
||||
pub fn default_options() -> Options {
|
||||
Options::ENABLE_TABLES
|
||||
| Options::ENABLE_FOOTNOTES
|
||||
| Options::ENABLE_STRIKETHROUGH
|
||||
| Options::ENABLE_TASKLISTS
|
||||
| Options::ENABLE_SMART_PUNCTUATION
|
||||
| Options::ENABLE_HEADING_ATTRIBUTES
|
||||
}
|
||||
|
||||
/// Markdown → HTML "crudo" (sin wrapper de tema).
|
||||
pub fn to_html(md: &str) -> String {
|
||||
let mut out = String::with_capacity(md.len() * 2);
|
||||
let parser = Parser::new_ext(md, default_options());
|
||||
html::push_html(&mut out, parser);
|
||||
out
|
||||
}
|
||||
|
||||
/// Markdown → HTML envuelto en `<div class="pluma-doc" data-pluma-theme="…">`.
|
||||
/// El `theme` es un string opaco (ej. "aire", "fuego") que el CSS del viewer
|
||||
/// matchea via `[data-pluma-theme="aire"]`.
|
||||
pub fn to_themed_html(md: &str, theme: &str) -> String {
|
||||
let body = to_html(md);
|
||||
let safe_theme: String = theme
|
||||
.chars()
|
||||
.filter(|c| c.is_ascii_alphanumeric() || *c == '-' || *c == '_')
|
||||
.collect();
|
||||
format!(
|
||||
r#"<article class="pluma-doc" data-pluma-theme="{theme}">{body}</article>"#,
|
||||
theme = safe_theme,
|
||||
body = body
|
||||
)
|
||||
}
|
||||
|
||||
/// Devuelve un iterador de eventos pulldown-cmark (AST stream).
|
||||
/// Útil si querés renderear a algo distinto que HTML.
|
||||
pub fn events(md: &str) -> impl Iterator<Item = Event<'_>> {
|
||||
Parser::new_ext(md, default_options())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn renders_h1() {
|
||||
let html = to_html("# Hola");
|
||||
assert!(html.contains("<h1>Hola</h1>"), "got {}", html);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renders_list() {
|
||||
let html = to_html("- a\n- b\n");
|
||||
assert!(html.contains("<li>a</li>"));
|
||||
assert!(html.contains("<li>b</li>"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn themed_wrapper_sanitizes_theme_name() {
|
||||
let html = to_themed_html("# x", "aire<script>");
|
||||
assert!(html.contains(r#"data-pluma-theme="airescript""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renders_code_fence() {
|
||||
let html = to_html("```rust\nfn main(){}\n```");
|
||||
assert!(html.contains("<pre><code") && html.contains("fn main"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn renders_table_gfm() {
|
||||
let md = "| a | b |\n|---|---|\n| 1 | 2 |\n";
|
||||
let html = to_html(md);
|
||||
assert!(html.contains("<table>"), "got {}", html);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user