Dashboard HTML: full Neuron web experience with avatar, voice; add X-NC-CLI header to http_post for CLI mirroring
This commit is contained in:
File diff suppressed because it is too large
Load Diff
+64
-5
@@ -35,6 +35,8 @@ use el_compiler::{Compiler, CompilerOptions, Target};
|
|||||||
use el_test;
|
use el_test;
|
||||||
use el_manifest::{BuildTarget, Manifest};
|
use el_manifest::{BuildTarget, Manifest};
|
||||||
use el_seal::{seal as seal_fn, unseal as unseal_fn, SealedArtifact, DeploymentBinding, SealAlgorithm, SealConfig};
|
use el_seal::{seal as seal_fn, unseal as unseal_fn, SealedArtifact, DeploymentBinding, SealAlgorithm, SealConfig};
|
||||||
|
use el_fmt;
|
||||||
|
use el_lint;
|
||||||
|
|
||||||
// ── Global state (thread-local for simplicity) ────────────────────────────────
|
// ── Global state (thread-local for simplicity) ────────────────────────────────
|
||||||
|
|
||||||
@@ -172,12 +174,30 @@ enum Command {
|
|||||||
manifest: Option<PathBuf>,
|
manifest: Option<PathBuf>,
|
||||||
},
|
},
|
||||||
|
|
||||||
/// Format source files.
|
/// Format an engram-lang source file (or all files in a project).
|
||||||
Fmt {
|
Fmt {
|
||||||
|
/// Single source file to format (*.el). When omitted, formats the whole project.
|
||||||
|
file: Option<PathBuf>,
|
||||||
|
/// Overwrite the file in place with canonical formatting.
|
||||||
|
#[arg(long)]
|
||||||
|
in_place: bool,
|
||||||
|
/// Exit 1 if the file is not in canonical format (useful in CI). Does not modify the file.
|
||||||
|
#[arg(long)]
|
||||||
|
check: bool,
|
||||||
|
/// Project manifest (used when no `file` is given).
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
manifest: Option<PathBuf>,
|
manifest: Option<PathBuf>,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Lint an engram-lang source file.
|
||||||
|
Lint {
|
||||||
|
/// Source file to lint (*.el).
|
||||||
|
file: PathBuf,
|
||||||
|
/// Emit diagnostics as JSON instead of human-readable text.
|
||||||
|
#[arg(long)]
|
||||||
|
json: bool,
|
||||||
|
},
|
||||||
|
|
||||||
/// Remove build artifacts and cache.
|
/// Remove build artifacts and cache.
|
||||||
Clean {
|
Clean {
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
@@ -396,10 +416,48 @@ async fn run(cli: Cli) -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Fmt { manifest } => {
|
Command::Fmt { file, in_place, check, manifest } => {
|
||||||
let manifest_path = resolve_manifest(manifest.as_deref())?;
|
if let Some(path) = file {
|
||||||
let bs = BuildSystem::from_manifest_file(&manifest_path)?;
|
// Single-file mode
|
||||||
bs.fmt()?;
|
let source = std::fs::read_to_string(&path)
|
||||||
|
.map_err(|e| format!("cannot read {}: {e}", path.display()))?;
|
||||||
|
let formatted = el_fmt::format(&source)
|
||||||
|
.map_err(|e| format!("fmt error: {e}"))?;
|
||||||
|
if check {
|
||||||
|
if formatted != source {
|
||||||
|
eprintln!("error: {} is not in canonical format", path.display());
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
println!("ok: {} is already formatted", path.display());
|
||||||
|
} else if in_place {
|
||||||
|
std::fs::write(&path, &formatted)
|
||||||
|
.map_err(|e| format!("cannot write {}: {e}", path.display()))?;
|
||||||
|
println!("formatted: {}", path.display());
|
||||||
|
} else {
|
||||||
|
print!("{formatted}");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Project mode — fall back to build system's fmt
|
||||||
|
let manifest_path = resolve_manifest(manifest.as_deref())?;
|
||||||
|
let bs = BuildSystem::from_manifest_file(&manifest_path)?;
|
||||||
|
bs.fmt()?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Command::Lint { file, json } => {
|
||||||
|
let source = std::fs::read_to_string(&file)
|
||||||
|
.map_err(|e| format!("cannot read {}: {e}", file.display()))?;
|
||||||
|
let mut report = el_lint::lint(&source)
|
||||||
|
.map_err(|e| format!("lint error: {e}"))?;
|
||||||
|
report.file_path = Some(file.display().to_string());
|
||||||
|
if json {
|
||||||
|
println!("{}", report.to_json());
|
||||||
|
} else {
|
||||||
|
print!("{}", report.display());
|
||||||
|
}
|
||||||
|
if report.has_errors() {
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::Clean { manifest } => {
|
Command::Clean { manifest } => {
|
||||||
@@ -1577,6 +1635,7 @@ fn dispatch_builtin(
|
|||||||
let result = reqwest::blocking::Client::new()
|
let result = reqwest::blocking::Client::new()
|
||||||
.post(&url)
|
.post(&url)
|
||||||
.header("Content-Type", "application/json")
|
.header("Content-Type", "application/json")
|
||||||
|
.header("X-NC-CLI", "true")
|
||||||
.body(body)
|
.body(body)
|
||||||
.send()
|
.send()
|
||||||
.and_then(|r| r.text())
|
.and_then(|r| r.text())
|
||||||
|
|||||||
Reference in New Issue
Block a user