Frontmatter imports are now valid YAML (`import:` / `导入:` with bind→target entries), removing spaced keys. Add `marqdo migrate imports`, hard-error the old one-liner form, and migrate lib/ext/examples/tests/docs accordingly. Co-authored-by: Cursor <cursoragent@cursor.com>
4.1 KiB
markup, title, description, import
| markup | title | description | import | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| occlusion | ext/ai/sandbox | CoW trial workspace for AI-generated Marqdo: open / run / diff / commit. Native work lives in plugins/agent (`sandbox_*` → host_query). |
|
Load the agent plugin once per call (same pattern as other ext/ai helpers).
Capability profiles are GFM tables under ## profile (readable authority; open / inspect echo them). Do not invent a second table dialect.
ensure_plugin
p = plugin.native_path name="agent"
p
plugin.load path=
p
print text=ext/ai/sandbox: native agent plugin not found (build marqdo_plugin_agent or marqdo ext add agent) sys.exit code=1
profile
+ `name`=default
Named caps row as a map table (name, fs_write, exec, net, plugin). Unknown names → default.
Catalog (documentation + authority):
| name | fs_write | exec | net | plugin |
|---|---|---|---|---|
| default | true | false | false | false |
| readonly | false | false | false | false |
name== "readonly" **row = **
| name | fs_write | exec | net | plugin |
|---|---|---|---|---|
| readonly | false | false | false | false |
**row = **
| name | fs_write | exec | net | plugin |
|---|---|---|---|---|
| default | true | false | false | false |
row
open_native
+ `root`=None
Native CoW open (plugin ABI italic return). Prefer ## open for the profile-aware facade.
ensure_plugin
root> sandbox_open root=root-
> sandbox_open
open
+ `root`=None
+ `profile`=default
Open a CoW session. Optional root= (directory). Default: entry file directory.
profile= selects the caps row from ## profile (echoed by inspect).
sess = open_native root=root
prof = profile name=profile
sess = table.put in=sess at="profile" value=prof
sess
write
+ `id`
+ `path`
+ `text`
Write text into the session upper layer (host tree unchanged until commit).
ensure_plugin > sandbox_write id=
idpath=pathtext=text
read
+ `id`
+ `path`
Read through CoW (upper, else lower; whiteout misses).
ensure_plugin > sandbox_read id=
idpath=path
remove
+ `id`
+ `path`
Logical delete (whiteout).
ensure_plugin > sandbox_remove id=
idpath=path
diff
+ `id`
List of { path, kind } pending changes (write | remove).
ensure_plugin > sandbox_diff id=
id
commit
+ `id`
Apply upper / whiteout to the real workspace root.
ensure_plugin > sandbox_commit id=
id
discard
+ `id`
Drop the session without writing the host tree.
ensure_plugin > sandbox_discard id=
id
run
+ `id`
+ `source`=None
+ `path`=None
Run Marqdo under sandbox caps (exec / net / plugin off; fs via CoW).
Pass source= or path= (relative to session root).
ensure_plugin
source> sandbox_run id=idsource=sourcepath> sandbox_run id=idpath=path-
print text=ext/ai/sandbox.run: need source= or path= sys.exit code=1
inspect_native
+ `id`
ensure_plugin > sandbox_inspect id=
id
inspect
+ `id`
+ `profile`=default
Native caps / change counts, plus the GFM ## profile row under key profile.
raw = inspect_native id=id
prof = profile name=profile
out = table.put in=raw at="profile" value=prof
out
report
+ `id`
+ `path`=sandbox-diff.md
O4: write a markdown review of ## diff for marqdo view / HITL (static report file, not a UI rewrite).
pending = diff id=id
n = len value=pending
body = "# Sandbox diff report\n\nPending changes: "
body = body + n
body = body + "\n\n| path | kind |\n|------|------|\n"
- [row](遍历 pending 为 row) p = path) k = kind) body = body + "| " body = body + p body = body + " | " body = body + k body = body + " |\n"
fs.write_text path=
pathtext=body
**out = **
| path | count |
|---|---|
path |
n |
out