refactor(view): unify cells into the view surface
Cell controls now appear only when a document declares 内核表/会话表. Remove Notebook branding and Jupyter In/Out prompts; ordinary view pages stay classic. There is no new CLI command or second interactive mode; run remains canonical execution and view is the only interactive surface.
This commit is contained in:
1 parent
024cdee82a
commit
7fef690167
18 files changed
+75
-76
No files matched your search
@@ -210,7 +210,7 @@ Design: [ext-quantum.md](../../doc/design/ext-quantum.md) · Q7: [ext-quantum-q7
|
||||
- `invoke` returns a record (`ok`, `code`, `stdout`, `stderr`, `ms`, `timed_out`, `truncated`, `result`); pass `input` for JSON stdin and `output="json"` for a parsed result.
|
||||
- `call` is JSON-in / JSON-out; `call_many` fans out one program over a list with ordered results.
|
||||
- `session_open` starts a persistent Python/Node kernel; `session_eval` evaluates source; `session_set` / `session_get` bridge values explicitly as JSON. Close it with `session_close`.
|
||||
- A notebook is still a document: bind `内核表` and `会话表` as ordinary tables inside `# main`. A `view` session adds cell stepping, Run All, kernel switching, journal and reload. No new Markdown marker exists.
|
||||
- A view document can expose cells: bind `内核表` and `会话表` as ordinary tables inside `# main`. `marqdo view` adds cell stepping, Run All, kernel switching, journal and reload. There is no separate notebook CLI mode or command, and no new Markdown marker exists.
|
||||
- The same source remains the authority; state crossing kernels is explicit, never implicitly mirrored.
|
||||
|
||||
## AI authoring workflow
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@
|
||||
|
||||
### Added
|
||||
|
||||
- **view cells 概念收敛**:`view` 是唯一交互面;只有文档声明 `内核表` / `会话表` 时才显示 cell 控件,普通 view 不显示;移除 `In []` / `Out []` 的 Jupyter 式提示与 Notebook 品牌;没有新增 notebook CLI 或第二个交互模式。
|
||||
### Fixed
|
||||
|
||||
### Changed
|
||||
@@ -22,7 +23,7 @@ git checkout v1.5.0 && cargo build --release
|
||||
|
||||
### Added
|
||||
|
||||
- **用户静态站(外联 / OKF / EKC)**:新增中英双语 `features/19-foreign-notebook` 与 `features/20-okf-ekc`,重写 `stdlib/foreign`,首页加入「一份文件三个面」、外联 Python 运行、Notebook 表、OKF/EKC 与 preflight 说明。
|
||||
- **用户静态站(外联 / OKF / EKC)**:新增中英双语 `features/19-foreign-view-cells` 与 `features/20-okf-ekc`,重写 `stdlib/foreign`,首页加入「一份文件三个面」、外联 Python 运行、Notebook 表、OKF/EKC 与 preflight 说明。
|
||||
- **`lib/foreign` F0/F1**:`invoke` 结构化记录(`ok`/`code`/`stdout`/`stderr`/`ms`/`timed_out`/`truncated`/`result`);`run`/`run_lang` 新增 `env`/`cwd`/`timeout`/`args`/`max_output`;15 个语言预设;`probe`/`register`/`unset`/`load_config`;`.marqdo/foreign.toml`。
|
||||
- **`lib/foreign` F2**:JSON 进 / JSON 出 `call`;并行 `run_many` / `call_many`(有序、单项隔离、并发上限);`invoke` 的 `input` / `output` / `result` / `result_error`。
|
||||
- **`lib/foreign` F3/F3.5**:Python / Node 持久会话 `session_open` / `session_eval` / `session_close` / `session_list`;状态桥 `session_set` / `session_get` / `session_names`;会话超时即杀、崩溃隔离、drop 清理。
|
||||
|
||||
@@ -151,7 +151,7 @@ marqdo catalog public -o .marqdo
|
||||
|
||||
## 现状(v1.5.0)
|
||||
|
||||
- **外联 v2 / 文档原生 Notebook(v1.5.0)**:结构化 invoke · JSON call/call_many · 并行扇出 · Python/Node 持久内核 · 显式状态桥 · cell 单步/Run All/内核切换 · 高对比浅深主题;扩展包同步 **1.5.0**
|
||||
- **外联 v2 / view 交互单元(v1.5.0)**:结构化 invoke · JSON call/call_many · 并行扇出 · Python/Node 持久内核 · 显式状态桥 · cell 单步/Run All/内核切换 · 高对比浅深主题;扩展包同步 **1.5.0**
|
||||
- **裸自增升参(v1.4.6)**:首次粗体赋值左值即声明;`**n = n + 1**` 无反引号也升为必选形参。扩展包仍为 **1.4.5**
|
||||
- **Streamable HTTP MCP + web invoke 鉴权(v1.4.5)**:`agent_mcp_serve transport=http` · Bearer/`X-Api-Key` 注入 · `unauthorized`→401 · openai/agent `json.get` 硬化
|
||||
- **LLM 传输软失败 + `ext/ai` 表优先(v1.4.4)**:上游不可达 → `status=error`(不 abort);`agent`/`llm` 去 `json.set` 胶水 · [agent-llm-transport-soft-2026-10.md](doc/research/agent-llm-transport-soft-2026-10.md)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# 文档会话(Document Session)
|
||||
# 文档会话(View Cells)
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| 状态 | **D1–D3 首版已实现;D4/D5 待做** |
|
||||
| 日期 | 2026-10-17 |
|
||||
| 层 | Runtime + Document(view 服务端 / notebook 交互) |
|
||||
| 层 | Runtime + Document(view 服务端 / 交互单元) |
|
||||
| 相关 | [notebook-syntax.md](notebook-syntax.md) · [foreign-kernel.md](foreign-kernel.md) · [foreign-notebook-decisions.md](../research/foreign-notebook-decisions.md) · [view.md](view.md) · [view-debug.md](view-debug.md) · [stdlib-subtask.md](stdlib-subtask.md) |
|
||||
| 核心表面 Δ | 无(读取既有 AST 与表格) |
|
||||
|
||||
> 文档会话是 view 背后的“notebook 运行时”:它记住哪些 cell、在哪个内核、按什么顺序执行、状态是什么、结果是否过期。
|
||||
> 文档会话是 view 背后的交互单元运行时:它记住哪些 cell、在哪个内核、按什么顺序执行、状态是什么、结果是否过期。它不是第二个 CLI 模式——`marqdo view` 是唯一的交互面,`marqdo run` 是规范执行。
|
||||
|
||||
---
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
| view 工具栏 / 状态徽标 / 内核下拉 / 状态表单 | ✅ | `src/view/html.rs` |
|
||||
| `POST /api/session/*` | ✅(含 `reload`) | `src/view/notebook_api.rs` |
|
||||
| cell step | ✅ | 同上 |
|
||||
| Marqdo statement step | ✅(notebook 工具栏 Debug → 同一 view 服务的 `/debug`;`/api/debug/*`) | `src/debug` · `src/view/debug_api.rs` |
|
||||
| Marqdo statement step | ✅(view 工具栏 Debug → 同一 view 服务的 `/debug`;`/api/debug/*`) | `src/debug` · `src/view/debug_api.rs` |
|
||||
| dirty/stale 自动检测 | 部分(reload → dirty;assign → dirty;stale 传播待做) | `src/notebook/mod.rs` |
|
||||
| writeback 集成 | 待做 | `writeback` |
|
||||
| replay / 持久化 | 待做 | — |
|
||||
@@ -50,18 +50,18 @@
|
||||
|
||||
---
|
||||
|
||||
## 2. 两种执行模式
|
||||
## 2. 两种执行面(不是两个 CLI 模式)
|
||||
|
||||
### 2.1 Program mode(规范)
|
||||
### 2.1 Program execution(规范)
|
||||
|
||||
- 入口:`marqdo run doc.mq.md` / CI / `view` 的 `Run document`。
|
||||
- 执行:`# main` 程序语义;外联通过显式 `foreign.session_open/eval/call` 编排。
|
||||
- 状态:一次运行内有效;运行结束进程退出(除非显式持久内核)。
|
||||
- 结果:可复现;是文档的“真理”。
|
||||
|
||||
### 2.2 Notebook mode(交互)
|
||||
### 2.2 View cells(交互)
|
||||
|
||||
- 入口:`marqdo view doc.mq.md` → Session 面板。
|
||||
- 入口:`marqdo view doc.mq.md` → 文档单元(cell)控制。
|
||||
- 执行:按 `会话表`(或自动顺序)逐 cell 执行。
|
||||
- 状态:内核持久;可切换、重启、单步。
|
||||
- 结果:默认临时显示;可显式 writeback。
|
||||
@@ -72,7 +72,7 @@
|
||||
```text
|
||||
.mq.md
|
||||
/ \
|
||||
Program mode Notebook mode
|
||||
Program run View cells
|
||||
(canonical) (interactive)
|
||||
\ /
|
||||
Document Session
|
||||
@@ -83,8 +83,8 @@
|
||||
```
|
||||
|
||||
- 共享 cell index 与 kernel registry。
|
||||
- Program mode 可以不使用 notebook 表;Notebook mode 可以使用。
|
||||
- 冲突时以 Program mode 为准;Notebook mode 不改变文档语义。
|
||||
- `run` 不使用 cell 表;`view` 在文档声明 `内核表` / `会话表` 时提供 cell 控制。
|
||||
- 冲突时以 `run` 的程序语义为准;view cells 不改变文档语义。
|
||||
|
||||
---
|
||||
|
||||
@@ -107,7 +107,7 @@ DocumentSession
|
||||
├── value_store: HashMap<String, Value> // Marqdo 侧会话值
|
||||
├── journal: Vec<ExecutionRecord>
|
||||
├── created_ms / last_active_ms
|
||||
└── mode: program | notebook
|
||||
└── surface: program | view
|
||||
```
|
||||
|
||||
### 3.1 Cell
|
||||
@@ -233,7 +233,7 @@ resolve cell -> resolve kernel
|
||||
| **Marqdo statement step** | 执行下一条 Marqdo 语句;遇到 `foreign.session_eval` 时整个外联调用原子完成 |
|
||||
| **Foreign line step** | 不做;未来 DAP |
|
||||
|
||||
- Cell step 是 Notebook mode 的主单步。
|
||||
- Cell step 是 view cells 的主单步。
|
||||
- Statement step 复用 `DebugController`;需要把 debug session 与 DocumentSession 关联。
|
||||
- 两者可以互相切换:cell step 到某个 Marqdo cell 后可 statement step;语句执行完回到 cell 边界。
|
||||
|
||||
@@ -333,7 +333,7 @@ resolve cell -> resolve kernel
|
||||
|
||||
### 7.1 默认
|
||||
|
||||
- Notebook mode 输出只在 view 中显示;不写 `.mq.md`。
|
||||
- View cells 输出只在 view 中显示;不写 `.mq.md`。
|
||||
- 关闭/刷新后可通过 journal 恢复最近结果(若 session 持久化)。
|
||||
- 不写 execution_count 到文档。
|
||||
|
||||
@@ -495,7 +495,7 @@ Kernel: [分析 ▾] Status: ready [Restart] [Interrupt]
|
||||
| 源 | `.ipynb` | `.mq.md` |
|
||||
| 执行顺序 | 隐藏的 `In[n]` | 会话表 / 文档顺序 / journal |
|
||||
| 状态 | 隐藏 kernel | kernel + value store + 状态面板 |
|
||||
| 多语言 | 一 notebook 一 kernel | 命名内核 + 每 cell 归属 |
|
||||
| 多语言 | 一文档一 kernel | 命名内核 + 每 cell 归属 |
|
||||
| 单步 | cell | cell + statement |
|
||||
| 复现 | 手动 | Restart & Run All + journal + replay |
|
||||
| Git | 输出/计数噪声 | 源码干净;输出显式 |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# 文档原生 Notebook 语法
|
||||
# 文档原生 view cells 语法
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
@@ -247,11 +247,11 @@ print(x + 1)
|
||||
|
||||
- `内核表` / `会话表` 是**声明**,不是执行指令。
|
||||
- `marqdo run` 仍然执行 `# main` 的程序语义;这两个表会被求值为普通数据。
|
||||
- Program mode 的外联编排用显式 API(`foreign.session_open` / `session_eval` / `call`);表只服务 view 的 notebook 会话与一键 Run All。
|
||||
- `run` 的外联编排用显式 API(`foreign.session_open` / `session_eval` / `call`);表只服务 `view` 的 cells 与一键 Run All。
|
||||
- 两种模式可以并存:
|
||||
- 文档用表描述“交互时怎么跑”;
|
||||
- `# main` 用显式调用描述“CI 时怎么跑”。
|
||||
- 如果两者冲突,以 Program mode 的程序语义为准;Notebook mode 的表只影响 view。
|
||||
- 如果两者冲突,以 `run` 的程序语义为准;cell 表只影响 `view`。
|
||||
|
||||
这样避免把“执行计划”变成第二套程序语义。
|
||||
|
||||
|
||||
@@ -54,8 +54,8 @@
|
||||
### 结论 C:Hybrid 执行模型
|
||||
|
||||
- **Program mode(规范模式)**:`marqdo run` / CI / 可复现执行。文档是程序;外联通过显式 `foreign.session_*` / `call` 编排;结果可重复。
|
||||
- **Notebook mode(交互模式)**:`view` 中按 cell 执行、单步、切换内核、查看状态。适合探索,不默认写入文档。
|
||||
- 两者共享同一个内核运行时与同一套 cell 索引;Notebook mode 是 Program mode 的**交互镜头**,不是替代品。
|
||||
- **View cells(交互面)**:`view` 中按 cell 执行、单步、切换内核、查看状态。适合探索,不默认写入文档;不是第二个 CLI 模式。
|
||||
- 两者共享同一个内核运行时与同一套 cell 索引;view cells 是 program execution 的**交互镜头**,不是替代品。
|
||||
|
||||
理由:如果让 cell 执行取代文档程序语义,Marqdo 就退化成 Jupyter;如果只有 Program mode,就失去 Jupyter 的即时反馈。Hybrid 同时保留两者。
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
### 结论 H:输出默认临时,writeback 显式;状态不写进 `.mq.md`
|
||||
|
||||
- Notebook mode 的输出默认只在 view 中显示,不修改文档。
|
||||
- View cells 的输出默认只在 view 中显示,不修改文档。
|
||||
- 需要持久化时显式 writeback(沿用 `<!-- marqdo-out … -->`),可 Git 跟踪、可忽略。
|
||||
- 执行日志放 `.marqdo/sessions/…`(默认 git 忽略)。
|
||||
- 不把 execution_count / kernel 状态 / base64 输出写进 `.mq.md`。
|
||||
|
||||
@@ -57,9 +57,9 @@ Foreign v2 is a good example. Probe Python, then run the bound fence:
|
||||
2. *
|
||||
> print text="(python3 not found — install Python to run this cell)"
|
||||
|
||||
The same module also supports JSON calls, parallel fan-out, persistent kernels and an explicit state bridge. See [stdlib/foreign.mq.md](stdlib/foreign.mq.md) and the full Python walkthrough in [features/19-foreign-notebook.mq.md](features/19-foreign-notebook.mq.md).
|
||||
The same module also supports JSON calls, parallel fan-out, persistent kernels and an explicit state bridge. See [stdlib/foreign.mq.md](stdlib/foreign.mq.md) and the full Python walkthrough in [features/19-foreign-view-cells.mq.md](features/19-foreign-view-cells.mq.md).
|
||||
|
||||
A notebook is still a document. Named kernels and a cell order are ordinary bound tables:
|
||||
A view document is still a document. Named kernels and a cell order are ordinary bound tables:
|
||||
|
||||
```text
|
||||
`内核表` =
|
||||
@@ -78,7 +78,7 @@ A notebook is still a document. Named kernels and a cell order are ordinary boun
|
||||
| 独立复核 | 复核 | validate |
|
||||
```
|
||||
|
||||
Live view turns that into Run All, Step, per-cell kernels, a journal and a state panel. Program mode still runs the file as one program.
|
||||
`marqdo view` turns that into Run All, Step, per-cell kernels, a journal and a state panel. There is no separate interactive mode or command; `marqdo run` still executes the file as one program.
|
||||
|
||||
Documentation becomes knowledge when it can be discovered, verified and reused. OKF supplies the portable Markdown + YAML shape; EKC projects the repository into catalog layers L0–L4, a graph and an engineering preflight. The source `.mq.md` remains the only authority; generated artifacts are marked and rebuildable.
|
||||
|
||||
|
||||
+3
-3
@@ -57,9 +57,9 @@ print("hello-from-python")
|
||||
2. *
|
||||
> 打印 内容="(未找到 python3 — 安装 Python 后可运行此单元)"
|
||||
|
||||
同一个模块还支持 JSON 调用、并行扇出、持久内核与显式状态桥。见 [stdlib/外联.mq.md](stdlib/外联.mq.md) 与完整 Python 示例 [features/19-外联Notebook.mq.md](features/19-外联Notebook.mq.md)。
|
||||
同一个模块还支持 JSON 调用、并行扇出、持久内核与显式状态桥。见 [stdlib/外联.mq.md](stdlib/外联.mq.md) 与完整 Python 示例 [features/19-外联视图单元.mq.md](features/19-外联视图单元.mq.md)。
|
||||
|
||||
Notebook 仍然是一篇文档。命名内核与单元顺序就是普通绑定表:
|
||||
view 仍然是一篇文档。命名内核与单元顺序就是普通绑定表:
|
||||
|
||||
```text
|
||||
`内核表` =
|
||||
@@ -78,7 +78,7 @@ Notebook 仍然是一篇文档。命名内核与单元顺序就是普通绑定
|
||||
| 独立复核 | 复核 | 校验 |
|
||||
```
|
||||
|
||||
live view 会把它变成 Run All、Step、每单元内核、journal 与状态面板;Program 模式仍然把文件当单个程序运行。
|
||||
`marqdo view` 会把它变成 Run All、Step、每单元内核、journal 与状态面板。没有单独的交互模式或命令;`marqdo run` 仍然把文件当单个程序运行。
|
||||
|
||||
文档能被发现、验证和复用时,才成为知识。OKF 提供可移植的 Markdown + YAML 形态;EKC 把仓库投影成 catalog L0–L4、图与工程 preflight。源 `.mq.md` 始终是唯一权威,生成物有标记、可重建。
|
||||
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
| [`keywords/`](keywords/) | 关键字与 L0 内置 |
|
||||
| [`stdlib/`](stdlib/) | **标准库**(导入方式 + text/表/文件/时间/系统/json/网络/数学/外联/插件/**自写回**/**子任务**;v0.1.2+ 内置于 CLI) |
|
||||
| [`features/`](features/) | 特性迭代(含对象、官方 `ext/`) |
|
||||
| [`features/19-foreign-notebook.mq.md`](features/19-foreign-notebook.mq.md) / [`19-外联Notebook.mq.md`](features/19-外联Notebook.mq.md) | 外联 v2 完整 Python 示例:probe / JSON call / 并行 / 持久内核 / 状态桥 / notebook |
|
||||
| [`features/19-foreign-view-cells.mq.md`](features/19-foreign-view-cells.mq.md) / [`19-外联视图单元.mq.md`](features/19-外联视图单元.mq.md) | 外联 v2 完整 Python 示例:probe / JSON call / 并行 / 持久内核 / 状态桥 / view 单元 |
|
||||
| [`features/20-okf-ekc.mq.md`](features/20-okf-ekc.mq.md) / [`20-OKF与EKC.mq.md`](features/20-OKF与EKC.mq.md) | 代码即文档、文档即知识:OKF 形态与 EKC 工程知识编译器 |
|
||||
|
||||
官方扩展(非 stdlib):`ext/llm`、`ext/agent`、`ext/web`、`ext/quantum`、`ext/linalg` — 见 `features/05-*.mq.md`、`06-*.mq.md`、`07-linalg.mq.md` / `07-线性代数.mq.md` 与 `doc/design/ext-*.md`。
|
||||
|
||||
+5
-5
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: Foreign kernels v2 — a Python analysis notebook
|
||||
description: A complete Python data walkthrough with probe, JSON calls, parallel fan-out, persistent state, an explicit bridge and document-native notebook cells
|
||||
title: Foreign kernels v2 — Python analysis in view
|
||||
description: A complete Python data walkthrough with probe, JSON calls, parallel fan-out, persistent state and view cells
|
||||
import foreign:lib/foreign.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
This page is both a readable document and a runnable program. It uses the same file to show the foreign-kernel features added in v2: language probing, structured records, JSON in/out, parallel fan-out, a persistent Python kernel, and an explicit state bridge.
|
||||
This page is both a readable document and a runnable program. It uses the same file to show the foreign-kernel features added in v2: language probing, structured records, JSON in/out, parallel fan-out, a persistent Python kernel, and an explicit state bridge. The same source can also be opened in view as interactive cells.
|
||||
|
||||
The data is intentionally small and deterministic, so every number below can be reproduced by running the page.
|
||||
|
||||
@@ -147,7 +147,7 @@ print(json.dumps(value + 1))
|
||||
|
||||
---
|
||||
|
||||
A document-native notebook. Named kernels and a session table are ordinary bound data tables, not fence metadata or YAML config.
|
||||
Cells in view. Named kernels and a cell order are ordinary bound tables, not fence metadata or YAML config.
|
||||
|
||||
```text
|
||||
`内核表` =
|
||||
@@ -166,7 +166,7 @@ A document-native notebook. Named kernels and a session table are ordinary bound
|
||||
| 独立复核 | 复核 | read the JSON report |
|
||||
```
|
||||
|
||||
Live `view` renders these as cells with Run All, Step, per-cell kernel switching, a journal, dirty reload and a state panel. The same file still runs as a single program.
|
||||
`marqdo view` renders these as cells with Run All, Step, per-cell kernel switching, a journal, dirty reload and a state panel. There is no separate interactive command; `marqdo run` still executes the same file as one program.
|
||||
|
||||
---
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
---
|
||||
title: 外联内核 v2 — Python 分析 Notebook
|
||||
description: 从 probe、JSON 调用、并行扇出、持久状态到显式桥与文档原生 notebook 单元的完整 Python 示例
|
||||
title: 外联内核 v2 — Python 分析(view 单元)
|
||||
description: 从 probe、JSON 调用、并行扇出、持久状态到显式桥与 view 交互单元的完整 Python 示例
|
||||
导入 外联:lib/外联.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
这一页既是可读文档,也是可运行程序。它用同一份文件展示 v2 的外联内核能力:语言探测、结构化记录、JSON 进出、并行扇出、持久 Python 内核,以及显式状态桥。
|
||||
这一页既是可读文档,也是可运行程序。它用同一份文件展示 v2 的外联内核能力:语言探测、结构化记录、JSON 进出、并行扇出、持久 Python 内核,以及显式状态桥。同一份源也可以在 view 中作为交互单元打开。
|
||||
|
||||
数据故意保持小而确定,因此下面每个数字都可以通过运行本页复现。
|
||||
|
||||
@@ -147,7 +147,7 @@ print(json.dumps(value + 1))
|
||||
|
||||
---
|
||||
|
||||
文档原生 Notebook。命名内核和会话表都是普通绑定数据表,不是 fence 元数据或 YAML 配置。
|
||||
view 中的单元。命名内核和单元顺序都是普通绑定表,不是 fence 元数据或 YAML 配置。
|
||||
|
||||
```text
|
||||
`内核表` =
|
||||
@@ -166,7 +166,7 @@ print(json.dumps(value + 1))
|
||||
| 独立复核 | 复核 | 读取 JSON 报告 |
|
||||
```
|
||||
|
||||
live `view` 会把这些渲染成带 Run All、Step、切换内核、journal、dirty reload 和状态面板的单元。同一份文件仍可作为单个程序运行。
|
||||
`marqdo view` 会把这些渲染成带 Run All、Step、切换内核、journal、dirty reload 和状态面板的单元。没有单独的交互命令;`marqdo run` 仍把同一份文件当单个程序执行。
|
||||
|
||||
---
|
||||
|
||||
@@ -21,13 +21,13 @@ OKF(Open Knowledge Format)用 Markdown + YAML frontmatter 表示知识:一
|
||||
type: Capability
|
||||
title: 持久外联内核
|
||||
description: 在命名内核中运行 Python 或 Node 并保留状态
|
||||
resource: public/features/19-外联Notebook.mq.md
|
||||
resource: public/features/19-外联视图单元.mq.md
|
||||
status: stable
|
||||
verified:
|
||||
by: marqdo-knowledge/verify
|
||||
tags:
|
||||
- foreign
|
||||
- notebook
|
||||
- view-cells
|
||||
```
|
||||
|
||||
同一页可以在编辑器里读、从 catalog 链接、被 Agent 查询,也可以直接运行。未知字段保留;未知类型降级为可读正文。概念页不是源文件的复制品。
|
||||
@@ -104,7 +104,7 @@ marqdo find "外联 会话"
|
||||
marqdo reuse "实现 JSON 并行扇出"
|
||||
|
||||
# 看一次修改会影响什么
|
||||
marqdo impact public/features/19-外联Notebook.mq.md
|
||||
marqdo impact public/features/19-外联视图单元.mq.md
|
||||
|
||||
# 校验知识投影
|
||||
marqdo knowledge verify
|
||||
@@ -132,4 +132,4 @@ Catalog CLI:[Catalog CLI](../../doc/design/catalog-cli.md)
|
||||
|
||||
OKF 与 Marqdo 调研:[OKF 与 Marqdo 调研](../../doc/research/okf-and-marqdo.md)
|
||||
|
||||
外联 Notebook 示例:[外联 Notebook 示例](19-外联Notebook.mq.md)
|
||||
外联 view 单元示例:[外联 view 单元示例](19-外联视图单元.mq.md)
|
||||
@@ -21,13 +21,13 @@ A concept page can therefore point at the exact file that proves it:
|
||||
type: Capability
|
||||
title: Persistent foreign kernels
|
||||
description: Run Python or Node in a named, stateful kernel
|
||||
resource: public/features/19-foreign-notebook.mq.md
|
||||
resource: public/features/19-foreign-view-cells.mq.md
|
||||
status: stable
|
||||
verified:
|
||||
by: marqdo-knowledge/verify
|
||||
tags:
|
||||
- foreign
|
||||
- notebook
|
||||
- view-cells
|
||||
```
|
||||
|
||||
The same page can be opened in an editor, linked from a catalog, queried by an agent, and executed. Unknown fields are preserved; unknown types degrade to readable prose. The page is a concept, not a copy of one.
|
||||
@@ -104,7 +104,7 @@ marqdo find "foreign session"
|
||||
marqdo reuse "implement JSON fan-out"
|
||||
|
||||
# See what a change would touch
|
||||
marqdo impact public/features/19-foreign-notebook.mq.md
|
||||
marqdo impact public/features/19-foreign-view-cells.mq.md
|
||||
|
||||
# Validate the knowledge projection
|
||||
marqdo knowledge verify
|
||||
@@ -132,4 +132,4 @@ Catalog CLI: [Catalog CLI](../../doc/design/catalog-cli.md)
|
||||
|
||||
OKF and Marqdo research: [OKF and Marqdo research](../../doc/research/okf-and-marqdo.md)
|
||||
|
||||
Foreign notebook example: [Foreign notebook example](19-foreign-notebook.mq.md)
|
||||
Foreign view-cells example: [Foreign view-cells example](19-foreign-view-cells.mq.md)
|
||||
@@ -11,7 +11,7 @@ English-named files export English APIs; Chinese-named files export Chinese APIs
|
||||
|
||||
No extra allow flags: importing a module means you intend to use it. Under marqdo view or static export, exit soft-fails and long sleeps are clamped so the console stays up.
|
||||
|
||||
Modules: text (text / 文本), table (table / 表), files (fs / 文件), time (time / 时间), system (sys / 系统), json (json only), net (net / 网络), math (math / 数学), foreign (foreign / 外联), plugin (plugin / 插件), writeback (writeback / 自写回), subtask (subtask / 子任务). Foreign v2 adds structured invoke records, JSON calls, parallel fan-out, persistent Python/Node kernels, an explicit state bridge and document-native notebook sessions — see stdlib/foreign.mq.md and features/19-foreign-notebook.mq.md.
|
||||
Modules: text (text / 文本), table (table / 表), files (fs / 文件), time (time / 时间), system (sys / 系统), json (json only), net (net / 网络), math (math / 数学), foreign (foreign / 外联), plugin (plugin / 插件), writeback (writeback / 自写回), subtask (subtask / 子任务). Foreign v2 adds structured invoke records, JSON calls, parallel fan-out, persistent Python/Node kernels, an explicit state bridge and document-native view cells — see stdlib/foreign.mq.md and features/19-foreign-view-cells.mq.md.
|
||||
|
||||
From v0.1.2, official `lib/*.mq.md` is embedded in the `marqdo` binary (disk `lib/` or `MARQDO_LIB` still overrides). Standalone `.exe` works without a separate stdlib zip.
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ description: 如何导入官方 lib 模块
|
||||
|
||||
导入即表示要用对应能力,无需再加允许旗标。marqdo view 或静态导出里,退出会软失败、长睡眠会被钳制,以免拖垮控制台。
|
||||
|
||||
模块:文本(text / 文本)、表(table / 表)、文件(fs / 文件)、时间(time / 时间)、系统(sys / 系统)、json(仅 json)、网络(net / 网络)、数学(math / 数学)、外联(foreign / 外联)、插件(plugin / 插件)、自写回(writeback / 自写回)、子任务(subtask / 子任务)。外联 v2 新增结构化执行记录、JSON 调用、并行扇出、Python/Node 持久内核、显式状态桥与文档原生 notebook 会话 — 见 stdlib/外联.mq.md 与 features/19-外联Notebook.mq.md。
|
||||
模块:文本(text / 文本)、表(table / 表)、文件(fs / 文件)、时间(time / 时间)、系统(sys / 系统)、json(仅 json)、网络(net / 网络)、数学(math / 数学)、外联(foreign / 外联)、插件(plugin / 插件)、自写回(writeback / 自写回)、子任务(subtask / 子任务)。外联 v2 新增结构化执行记录、JSON 调用、并行扇出、Python/Node 持久内核、显式状态桥与文档原生 view 单元 — 见 stdlib/外联.mq.md 与 features/19-外联视图单元.mq.md。
|
||||
|
||||
自 v0.1.2 起,官方 `lib/*.mq.md` 内置于 `marqdo` 二进制(磁盘 `lib/` 或 `MARQDO_LIB` 仍可覆盖)。单独下载 `.exe` 即可导入标准库,无需再解压 stdlib 包。
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ This is a JSON copy, not shared memory. The kernel receives a value; Marqdo rece
|
||||
|
||||
---
|
||||
|
||||
Notebook sessions.
|
||||
Cells in view.
|
||||
|
||||
A document can declare named kernels and a cell order without new Markdown markers:
|
||||
|
||||
@@ -127,7 +127,7 @@ A document can declare named kernels and a cell order without new Markdown marke
|
||||
| 独立复核 | 复核 | isolated kernel |
|
||||
```
|
||||
|
||||
Live `view` then adds Run All, Step, kernel switching, a journal and per-cell state. See the complete Python walkthrough in [`features/19-foreign-notebook.mq.md`](../features/19-foreign-notebook.mq.md).
|
||||
`marqdo view` then adds Run All, Step, kernel switching, a journal and per-cell state. This is a view capability, not a second CLI mode. See the complete Python walkthrough in [`features/19-foreign-view-cells.mq.md`](../features/19-foreign-view-cells.mq.md).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ process.stdin.on("end", () => {
|
||||
|
||||
---
|
||||
|
||||
Notebook 会话。
|
||||
view 中的单元。
|
||||
|
||||
文档可以直接声明命名内核和单元顺序,不需要新增 Markdown 标记:
|
||||
|
||||
@@ -127,7 +127,7 @@ Notebook 会话。
|
||||
| 独立复核 | 复核 | 隔离内核 |
|
||||
```
|
||||
|
||||
live `view` 会提供 Run All、Step、切换内核、journal 和单元状态。完整 Python 示例见 [`features/19-外联Notebook.mq.md`](../features/19-外联Notebook.mq.md)。
|
||||
`marqdo view` 会提供 Run All、Step、切换内核、journal 和单元状态。这是 view 的能力,不是第二个 CLI 模式。完整 Python 示例见 [`features/19-外联视图单元.mq.md`](../features/19-外联视图单元.mq.md)。
|
||||
|
||||
---
|
||||
|
||||
|
||||
+19
-21
@@ -2870,6 +2870,13 @@ pub fn page_index(files: &[PathBuf], only: Option<&Path>, links: &LinkMode) -> S
|
||||
layout("index", &nav, &main)
|
||||
}
|
||||
|
||||
/// True only when the document declares a cell table; ordinary view pages stay classic.
|
||||
fn has_cell_tables(source: &str) -> bool {
|
||||
["`内核表`", "`会话表`", "`kernels`", "`session`"]
|
||||
.iter()
|
||||
.any(|needle| source.contains(needle))
|
||||
}
|
||||
|
||||
fn notebook_ui() -> &'static str {
|
||||
r#"<style>
|
||||
/* ── VS Code / Jupyter notebook skin ───────────────────────────────── */
|
||||
@@ -3233,16 +3240,6 @@ body.notebook-page .code-head {
|
||||
background: var(--nb-surface-2);
|
||||
}
|
||||
body.notebook-page .code-head .badge { display: none; }
|
||||
body.notebook-page .nb-prompt {
|
||||
order: 0;
|
||||
min-width: 3.2rem;
|
||||
padding-right: 0.5rem;
|
||||
border-right: 1px solid var(--nb-border);
|
||||
color: var(--nb-muted);
|
||||
font: 0.66rem/1.3 var(--mono);
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
}
|
||||
body.notebook-page .code-name {
|
||||
order: 1;
|
||||
color: var(--nb-strong);
|
||||
@@ -3350,7 +3347,7 @@ body.notebook-page .code-out {
|
||||
word-break: break-word;
|
||||
}
|
||||
body.notebook-page .code-out::before {
|
||||
content: "Out [ ]";
|
||||
content: "Output";
|
||||
display: block;
|
||||
margin-bottom: 0.38rem;
|
||||
color: var(--nb-muted);
|
||||
@@ -3470,7 +3467,7 @@ body.notebook-page .stdin-form button {
|
||||
}
|
||||
</style>
|
||||
<div class="notebook-bar" id="notebook-bar" hidden>
|
||||
<strong>Notebook</strong>
|
||||
<strong>View</strong>
|
||||
<button type="button" id="nb-run-all">Run All</button>
|
||||
<button type="button" id="nb-restart">Restart & Run All</button>
|
||||
<button type="button" id="nb-step">Step</button>
|
||||
@@ -3568,14 +3565,6 @@ body.notebook-page .stdin-form button {
|
||||
(s.cells || []).forEach(function (c) {
|
||||
var el = card(c.name);
|
||||
if (!el) return;
|
||||
var head0 = el.querySelector(".code-head");
|
||||
var prompt = el.querySelector(".nb-prompt");
|
||||
if (!prompt && head0) {
|
||||
prompt = document.createElement("span");
|
||||
prompt.className = "nb-prompt";
|
||||
head0.insertBefore(prompt, head0.firstChild);
|
||||
}
|
||||
if (prompt) prompt.textContent = "In [" + (c.runs ? c.runs : " ") + "]";
|
||||
badge(el, c.status, c.status === "clean");
|
||||
var sel = el.querySelector(".nb-kernel");
|
||||
if (!sel) {
|
||||
@@ -3872,7 +3861,7 @@ pub fn page_file(files: &[PathBuf], rel: &str, vm: &FileViewModel, links: &LinkM
|
||||
let trace_safe = vm
|
||||
.trace_json
|
||||
.replace("</", "<\\/");
|
||||
let notebook = if matches!(links, LinkMode::Live) {
|
||||
let notebook = if matches!(links, LinkMode::Live) && has_cell_tables(&vm.source) {
|
||||
notebook_ui().to_string()
|
||||
} else {
|
||||
String::new()
|
||||
@@ -4140,5 +4129,14 @@ mod tests {
|
||||
"notebook API URLs must stay relative for path-prefix proxy"
|
||||
);
|
||||
assert!(ui.contains("post(\"api/session/open\""));
|
||||
assert!(!ui.contains("In ["), "view cells must not mimic Jupyter In[] prompts");
|
||||
assert!(!ui.contains("Out ["), "view cells must not mimic Jupyter Out[] prompts");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cell_controls_only_for_cell_tables() {
|
||||
assert!(has_cell_tables("# main\n\n`内核表` =\n"));
|
||||
assert!(has_cell_tables("# main\n\n`session` =\n"));
|
||||
assert!(!has_cell_tables("# main\n\n`hi` =\n```python\nprint(1)\n```\n"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user