Edict

io.github.Sowiedu由 GitHub 帳號 Sowiedu 發布v1.9.2更新於 Oct 24, 2026

AI-agent programming language. JSON AST in, WASM out. Typed, effect-tracked, Z3-verified.

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

Edict 的本機 MCP 伺服器:面向 AI 代理的程式語言,助理以 JSON AST 撰寫程式,並進行驗證、型別檢查、驗證與編譯

可以做什麼
透過 schema、範例、錯誤目錄與解說工具及資源,了解 AST 格式、檢視範例程式與編譯器版本資訊。對程式執行結構驗證、名稱解析、型別與效應檢查、Z3 合約驗證,並進行 lint 與依節點修補。將檢查通過的 AST 編譯為 WebAssembly 並在沙箱虛擬機中執行,支援執行追蹤、除錯與決定性重播。將片段組合為模組,依已驗證合約產生測試,並封裝或匯入可攜式技能包。將程式部署到邊緣執行環境,並透過 HTTP 呼叫已部署的服務或技能。
適用情境
當你希望助理不需自由文字語法即可撰寫、驗證並執行小程式,且能依結構化編譯錯誤自行修正時使用。適合在執行前需要型別、效應與合約保證的代理產生程式碼。
執行需求
需要本機執行環境:透過 npx 以 stdio 執行 npm 套件 edict-lang,或使用已發佈的容器映像。npm 方式需要 Node.js,容器方式不需本機 Node.js。未宣告需要帳號、API 金鑰或環境變數。
安裝前請注意
程式會被實際執行,且透過轉接器可存取檔案系統、HTTP、加密與環境變數等主機能力,執行前應確認程式宣告的能力。部署與呼叫工具會將程式與請求傳送到邊緣執行環境及遠端服務。技能匯入與呼叫會執行第三方套件。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Edict,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Edict

[CI] [License: MIT] [Node.js] [MCP]

[圖片]

A programming language designed for AI agents. No parser. No syntax. Agents produce AST directly as JSON.

Edict is a statically-typed, effect-tracked programming language where the canonical program format is a JSON AST. It's purpose-built so AI agents can write, verify, and execute programs through a structured pipeline — no text parsing, no human-readable syntax, no ambiguity.

Agent (LLM)  │  produces JSON AST via MCP tool call  ↓Schema Validator ─── invalid? → StructuredError → Agent retries  ↓Name Resolver ────── undefined? → StructuredError + candidates → Agent retries  ↓Type Checker ─────── mismatch? → StructuredError + expected type → Agent retries  ↓Effect Checker ───── violation? → StructuredError + propagation chain → Agent retries  ↓Contract Verifier ── unproven? → StructuredError + counterexample → Agent retries  (Z3/SMT)            ↓                  Code Generator (pure-JS WASM encoder) → WASM → Execute

Features

  • JSON AST — Programs are JSON objects, not text files. No lexer, no parser.
  • Structured errors — Every error is a typed JSON object with enough context for an agent to self-repair.
  • Type system — Int, Float, String, Bool, Array<T>, Option<T>, Result<T,E>, records, enums, refinement types.
  • Effect tracking — Functions declare pure, reads, writes, io, fails. The compiler verifies consistency.
  • Contract verification — Pre/post conditions verified at compile time by Z3 (via SMT). Failing contracts return concrete counterexamples.
  • WASM compilation — Verified programs compile to WebAssembly via a pure-JS encoder and run in Node.js.
  • MCP interface — All tools exposed via Model Context Protocol for direct agent integration.
  • Schema migration — ASTs from older schema versions are auto-migrated. No breakage when the language evolves.

Execution Model

Edict compiles to WebAssembly and runs in a sandboxed VM. This is a deliberate security decision — not a limitation:

  • No ambient authority — compiled WASM cannot access the filesystem, network, or OS unless the host explicitly provides those capabilities via the pluggable EdictHostAdapter interface
  • Compile-time capability declaration — the effect system (io, reads, writes, fails) lets the host inspect what a program requires before running it
  • Runtime enforcement — RunLimits controls execution timeout, memory ceiling, and filesystem sandboxing
  • Defense-in-depth — agent-generated code that runs immediately needs stronger isolation than human-reviewed code. The effect system + WASM sandbox + host adapter pattern provides exactly that

Host capabilities available through adapters: filesystem (sandboxed), HTTP, crypto (SHA-256, MD5, HMAC), environment variables, CLI arguments. New capabilities are added by extending EdictHostAdapter.

Quick Start

For AI Agents (MCP)

The fastest way to use Edict is through the MCP server — it exposes the entire compiler pipeline as tool calls:

bash
npx edict-lang          # start MCP server (stdio transport, no install needed)

Or install locally:

bash
npm install edict-langnpx edict-lang          # start MCP server

Two calls to get started: edict_schema (learn the AST format) → edict_check (submit a program). See MCP Tools for the full tool list.

For Development

bash
npm installnpm test          # 2675 tests across 136 filesnpm run mcp       # start MCP server (stdio transport)

Docker

Run the Edict MCP server in a container — no local Node.js required:

bash
# stdio transport (default — for local MCP clients)docker run -i ghcr.io/sowiedu/edict
# HTTP transport (for remote/networked MCP clients)docker run -p 3000:3000 -e EDICT_TRANSPORT=http ghcr.io/sowiedu/edict

Supported platforms: linux/amd64, linux/arm64.

Browser

Run the Edict compiler entirely in the browser — no server required:

BundleSizePhasesUse case
edict-lang/browser318 KB1–3 (validate, resolve, typecheck, effects, lint, patch)Lightweight checking
edict-lang/browser-full~14 MB1–5 (+ WASM codegen, Z3 contracts, WASM execution)Full compile & run
javascript
import { compileBrowser, runBrowserDirect } from 'edict-lang/browser-full';
const result = compileBrowser(astJson);if (result.ok) {    const run = await runBrowserDirect(result.wasm);    console.log(run.output);  // "Hello, World!"}

Note: ESM modules require HTTP serving. Use npx serve . or any static server — file:// won't work.

See examples/browser/index.html for a working example.

QuickJS (Sandboxed Environments)

The Edict compiler also runs inside QuickJS WASM — useful for sandboxed runtimes, edge workers, or embedding in other WASM applications:

BundleSizePhasesSlowdown vs Node.js
dist/edict-quickjs-check.js373 KB1–3 (validate, resolve, typecheck, effects)~3.7x
dist/edict-quickjs-full.js932 KB1–5 (check + WASM compile)~3.7x
typescript
import { EdictQuickJS } from "edict-lang/quickjs";
const edict = await EdictQuickJS.createFull();  // phases 1-5const result = edict.compile(ast);if (result.ok) {    console.log(result.wasm);  // Uint8Array of valid WASM}edict.dispose();

Note: quickjs-emscripten is an optional peer dependency — install it alongside edict-lang to use EdictQuickJS. For fs-free environments, pass bundleSource directly instead of loading from disk.

See docs/quickjs-feasibility-report.md for full benchmarks and recommendations.

MCP Tools

ToolDescription
edict_schemaReturns the full AST JSON Schema — the spec for how to write programs
edict_versionReturns compiler version and capability info
edict_examplesReturns 41 example programs as JSON ASTs (includes schema snippet)
edict_validateValidates AST structure (field names, types, node kinds)
edict_checkFull pipeline: validate → resolve names → type check → effect check → verify contracts
edict_compileCompiles a checked AST to WASM (returns base64-encoded binary)
edict_runExecutes a compiled WASM binary, returns output and exit code
edict_patchApplies targeted AST patches by nodeId and re-checks
edict_errorsReturns machine-readable catalog of all error types
edict_lintRuns non-blocking quality analysis and returns warnings
edict_debugExecution tracing and crash diagnostics
edict_composeCombines composable program fragments into a module
edict_explainExplains AST nodes, errors, or compiler behavior
edict_exportPackages a program as a UASF portable skill
edict_import_skillImports and executes a UASF skill package
edict_generate_testsGenerates tests from Z3-verified contracts
edict_replayRecords and replays deterministic execution traces
edict_deployCompiles and deploys an Edict program to edge runtimes (Cloudflare Workers)
edict_invokeInvokes a deployed Edict WASM service via HTTP
edict_invoke_skillInvokes a UASF skill package directly
edict_packagePackages a compiled program as a deployable skill bundle
edict_supportReturns diagnostics and environment info for troubleshooting

MCP Resources

URIDescription
edict://schemaThe full AST JSON Schema
edict://schema/minimalMinimal schema variant for token-efficient bootstrap
edict://examplesAll example programs
edict://errorsMachine-readable error catalog
edict://schema/patchJSON Schema for the AST patch protocol
edict://guideAgent bootstrap guide for MCP-first onboarding
edict://supportDiagnostics and environment info

Example Program

A "Hello, World!" in Edict's JSON AST:

json
{  "kind": "module",  "id": "mod-hello-001",  "name": "hello",  "imports": [],  "definitions": [    {      "kind": "fn",      "id": "fn-main-001",      "name": "main",      "params": [],      "effects": ["io"],      "returnType": { "kind": "basic", "name": "Int" },      "contracts": [],      "body": [        {          "kind": "call",          "id": "call-print-001",          "fn": { "kind": "ident", "id": "ident-print-001", "name": "print" },          "args": [            { "kind": "literal", "id": "lit-msg-001", "value": "Hello, World!" }          ]        },        { "kind": "literal", "id": "lit-ret-001", "value": 0 }      ]    }  ]}

The Agent Loop

The core design: an agent submits an AST → the compiler validates it → if wrong, returns a StructuredError with enough context for the agent to self-repair → the agent fixes it → resubmits.

typescript
// 1. Agent reads the schema to learn the AST formatconst schema = edict_schema();
// 2. Agent writes a program (may contain errors)const program = agentWritesProgram(schema);
// 3. Compile — returns structured errors or WASMconst result = edict_compile(program);
if (!result.ok) {  // 4. Agent reads errors and fixes the program  //    Errors include: nodeId, expected type, candidates, counterexamples  const fixed = agentFixesProgram(program, result.errors);  // 5. Resubmit  return edict_compile(fixed);}
// 6. Run the WASMconst output = edict_run(result.wasm);

Architecture

src/├── ast/           # TypeScript interfaces for every AST node├── validator/     # Schema validation (structural correctness)├── resolver/      # Name resolution (scope-aware, with Levenshtein suggestions)├── checker/       # Type checking (bidirectional, with unit types)├── effects/       # Effect checking (call-graph propagation)├── contracts/     # Contract verification (Z3/SMT integration)├── codegen/       # WASM code generation (pure-JS encoder)│   ├── codegen.ts       # IR → WASM module orchestration│   ├── compile-ir-expr.ts  # IR expression compilation│   ├── compile-ir-*.ts  # Specialized IR compilers (calls, data, match, scalars)│   ├── runner.ts        # WASM execution (Node.js WebAssembly API)│   ├── host-adapter.ts  # EdictHostAdapter interface + platform adapters│   ├── closures.ts      # Closure capture and compilation│   ├── hof-generators.ts # Higher-order function WASM generators│   ├── wasm-encoder.ts  # Pure-JS WASM binary encoder (replaced binaryen)│   ├── wasm-interpreter.ts # Pure-JS WASM interpreter (no WebAssembly API needed)│   ├── recording-adapter.ts # Execution recording for replay│   ├── replay-adapter.ts  # Deterministic replay from recorded traces│   └── string-table.ts  # String interning for WASM memory├── ir/            # Mid-level IR (lowering, optimization)├── builtins/      # Builtin registry and domain-specific builtins├── compact/       # Compact AST format (token-efficient for agents)├── compose/       # Composable program fragments├── deploy/        # Edge deployment scaffolding (Cloudflare Workers)├── incremental/   # Incremental checking (dependency graph + diff)├── lint/          # Non-blocking quality warnings├── patch/         # Surgical AST patching by nodeId├── migration/     # Schema version migration (auto-upgrade older ASTs)├── skills/        # Skill packaging and invocation├── mcp/           # MCP server (tools + resources + prompts)└── errors/        # Structured error types
tests/             # 2675 tests across 136 filesexamples/          # 41 example programs (⭐→⭐⭐⭐ difficulty in README)schema/            # Auto-generated JSON Schema

Type System

TypeExample
BasicInt, Int64, Float, String, Bool
ArrayArray<Int>
OptionOption<String>
ResultResult<String, String>
RecordPoint { x: Float, y: Float }
EnumShape = Circle { radius: Float } | Rectangle { w: Float, h: Float }
Refinement{ i: Int | i > 0 } — predicates verified by Z3
Function(Int, Int) -> Int

Effect System

Functions declare their effects. The compiler enforces:

  • A pure function cannot call an io function
  • Effects propagate through the call graph
  • Missing effects are detected and reported

Effects: pure, reads, writes, io, fails

Contract Verification

Pre/post conditions are verified at compile time using Z3:

json
{  "kind": "post",  "id": "post-001",  "condition": {    "kind": "binop", "id": "binop-001", "op": ">",    "left": { "kind": "ident", "id": "ident-result-001", "name": "result" },    "right": { "kind": "ident", "id": "ident-x-001", "name": "x" }  }}

Z3 either proves unsat (contract holds ✅) or returns sat with a concrete counterexample the agent can reason about.

Contributing

We welcome contributions from agents and humans alike. See CONTRIBUTING.md for setup instructions, coding standards, and the PR workflow.

Looking for a place to start? Check issues labeled good first issue.

Roadmap

See ROADMAP.md for the full development plan, FEATURE_SPEC.md for the language specification, and Crystallized Intelligence for how agents store and reuse verified WASM skills.

Support

Edict is free and open source under the MIT license. If your agents find it valuable, consider sponsoring its development.

License

MIT

來源:README.md,提交 5b021ed

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v1.9.2最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分