Add object primitives, official ext/llm, and HTTPS/dotenv platform.
Introduce # objects with ## methods (handles + ` x.method `), ship OpenAI-compatible ext/llm, and upgrade net/sys for HTTPS headers and dotenv loading. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b974f10c6e
commit
b00b018056
55 files changed
+1741
-291
No files matched your search
+38
-2
@@ -41,8 +41,8 @@ fn load_module_inner(path: &Path, visited: &mut HashSet<PathBuf>) -> Result<Modu
|
||||
Ok(module)
|
||||
}
|
||||
|
||||
/// Resolve an import path: relative to the importer first; `lib/…` and `std/…`
|
||||
/// also search official library roots (`MARQDO_LIB`, `./lib`, near the binary).
|
||||
/// Resolve an import path: relative to the importer first; `lib/…` / `std/…`
|
||||
/// and `ext/…` also search official roots (`MARQDO_LIB` / `MARQDO_EXT`, cwd, near the binary).
|
||||
pub fn resolve_import(from_dir: &Path, rel: &str) -> Result<PathBuf> {
|
||||
let rel = rel.replace('\\', "/");
|
||||
let direct = from_dir.join(&rel);
|
||||
@@ -72,6 +72,22 @@ pub fn resolve_import(from_dir: &Path, rel: &str) -> Result<PathBuf> {
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(remainder) = normalized.strip_prefix("ext/") {
|
||||
for root in ext_search_roots() {
|
||||
let as_ext_dir = root.join(remainder);
|
||||
if as_ext_dir.is_file() {
|
||||
return Ok(as_ext_dir);
|
||||
}
|
||||
let as_repo_root = root.join("ext").join(remainder);
|
||||
if as_repo_root.is_file() {
|
||||
return Ok(as_repo_root);
|
||||
}
|
||||
}
|
||||
bail!(
|
||||
"cannot resolve extension import `{rel}` (set MARQDO_EXT or keep an ext/ next to the project)"
|
||||
);
|
||||
}
|
||||
|
||||
Ok(direct)
|
||||
}
|
||||
|
||||
@@ -95,6 +111,26 @@ fn lib_search_roots() -> Vec<PathBuf> {
|
||||
roots
|
||||
}
|
||||
|
||||
fn ext_search_roots() -> Vec<PathBuf> {
|
||||
let mut roots = Vec::new();
|
||||
if let Ok(h) = env::var("MARQDO_EXT") {
|
||||
roots.push(PathBuf::from(h));
|
||||
}
|
||||
if let Ok(cwd) = env::current_dir() {
|
||||
roots.push(cwd.join("ext"));
|
||||
roots.push(cwd);
|
||||
}
|
||||
if let Ok(exe) = env::current_exe() {
|
||||
if let Some(dir) = exe.parent() {
|
||||
roots.push(dir.join("ext"));
|
||||
roots.push(dir.join("../ext"));
|
||||
roots.push(dir.join("../../ext"));
|
||||
roots.push(dir.join("../../../ext"));
|
||||
}
|
||||
}
|
||||
roots
|
||||
}
|
||||
|
||||
fn attach_path(path: &Path, err: anyhow::Error) -> anyhow::Error {
|
||||
if let Some(d) = err.downcast_ref::<Diagnostic>() {
|
||||
if d.path.is_none() {
|
||||
|
||||
Reference in new issue
Block a user