Compare commits

...
2 Commits
Author SHA1 Message Date
cflmyandCursor 95b16be714 release: v0.3.5 — prebuilt native plugins for ext add
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 17:08:19 +08:00
cflmyandCursor d31ad79bc0 feat(ext): prebuilt native plugins and ext add download
Ship Release native zips and let ext add fetch L1/native without a local Rust toolchain.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-04 16:57:43 +08:00
13 changed files with 567 additions and 81 deletions

No files matched your search

@@ -33,6 +33,8 @@ Produced by `.github/workflows/release.yml` on **windows-latest**:
| `marqdo-VER-x86_64-pc-windows-msvc.zip` | `marqdo.exe` + `lib/` | | `marqdo-VER-x86_64-pc-windows-msvc.zip` | `marqdo.exe` + `lib/` |
| `marqdo-VER-stdlib.zip` | `lib/` only | | `marqdo-VER-stdlib.zip` | `lib/` only |
| `marqdo-VER-ext.zip` | Official `ext/` L1 | | `marqdo-VER-ext.zip` | Official `ext/` L1 |
| `marqdo-VER-native-x86_64-pc-windows-msvc.zip` | Prebuilt Windows plugins (`native/*.dll`) |
| `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` | Prebuilt Linux plugins (`native/lib*.so`) |
| `marqdo-VER-source.zip` | `git archive` of tagged commit | | `marqdo-VER-source.zip` | `git archive` of tagged commit |
| `marqdo-VER.vsix` | VS Code / Cursor (from branch `vscode-extension`) | | `marqdo-VER.vsix` | VS Code / Cursor (from branch `vscode-extension`) |
| `marqdo-VER-public.zip` | Static user docs (`marqdo view output public`) | | `marqdo-VER-public.zip` | Static user docs (`marqdo view output public`) |
+60 -13
View File
@@ -25,8 +25,10 @@ jobs:
with: with:
node-version: "20" node-version: "20"
- name: Build release - name: Build release CLI + official plugins
run: cargo build --release run: |
cargo build --release
cargo build --release -p marqdo_plugin_web -p marqdo_plugin_agent -p marqdo_plugin_quantum
- name: Checkout extension sources (branch vscode-extension only) - name: Checkout extension sources (branch vscode-extension only)
run: git fetch origin vscode-extension && git checkout origin/vscode-extension -- vscode-extension run: git fetch origin vscode-extension && git checkout origin/vscode-extension -- vscode-extension
@@ -55,6 +57,7 @@ jobs:
$vsix = "marqdo-$ver.vsix" $vsix = "marqdo-$ver.vsix"
$public = "marqdo-$ver-public.zip" $public = "marqdo-$ver-public.zip"
$extZip = "marqdo-$ver-ext.zip" $extZip = "marqdo-$ver-ext.zip"
$nativeZip = "marqdo-$ver-native-$target.zip"
Copy-Item target/release/marqdo.exe "dist/$exe" Copy-Item target/release/marqdo.exe "dist/$exe"
git archive --format=zip -o "dist/$source" HEAD git archive --format=zip -o "dist/$source" HEAD
./target/release/marqdo view output public -o public ./target/release/marqdo view output public -o public
@@ -65,11 +68,25 @@ jobs:
Copy-Item ext "$stageExt/ext" -Recurse Copy-Item ext "$stageExt/ext" -Recurse
if (Test-Path "dist/$extZip") { Remove-Item "dist/$extZip" -Force } if (Test-Path "dist/$extZip") { Remove-Item "dist/$extZip" -Force }
Compress-Archive -Path "$stageExt/*" -DestinationPath "dist/$extZip" -Force Compress-Archive -Path "$stageExt/*" -DestinationPath "dist/$extZip" -Force
# Prebuilt native plugins (no Rust required for `marqdo ext add`)
$stageNative = "dist/stage-native"
if (Test-Path $stageNative) { Remove-Item $stageNative -Recurse -Force }
New-Item -ItemType Directory -Force -Path "$stageNative/native" | Out-Null
Copy-Item target/release/web.dll "$stageNative/native/web.dll"
Copy-Item target/release/agent.dll "$stageNative/native/agent.dll"
Copy-Item target/release/quantum.dll "$stageNative/native/quantum.dll"
if (Test-Path "dist/$nativeZip") { Remove-Item "dist/$nativeZip" -Force }
Compress-Archive -Path "$stageNative/*" -DestinationPath "dist/$nativeZip" -Force
$stage = "dist/stage-bundle" $stage = "dist/stage-bundle"
if (Test-Path $stage) { Remove-Item $stage -Recurse -Force } if (Test-Path $stage) { Remove-Item $stage -Recurse -Force }
New-Item -ItemType Directory -Force -Path $stage | Out-Null New-Item -ItemType Directory -Force -Path $stage | Out-Null
Copy-Item target/release/marqdo.exe "$stage/marqdo.exe" Copy-Item target/release/marqdo.exe "$stage/marqdo.exe"
Copy-Item lib "$stage/lib" -Recurse Copy-Item lib "$stage/lib" -Recurse
Copy-Item ext "$stage/ext" -Recurse
New-Item -ItemType Directory -Force -Path "$stage/ext/native" | Out-Null
Copy-Item target/release/web.dll "$stage/ext/native/web.dll"
Copy-Item target/release/agent.dll "$stage/ext/native/agent.dll"
Copy-Item target/release/quantum.dll "$stage/ext/native/quantum.dll"
if (Test-Path "dist/$zip") { Remove-Item "dist/$zip" -Force } if (Test-Path "dist/$zip") { Remove-Item "dist/$zip" -Force }
Compress-Archive -Path "$stage/*" -DestinationPath "dist/$zip" -Force Compress-Archive -Path "$stage/*" -DestinationPath "dist/$zip" -Force
$stageLib = "dist/stage-stdlib" $stageLib = "dist/stage-stdlib"
@@ -85,6 +102,7 @@ jobs:
echo "SOURCE=$source" >> $env:GITHUB_ENV echo "SOURCE=$source" >> $env:GITHUB_ENV
echo "PUBLIC=$public" >> $env:GITHUB_ENV echo "PUBLIC=$public" >> $env:GITHUB_ENV
echo "EXT=$extZip" >> $env:GITHUB_ENV echo "EXT=$extZip" >> $env:GITHUB_ENV
echo "NATIVE=$nativeZip" >> $env:GITHUB_ENV
- name: Upload release assets - name: Upload release assets
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
@@ -92,24 +110,21 @@ jobs:
body: | body: |
## Marqdo ${{ github.ref_name }} ## Marqdo ${{ github.ref_name }}
### 亮点 / Highlights — v0.3.4 ### 亮点 / Highlights
- **`ext/web` 定制 C0–C4**:admin 前缀可让出、段边界 gates、shell/layout、样式 strict、脚本 defer/version、条件导航 when/media - **`marqdo ext add` 无需本机 Rust**:发布附带预编译 native 插件;`ext add` 可自动下载
- **ext/web customization C0–C4**: configurable admin/gates/shell/layout/CSS strict/script lifecycle/conditional nav - **Prebuilt native plugins**: `marqdo-*-native-*.zip`; Windows zip includes `ext/native/`
- Agent Wave B0 demos + writeback shadow fix - Install: `marqdo ext add web|agent|quantum|llm`(零源码编译)
- Install: `marqdo ext list` / `marqdo ext add llm|agent|web|quantum` - Details: [CHANGELOG](https://github.com/cflmy/marqdo/blob/main/CHANGELOG.md) · [ext-cli.md](https://github.com/cflmy/marqdo/blob/main/doc/design/ext-cli.md)
- Native plugins: `cargo build --release -p marqdo_plugin_*` then `ext add`
- Details: [CHANGELOG](https://github.com/cflmy/marqdo/blob/main/CHANGELOG.md) · [README](https://github.com/cflmy/marqdo/blob/main/README.md)
Also: embedded stdlib, writeback/subtask, Variables modal in `view`, VSIX from branch **`vscode-extension`**.
### Downloads ### Downloads
| Asset | Contents | | Asset | Contents |
|-------|----------| |-------|----------|
| `marqdo-*-windows-msvc.exe` | CLI with **embedded** official stdlib | | `marqdo-*-windows-msvc.exe` | CLI with **embedded** official stdlib |
| `marqdo-*-windows-msvc.zip` | `marqdo.exe` + `lib/` (optional disk override) | | `marqdo-*-windows-msvc.zip` | `marqdo.exe` + `lib/` + `ext/`(含 native DLL) |
| `marqdo-*-native-*.zip` | 预编译 `web`/`agent`/`quantum` 插件 |
| `marqdo-*-stdlib.zip` | `lib/` only | | `marqdo-*-stdlib.zip` | `lib/` only |
| `marqdo-*-ext.zip` | Official `ext/` L1 sources (for `MARQDO_EXT_SOURCE` / local `./ext`) | | `marqdo-*-ext.zip` | Official `ext/` L1 sources |
| `marqdo-*-source.zip` | Source snapshot (`git archive`) | | `marqdo-*-source.zip` | Source snapshot (`git archive`) |
| `marqdo-*.vsix` | VS Code / Cursor extension | | `marqdo-*.vsix` | VS Code / Cursor extension |
| `marqdo-*-public.zip` | Static user docs site | | `marqdo-*-public.zip` | Static user docs site |
@@ -120,9 +135,41 @@ jobs:
dist/${{ env.ZIP }} dist/${{ env.ZIP }}
dist/${{ env.STDLIB }} dist/${{ env.STDLIB }}
dist/${{ env.EXT }} dist/${{ env.EXT }}
dist/${{ env.NATIVE }}
dist/${{ env.VSIX }} dist/${{ env.VSIX }}
dist/${{ env.SOURCE }} dist/${{ env.SOURCE }}
dist/${{ env.PUBLIC }} dist/${{ env.PUBLIC }}
fail_on_unmatched_files: true fail_on_unmatched_files: true
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
linux-native:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build official plugins (release)
run: cargo build --release -p marqdo_plugin_web -p marqdo_plugin_agent -p marqdo_plugin_quantum
- name: Package native zip
run: |
set -euo pipefail
VER="${GITHUB_REF_NAME#v}"
TARGET="x86_64-unknown-linux-gnu"
mkdir -p dist/stage-native/native
cp target/release/libweb.so dist/stage-native/native/libweb.so
cp target/release/libagent.so dist/stage-native/native/libagent.so
cp target/release/libquantum.so dist/stage-native/native/libquantum.so
(cd dist/stage-native && zip -r "../marqdo-${VER}-native-${TARGET}.zip" .)
echo "NATIVE=marqdo-${VER}-native-${TARGET}.zip" >> "$GITHUB_ENV"
- name: Upload Linux native plugins
uses: softprops/action-gh-release@v2
with:
files: dist/${{ env.NATIVE }}
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+22
View File
@@ -8,6 +8,28 @@
### Changed ### Changed
## v0.3.5 — 2026-09-04
### Highlights
**`marqdo ext add` 无需本机 Rust**:Release 发布预编译 native 插件;CLI 可自动下载 L1(`*-ext.zip`)与 `*-native-*.zip`。Windows 便携包内含 `ext/native/*.dll`。
```bash
git checkout v0.3.5
# 或下载 Release 的 exe / zip
marqdo ext add web
marqdo ext add agent
marqdo ext add quantum
```
### Added
- **预编译原生插件资产**:`marqdo-*-native-x86_64-pc-windows-msvc.zip`、`marqdo-*-native-x86_64-unknown-linux-gnu.zip`;Windows zip 捆绑 `ext/` + native DLL。
- **`ext add` 下载回退**:本地无 `target/` 时从 GitHub Release 拉取;`MARQDO_EXT_NO_DOWNLOAD=1` / `MARQDO_EXT_VERSION` 可配置。
### Changed
- 文档:[ext-cli.md](doc/design/ext-cli.md)、[08-ext-deploy-coupling](doc/design/ext-web-customization/08-ext-deploy-coupling.md)、README 安装步骤以预编译为默认路径。
- Release workflow:Windows 编插件并上传 native zip;新增 Linux native job。
## v0.3.4 — 2026-09-04 ## v0.3.4 — 2026-09-04
### Highlights ### Highlights
Generated
+21 -2
View File
@@ -463,6 +463,12 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crossbeam-utils"
version = "0.8.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61803da095bee82a81bb1a452ecc25d3b2f1416d1897eb86430c6159ef717c17"
[[package]] [[package]]
name = "crypto-common" name = "crypto-common"
version = "0.1.7" version = "0.1.7"
@@ -1018,7 +1024,7 @@ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad"
[[package]] [[package]]
name = "marqdo" name = "marqdo"
version = "0.3.3" version = "0.3.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"assert_cmd", "assert_cmd",
@@ -1038,11 +1044,12 @@ dependencies = [
"tokio-tungstenite 0.24.0", "tokio-tungstenite 0.24.0",
"ureq", "ureq",
"zeroize", "zeroize",
"zip",
] ]
[[package]] [[package]]
name = "marqdo-wasm" name = "marqdo-wasm"
version = "0.3.3" version = "0.3.5"
dependencies = [ dependencies = [
"marqdo", "marqdo",
"serde_json", "serde_json",
@@ -2562,6 +2569,18 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
[[package]]
name = "zip"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261"
dependencies = [
"byteorder",
"crc32fast",
"crossbeam-utils",
"flate2",
]
[[package]] [[package]]
name = "zmij" name = "zmij"
version = "1.0.23" version = "1.0.23"
+4 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "marqdo" name = "marqdo"
version = "0.3.4" version = "0.3.5"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Marqdo — Markdown markers as an interpreted programming language" description = "Marqdo — Markdown markers as an interpreted programming language"
@@ -17,7 +17,7 @@ default = ["native"]
native = ["cli", "view", "net-host", "plugin-host", "exec-host", "fs-host", "tty"] native = ["cli", "view", "net-host", "plugin-host", "exec-host", "fs-host", "tty"]
cli = ["dep:clap"] cli = ["dep:clap"]
view = ["dep:tiny_http"] view = ["dep:tiny_http"]
net-host = ["dep:ureq", "dep:idna_adapter", "dep:zeroize"] net-host = ["dep:ureq", "dep:idna_adapter", "dep:zeroize", "dep:zip"]
plugin-host = ["dep:libloading"] plugin-host = ["dep:libloading"]
exec-host = [] exec-host = []
fs-host = [] fs-host = []
@@ -36,6 +36,8 @@ tiny_http = { version = "0.12", optional = true }
ureq = { version = "=2.9.7", default-features = false, features = ["tls", "gzip"], optional = true } ureq = { version = "=2.9.7", default-features = false, features = ["tls", "gzip"], optional = true }
idna_adapter = { version = "=1.1.0", optional = true } idna_adapter = { version = "=1.1.0", optional = true }
zeroize = { version = "=1.8.1", optional = true } zeroize = { version = "=1.8.1", optional = true }
# Extract GitHub Release ext/native zips (`marqdo ext add` without local Rust).
zip = { version = "=0.6.6", default-features = false, features = ["deflate"], optional = true }
libloading = { version = "=0.8.6", optional = true } libloading = { version = "=0.8.6", optional = true }
include_dir = "0.7" include_dir = "0.7"
libc = { version = "0.2", optional = true } libc = { version = "0.2", optional = true }
+9 -8
View File
@@ -99,7 +99,7 @@ marqdo catalog public -o .marqdo
--- ---
## 现状(v0.3.4) ## 现状(v0.3.5)
- 映射与解释器:Phase I 树遍历 + 字节码后端可用;金样例在 `tests/` - 映射与解释器:Phase I 树遍历 + 字节码后端可用;金样例在 `tests/`
- **对象**:`#` = 类型/构造,`##`+ = 函数/方法;见 [objects.md](doc/design/objects.md) - **对象**:`#` = 类型/构造,`##`+ = 函数/方法;见 [objects.md](doc/design/objects.md)
@@ -120,12 +120,12 @@ marqdo catalog public -o .marqdo
- **浏览器 Marqdo(WASM)**:`marqdo wasm build` + 官方 bridge 自启(作者零业务 JS;桥内可含列表/路由/storage/ws/文件/Canvas/音频/Observer/拖放);`lib/browser` + GFM;`web.client_embed`;示例 [browser-hello](examples/browser-hello/) · [browser-app](examples/browser-app/) · [browser-media](examples/browser-media/) · [web-client-site](examples/web-client-site/)([ADR 0002](doc/adr/0002-browser-marqdo-wasm.md) · [D](doc/roadmap/browser-wasm-d.md) · [E](doc/roadmap/browser-wasm-e.md) · [F](doc/roadmap/browser-wasm-f.md)) - **浏览器 Marqdo(WASM)**:`marqdo wasm build` + 官方 bridge 自启(作者零业务 JS;桥内可含列表/路由/storage/ws/文件/Canvas/音频/Observer/拖放);`lib/browser` + GFM;`web.client_embed`;示例 [browser-hello](examples/browser-hello/) · [browser-app](examples/browser-app/) · [browser-media](examples/browser-media/) · [web-client-site](examples/web-client-site/)([ADR 0002](doc/adr/0002-browser-marqdo-wasm.md) · [D](doc/roadmap/browser-wasm-d.md) · [E](doc/roadmap/browser-wasm-e.md) · [F](doc/roadmap/browser-wasm-f.md))
- 选型:[ADR 0001 — Rust](doc/adr/0001-implementation-language.md) · [ADR 0002 — 浏览器 WASM](doc/adr/0002-browser-marqdo-wasm.md)(C0–C5 完结,见 [roadmap/browser-wasm.md](doc/roadmap/browser-wasm.md))· [ADR 0003 — 异步效应](doc/adr/0003-browser-async-effects.md) - 选型:[ADR 0001 — Rust](doc/adr/0001-implementation-language.md) · [ADR 0002 — 浏览器 WASM](doc/adr/0002-browser-marqdo-wasm.md)(C0–C5 完结,见 [roadmap/browser-wasm.md](doc/roadmap/browser-wasm.md))· [ADR 0003 — 异步效应](doc/adr/0003-browser-async-effects.md)
### 如何使用最新 Marqdo(v0.3.4) ### 如何使用最新 Marqdo(v0.3.5)
```bash ```bash
# 1) 源码安装(跟 tag 或 main) # 1) 源码安装(跟 tag 或 main)
git clone https://github.com/cflmy/marqdo.git && cd marqdo git clone https://github.com/cflmy/marqdo.git && cd marqdo
git checkout v0.3.4 # 或留在 main git checkout v0.3.5 # 或留在 main
cargo build --release cargo build --release
export PATH="$PWD/target/release:$PATH" export PATH="$PWD/target/release:$PATH"
marqdo version marqdo version
@@ -138,12 +138,13 @@ marqdo view public --no-open
marqdo debug public --no-open marqdo debug public --no-open
marqdo catalog public -o .marqdo marqdo catalog public -o .marqdo
# 3) 安装官方扩展(需先编原生插件) # 3) 安装官方扩展(Release 用户:无需本机 Rust)
cargo build --release -p marqdo_plugin_web -p marqdo_plugin_agent -p marqdo_plugin_quantum marqdo ext add web # 或:网页 — 自动下载 L1 + 预编译 native
marqdo ext add web # 或:网页
marqdo ext add agent # 或:智能体 marqdo ext add agent # 或:智能体
marqdo ext add quantum # 或:量子 marqdo ext add quantum # 或:量子
marqdo ext add llm # 或:大模型 marqdo ext add llm # 或:大模型(纯 .mq.md)
# 开发者也可:cargo build --release -p marqdo_plugin_* 后在本机 target/ 安装
# 离线:解压 Windows zip(已含 ext/native)或手动放下 native zip;MARQDO_EXT_NO_DOWNLOAD=1
# 4) 动态站示例(扩展装好后) # 4) 动态站示例(扩展装好后)
marqdo run examples/marqdo-blog/index.mq.md marqdo run examples/marqdo-blog/index.mq.md
@@ -154,7 +155,7 @@ marqdo wasm build
# → dist/wasm/ … 见 examples/browser-hello/ # → dist/wasm/ … 见 examples/browser-hello/
# 6) Windows:也可从 GitHub Releases 下载 exe / zip / vsix # 6) Windows:也可从 GitHub Releases 下载 exe / zip / vsix
# https://github.com/cflmy/marqdo/releases/tag/v0.3.4 # https://github.com/cflmy/marqdo/releases/tag/v0.3.5
``` ```
开发期也可用 `cargo run -- …` 代替已安装的 `marqdo`: 开发期也可用 `cargo run -- …` 代替已安装的 `marqdo`:
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "marqdo-wasm" name = "marqdo-wasm"
version = "0.3.4" version = "0.3.5"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "Marqdo interpreter as WebAssembly (browser host bridge)" description = "Marqdo interpreter as WebAssembly (browser host bridge)"
+64 -33
View File
@@ -2,9 +2,9 @@
| | | | | |
|---|---| |---|---|
| Status | **Accepted (v0.1)** | | Status | **Accepted (v0.3.5 prep)** — prebuilt native download |
| Date | 2026-08-07 | | Date | 2026-09-04 |
| Related | [ext-llm.md](ext-llm.md) · [ext-agent.md](ext-agent.md) · [ext-abi.md](ext-abi.md) | | Related | [ext-llm.md](ext-llm.md) · [ext-agent.md](ext-agent.md) · [ext-abi.md](ext-abi.md) · [08-ext-deploy-coupling.md](ext-web-customization/08-ext-deploy-coupling.md) |
## Commands ## Commands
@@ -12,8 +12,8 @@
marqdo ext list marqdo ext list
marqdo ext add llm marqdo ext add llm
marqdo ext add agent marqdo ext add agent
marqdo ext add web
marqdo ext remove llm marqdo ext remove llm
marqdo ext remove agent
``` ```
## Install root ## Install root
@@ -23,57 +23,88 @@ marqdo ext remove agent
Imports use paths like `import llm:ext/ai/llm.mq.md` (see [`load.rs`](../../src/load.rs)). Imports use paths like `import llm:ext/ai/llm.mq.md` (see [`load.rs`](../../src/load.rs)).
## Source for `add` ## Goal: no local Rust required
End users who install Marqdo from **GitHub Releases** should run:
```bash
marqdo ext add web
```
and get both L1 `.mq.md` **and** the matching native plugin (`.dll` / `.so`) **without** `cargo build`.
### Resolution order (`add` with native crate)
1. Local artifact (`MARQDO_*_PLUGIN`, `target/{debug,release}`, beside `marqdo`, `MARQDO_EXT_SOURCE/native`, …)
2. **Download** `marqdo-{VER}-native-{target}.zip` from the GitHub Release for this CLI version → cache under `~/.marqdo/cache/`
3. If Rust/`cargo` is available → `cargo build -p marqdo_plugin_*` (developers)
4. Else fail with a clear message pointing at the Release assets
L1 sources:
1. `MARQDO_EXT_SOURCE` / repo `./ext` / beside binary
2. Else download `marqdo-{VER}-ext.zip` into `~/.marqdo/cache/ext-src-v{VER}/`
### Env knobs
| Variable | Meaning |
|----------|---------|
| `MARQDO_EXT_VERSION` | Override SemVer used for Release asset names (default: CLI `CARGO_PKG_VERSION`) |
| `MARQDO_EXT_NO_DOWNLOAD=1` | Never hit the network (CI / air-gap); local/cargo only |
| `MARQDO_WEB_PLUGIN` / `MARQDO_AGENT_PLUGIN` / `MARQDO_QUANTUM_PLUGIN` | Explicit native path |
Windows Release **zip** also ships `ext/` + `ext/native/*.dll` next to `marqdo.exe` so a portable unzip works offline after one download.
## Source for `add` (developers)
1. `MARQDO_EXT_SOURCE` — directory containing `ai/llm.mq.md` … 1. `MARQDO_EXT_SOURCE` — directory containing `ai/llm.mq.md` …
2. Else repo `./ext` near cwd / binary 2. Else repo `./ext` near cwd / binary
3. Else Release `marqdo-*-ext.zip` (see above)
## Layout (`ext/`) ## Layout (`ext/`)
Official extensions live under **`ext/ai/`** (LLM + agent framework only). Do not add flat `.mq.md` files at `ext/` root — keeps the tree from accumulating unrelated modules.
```text ```text
ext/ ext/
ai/ ai/ # llm + agent L1
llm.mq.md web/
大模型.mq.md quantum/
agent.mq.md
智能体.mq.md
``` ```
Future optional ext domains get their own subdirs (e.g. `ext/web/`, `ext/quantum/`), not mixed into `ai/`. Installed tree (`~/.marqdo/ext` or `MARQDO_EXT`):
```text
web/web.mq.md
web/网页.mq.md
native/libweb.so # or web.dll / libweb.dylib
web.plugin # absolute path hint
```
## Catalog ## Catalog
| Id | Installs under `MARQDO_EXT` | | Id | Installs under `MARQDO_EXT` |
|----|-----------------------------| |----|-----------------------------|
| `llm` | `ai/llm.mq.md`, `ai/大模型.mq.md` | | `llm` | `ai/llm.mq.md`, `ai/大模型.mq.md` |
| `agent` | `ai/agent.mq.md`, `ai/智能体.mq.md`, **`native/libagent.so`** (or `.dylib`) | | `agent` | `ai/agent.mq.md`, `ai/智能体.mq.md`, **native `agent`** |
| `web` | `web/web.mq.md`, `web/网页.mq.md`, **`native/libweb.so`** — 见 [ext-web.md](ext-web.md) · [roadmap](../roadmap/ext-web.md) | | `web` | `web/web.mq.md`, `web/网页.mq.md`, **native `web`** |
| `quantum` | `quantum/quantum.mq.md`, `quantum/量子.mq.md`, **`native/libquantum.so`** — 见 [ext-quantum.md](ext-quantum.md) · [roadmap](../roadmap/ext-quantum.md) | | `quantum` | `quantum/quantum.mq.md`, `quantum/量子.mq.md`, **native `quantum`** |
`add agent` / `add web` / `add quantum` **先定位原生插件**,再复制 `.mq.md`: ## Release assets (native)
1. 在 `CARGO_TARGET_DIR`、`target/{debug,release}`、源码 `ext` 旁的 `target/`、可执行文件旁等路径查找 `lib{name}.so`(或 `.dll` / `.dylib`) | Asset | Platform |
2. 找不到则自动执行 `cargo build -p marqdo_plugin_{name}`,再安装到 `MARQDO_EXT/native/` |-------|----------|
3. 写入 `{name}.plugin` 绝对路径提示,供 `plugin.native_path` 解析 | `marqdo-VER-native-x86_64-pc-windows-msvc.zip` | Windows x64 (`native/*.dll`) |
| `marqdo-VER-native-x86_64-unknown-linux-gnu.zip` | Linux x64 (`native/lib*.so`) |
这样不会出现「只装了 `.mq.md`、运行时报 native plugin not found」的半安装状态。 macOS: use local `cargo build` until CI adds Darwin natives (same zip naming pattern reserved).
```bash
# 推荐:在仓库根目录
marqdo ext add web
# 等价于找到或编好 libweb.so 后拷入 ~/.marqdo/ext/native/
```
Without a prior install, runtime still resolves via `plugin.native_path name=web` (see [ext-abi.md](ext-abi.md)): `MARQDO_WEB_PLUGIN` → `CARGO_TARGET_DIR/{debug,release}/` → cwd `target/…` → beside `marqdo` binary → `MARQDO_EXT/native/`.
## Tests ## Tests
`tests/gold.rs`: `ext_cli_add_list_remove_llm`, `ext_cli_add_agent`, `ext_agent_framework_smoke`, `ext_agent_run_live` ([`tests/ext/agent-run-live.mq.md`](../../tests/ext/agent-run-live.mq.md); needs `tests/ext/.env` + built `libagent`). `tests/gold.rs`: `ext_cli_add_list_remove_llm`, `ext_cli_add_agent`, `ext_cli_add_web` (local build path; set `MARQDO_EXT_NO_DOWNLOAD=1` in sandboxes if needed).
Unit: `ext_fetch` URL / triple tests.
## Non-goals ## Non-goals
- Third-party registry - Third-party registry
- Merging into `lib/` - Merging domain helpers into `lib/`
- Bundling domain/task helpers in official ext - Guaranteeing plugin **source** ABI stability (author `.mq.md` API is the contract)
@@ -55,6 +55,14 @@
--- ---
## 6. 过渡期 workaround ## 6. 过渡期 → 预编译路径(进行中)
锁定 Marqdo 与插件同版本镜像;本地 `MARQDO_EXT` 指向仓库构建产物;定制需求提 issue 对照本目录解决文,避免沉默 fork 漂移。 **目标:** 用户 `marqdo ext add web` **不必**本机 Rust。
| 交付 | 说明 |
|------|------|
| Release `marqdo-*-native-*.zip` | Windows / Linux 预编译 `web`/`agent`/`quantum` |
| Windows portable zip | 内含 `ext/` + `ext/native/*.dll` |
| `ext add` 下载回退 | 本地无 `.so`/`.dll` 时从 GitHub Release 拉取(`MARQDO_EXT_NO_DOWNLOAD=1` 可关) |
仍保留开发者 `cargo build -p marqdo_plugin_*` 路径。详见 [ext-cli.md](../ext-cli.md)。
+63 -20
View File
@@ -173,8 +173,24 @@ fn find_source_file(name: &str) -> Result<PathBuf> {
return Ok(p); return Ok(p);
} }
} }
#[cfg(feature = "net-host")]
{
if crate::ext_fetch::downloads_enabled() {
match crate::ext_fetch::ensure_ext_source_tree() {
Ok(root) => {
let p = root.join(name);
if p.is_file() {
return Ok(p);
}
}
Err(e) => {
eprintln!("note: could not download ext sources: {e:#}");
}
}
}
}
bail!( bail!(
"cannot find source `{name}` for install (set MARQDO_EXT_SOURCE to an ext/ directory, or run from the Marqdo repo)" "cannot find source `{name}` for install (set MARQDO_EXT_SOURCE to an ext/ directory, run from the Marqdo repo, or use a release that publishes marqdo-*-ext.zip)"
); );
} }
@@ -240,31 +256,58 @@ fn find_native_plugin(short: &str) -> Result<PathBuf> {
) )
} }
/// Locate a built native plugin, or `cargo build -p …` once then look again. /// Locate a built native plugin: local artifact → GitHub Release prebuild → optional cargo build.
fn ensure_native_plugin(crate_name: &str) -> Result<PathBuf> { fn ensure_native_plugin(crate_name: &str) -> Result<PathBuf> {
let short = native_short_name(crate_name); let short = native_short_name(crate_name);
if let Ok(p) = find_native_plugin(short) { if let Ok(p) = find_native_plugin(short) {
return Ok(p); return Ok(p);
} }
println!( let lib_name = native_lib_filename(short);
"native plugin for `{short}` not found; building `{crate_name}` (debug)…"
); #[cfg(feature = "net-host")]
let status = std::process::Command::new("cargo") {
.args(["build", "-p", crate_name]) match crate::ext_fetch::download_native_plugin(short, &lib_name) {
.status() Ok(p) => return Ok(p),
.with_context(|| format!("spawn cargo build -p {crate_name}"))?; Err(e) => {
if !status.success() { eprintln!("note: prebuilt native download skipped/failed: {e:#}");
bail!( }
"cargo build -p {crate_name} failed (status {status}); build the plugin then re-run `marqdo ext add {short}`" }
);
} }
find_native_plugin(short).with_context(|| {
format!( #[cfg(feature = "net-host")]
"built `{crate_name}` but still cannot find {}; set {} to the .so/.dll path", let have_cargo = crate::ext_fetch::cargo_available();
native_lib_filename(short), #[cfg(not(feature = "net-host"))]
native_env_var(short) let have_cargo = true;
)
}) if have_cargo {
println!(
"native plugin for `{short}` not found; building `{crate_name}` (debug)…"
);
let status = std::process::Command::new("cargo")
.args(["build", "-p", crate_name])
.status()
.with_context(|| format!("spawn cargo build -p {crate_name}"))?;
if !status.success() {
bail!(
"cargo build -p {crate_name} failed (status {status}); \
install a prebuilt release asset or build the plugin then re-run `marqdo ext add {short}`"
);
}
return find_native_plugin(short).with_context(|| {
format!(
"built `{crate_name}` but still cannot find {}; set {} to the .so/.dll path",
lib_name,
native_env_var(short)
)
});
}
bail!(
"cannot find native plugin `{lib_name}` and Rust/cargo is not available. \
Install Marqdo from a GitHub Release that includes `marqdo-*-native-*.zip`, \
or set {} to a built plugin path.",
native_env_var(short)
)
} }
pub fn add_ext(id: &str) -> Result<()> { pub fn add_ext(id: &str) -> Result<()> {
+307
View File
@@ -0,0 +1,307 @@
//! Download official `ext/` L1 sources and native plugins from GitHub Releases.
//!
//! Enables `marqdo ext add web` without a local Rust toolchain or repo checkout.
//! Disable with `MARQDO_EXT_NO_DOWNLOAD=1`. Override tag with `MARQDO_EXT_VERSION=0.3.4`.
use std::env;
use std::fs::{self, File};
use std::io::{self, Write};
use std::path::{Path, PathBuf};
use anyhow::{bail, Context, Result};
const REPO: &str = "cflmy/marqdo";
pub fn downloads_enabled() -> bool {
match env::var("MARQDO_EXT_NO_DOWNLOAD") {
Ok(v) => {
let v = v.trim();
!(v == "1" || v.eq_ignore_ascii_case("true") || v.eq_ignore_ascii_case("yes"))
}
Err(_) => true,
}
}
/// SemVer without leading `v` (matches release asset names).
pub fn release_version() -> String {
if let Ok(v) = env::var("MARQDO_EXT_VERSION") {
let v = v.trim().trim_start_matches('v');
if !v.is_empty() {
return v.to_string();
}
}
env!("CARGO_PKG_VERSION").to_string()
}
pub fn host_target_triple() -> Option<&'static str> {
if cfg!(all(target_os = "windows", target_arch = "x86_64")) {
Some("x86_64-pc-windows-msvc")
} else if cfg!(all(target_os = "linux", target_arch = "x86_64")) {
Some("x86_64-unknown-linux-gnu")
} else if cfg!(all(target_os = "macos", target_arch = "aarch64")) {
Some("aarch64-apple-darwin")
} else if cfg!(all(target_os = "macos", target_arch = "x86_64")) {
Some("x86_64-apple-darwin")
} else {
None
}
}
fn cache_root() -> Result<PathBuf> {
let home = env::var_os("USERPROFILE")
.or_else(|| env::var_os("HOME"))
.map(PathBuf::from)
.unwrap_or_else(|| PathBuf::from("."));
let dir = home.join(".marqdo").join("cache");
fs::create_dir_all(&dir)?;
Ok(dir)
}
fn user_agent() -> String {
format!("marqdo/{}", env!("CARGO_PKG_VERSION"))
}
fn download_to_file(url: &str, dest: &Path) -> Result<()> {
if let Some(parent) = dest.parent() {
fs::create_dir_all(parent)?;
}
let tmp = dest.with_extension("download-tmp");
let resp = ureq::get(url)
.set("User-Agent", &user_agent())
.set("Accept", "application/octet-stream")
.call()
.with_context(|| format!("GET {url}"))?;
if !(200..300).contains(&resp.status()) {
bail!("download {url} returned HTTP {}", resp.status());
}
let mut reader = resp.into_reader();
let mut out = File::create(&tmp).with_context(|| format!("create {}", tmp.display()))?;
io::copy(&mut reader, &mut out).with_context(|| format!("write {}", tmp.display()))?;
out.flush()?;
drop(out);
if dest.exists() {
let _ = fs::remove_file(dest);
}
fs::rename(&tmp, dest).with_context(|| format!("rename {}", dest.display()))?;
Ok(())
}
fn extract_zip(zip_path: &Path, dest_dir: &Path) -> Result<()> {
fs::create_dir_all(dest_dir)?;
let file = File::open(zip_path).with_context(|| format!("open {}", zip_path.display()))?;
let mut archive = zip::ZipArchive::new(file)
.with_context(|| format!("read zip {}", zip_path.display()))?;
for i in 0..archive.len() {
let mut entry = archive
.by_index(i)
.with_context(|| format!("zip entry {i}"))?;
let name = entry.name().to_string();
if name.is_empty() {
continue;
}
if Path::new(&name)
.components()
.any(|c| matches!(c, std::path::Component::ParentDir))
{
bail!("refusing zip entry with ..: {name}");
}
let out_path = dest_dir.join(Path::new(&name));
if entry.is_dir() || name.ends_with('/') {
fs::create_dir_all(&out_path)?;
continue;
}
if let Some(parent) = out_path.parent() {
fs::create_dir_all(parent)?;
}
let mut outfile =
File::create(&out_path).with_context(|| format!("create {}", out_path.display()))?;
io::copy(&mut entry, &mut outfile)
.with_context(|| format!("extract {name}"))?;
}
Ok(())
}
fn release_asset_url(ver: &str, filename: &str) -> String {
format!("https://github.com/{REPO}/releases/download/v{ver}/{filename}")
}
/// Ensure L1 `ext/` tree is available (repo checkout or downloaded Release zip).
/// Returns a directory that contains `web/web.mq.md`, `ai/…`, etc.
pub fn ensure_ext_source_tree() -> Result<PathBuf> {
let ver = release_version();
let cache = cache_root()?.join(format!("ext-src-v{ver}"));
let marker = cache.join("web").join("web.mq.md");
if marker.is_file() {
return Ok(cache);
}
// Zip layout from CI: top-level `ext/…`
let nested = cache.join("ext").join("web").join("web.mq.md");
if nested.is_file() {
return Ok(cache.join("ext"));
}
if !downloads_enabled() {
bail!("extension sources not found and downloads disabled (MARQDO_EXT_NO_DOWNLOAD)");
}
let zip_name = format!("marqdo-{ver}-ext.zip");
let url = release_asset_url(&ver, &zip_name);
let zip_path = cache_root()?.join(&zip_name);
println!("downloading official ext sources ({url})…");
download_to_file(&url, &zip_path)?;
let stage = cache_root()?.join(format!("ext-src-v{ver}-extract"));
if stage.exists() {
let _ = fs::remove_dir_all(&stage);
}
extract_zip(&zip_path, &stage)?;
// Prefer `ext/` child if present
let src = if stage.join("ext").join("web").join("web.mq.md").is_file() {
stage.join("ext")
} else if stage.join("web").join("web.mq.md").is_file() {
stage.clone()
} else {
bail!(
"downloaded {zip_name} but could not find web/web.mq.md inside; check release assets"
);
};
if cache.exists() {
let _ = fs::remove_dir_all(&cache);
}
// Move/copy tree into stable cache path
copy_dir_recursive(&src, &cache)?;
let _ = fs::remove_dir_all(&stage);
if !cache.join("web").join("web.mq.md").is_file() {
bail!("failed to cache ext sources under {}", cache.display());
}
println!("cached ext sources at {}", cache.display());
Ok(cache)
}
fn copy_dir_recursive(src: &Path, dest: &Path) -> Result<()> {
fs::create_dir_all(dest)?;
for entry in fs::read_dir(src).with_context(|| format!("read {}", src.display()))? {
let entry = entry?;
let ty = entry.file_type()?;
let to = dest.join(entry.file_name());
if ty.is_dir() {
copy_dir_recursive(&entry.path(), &to)?;
} else if ty.is_file() {
if let Some(parent) = to.parent() {
fs::create_dir_all(parent)?;
}
fs::copy(entry.path(), &to)
.with_context(|| format!("copy {} → {}", entry.path().display(), to.display()))?;
}
}
Ok(())
}
/// Download prebuilt native plugins zip for this host; return path to `lib` file for `short`.
pub fn download_native_plugin(short: &str, lib_name: &str) -> Result<PathBuf> {
if !downloads_enabled() {
bail!("native plugin not found and downloads disabled (MARQDO_EXT_NO_DOWNLOAD)");
}
let Some(triple) = host_target_triple() else {
bail!(
"no prebuilt native plugins for this platform; install Rust and run `cargo build -p marqdo_plugin_{short}`"
);
};
let ver = release_version();
let zip_name = format!("marqdo-{ver}-native-{triple}.zip");
let url = release_asset_url(&ver, &zip_name);
let cache = cache_root()?.join(format!("native-v{ver}-{triple}"));
let lib_in_cache = cache.join("native").join(lib_name);
if lib_in_cache.is_file() {
return Ok(lib_in_cache);
}
// Also accept flat layout
let flat = cache.join(lib_name);
if flat.is_file() {
return Ok(flat);
}
let zip_path = cache_root()?.join(&zip_name);
println!("downloading prebuilt native plugins ({url})…");
download_to_file(&url, &zip_path).with_context(|| {
format!(
"failed to download prebuilt plugins for {triple}. \
Build locally with `cargo build --release -p marqdo_plugin_{short}`, \
or check https://github.com/{REPO}/releases/tag/v{ver}"
)
})?;
if cache.exists() {
let _ = fs::remove_dir_all(&cache);
}
fs::create_dir_all(&cache)?;
extract_zip(&zip_path, &cache)?;
if lib_in_cache.is_file() {
println!("cached {}", lib_in_cache.display());
return Ok(lib_in_cache);
}
if flat.is_file() {
return Ok(flat);
}
// Search recursively for the lib name
if let Some(found) = find_named_file(&cache, lib_name)? {
return Ok(found);
}
bail!(
"downloaded {zip_name} but missing {lib_name}; expected native/{lib_name} in the archive"
)
}
fn find_named_file(root: &Path, name: &str) -> Result<Option<PathBuf>> {
fn walk(dir: &Path, name: &str, out: &mut Option<PathBuf>) -> Result<()> {
if out.is_some() {
return Ok(());
}
for entry in fs::read_dir(dir)? {
let entry = entry?;
let p = entry.path();
if entry.file_type()?.is_dir() {
walk(&p, name, out)?;
} else if entry.file_name() == name {
*out = Some(p);
}
}
Ok(())
}
let mut found = None;
walk(root, name, &mut found)?;
Ok(found)
}
pub fn cargo_available() -> bool {
std::process::Command::new("cargo")
.arg("-V")
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.status()
.map(|s| s.success())
.unwrap_or(false)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn asset_url_shape() {
let u = release_asset_url("0.3.4", "marqdo-0.3.4-ext.zip");
assert_eq!(
u,
"https://github.com/cflmy/marqdo/releases/download/v0.3.4/marqdo-0.3.4-ext.zip"
);
}
#[test]
fn triple_known_on_ci_hosts() {
// At least one of these builds is what we ship.
let t = host_target_triple();
if cfg!(any(
all(target_os = "linux", target_arch = "x86_64"),
all(target_os = "windows", target_arch = "x86_64"),
all(target_os = "macos", target_arch = "aarch64"),
all(target_os = "macos", target_arch = "x86_64"),
)) {
assert!(t.is_some());
}
}
}
+2
View File
@@ -16,6 +16,8 @@ pub mod diagnostics;
pub mod embedded_lib; pub mod embedded_lib;
#[cfg(feature = "cli")] #[cfg(feature = "cli")]
pub mod ext_cli; pub mod ext_cli;
#[cfg(all(feature = "cli", feature = "net-host"))]
pub mod ext_fetch;
pub mod foreign; pub mod foreign;
pub mod formula; pub mod formula;
pub mod host; pub mod host;
+2
View File
@@ -1261,6 +1261,7 @@ fn ext_cli_add_agent() {
.args(["ext", "add", "agent"]) .args(["ext", "add", "agent"])
.env("MARQDO_EXT", &tmp) .env("MARQDO_EXT", &tmp)
.env("MARQDO_EXT_SOURCE", &src) .env("MARQDO_EXT_SOURCE", &src)
.env("MARQDO_EXT_NO_DOWNLOAD", "1")
.current_dir(env!("CARGO_MANIFEST_DIR")) .current_dir(env!("CARGO_MANIFEST_DIR"))
.status() .status()
.expect("ext add agent"); .expect("ext add agent");
@@ -1297,6 +1298,7 @@ fn ext_cli_add_web() {
.args(["ext", "add", "web"]) .args(["ext", "add", "web"])
.env("MARQDO_EXT", &tmp) .env("MARQDO_EXT", &tmp)
.env("MARQDO_EXT_SOURCE", &src) .env("MARQDO_EXT_SOURCE", &src)
.env("MARQDO_EXT_NO_DOWNLOAD", "1")
.current_dir(env!("CARGO_MANIFEST_DIR")) .current_dir(env!("CARGO_MANIFEST_DIR"))
.status() .status()
.expect("ext add web"); .expect("ext add web");