@plurnk/plurnk-schemes 0.29.3 → 0.29.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/SPEC.md +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,6 +42,11 @@ Implement only the op methods you support — `read` / `find` / `edit` / `copy`
|
|
|
42
42
|
### 3. Declare the manifest — including self-doc
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
+
import { readFile } from "node:fs/promises";
|
|
46
|
+
|
|
47
|
+
// Deep doc lives in docs/foo.md (convention); loaded at module init.
|
|
48
|
+
const documentation = await readFile(new URL("../docs/foo.md", import.meta.url), "utf-8");
|
|
49
|
+
|
|
45
50
|
static manifest: SchemeManifest = {
|
|
46
51
|
name: "foo",
|
|
47
52
|
channels: { body: "text/markdown" },
|
|
@@ -53,12 +58,12 @@ static manifest: SchemeManifest = {
|
|
|
53
58
|
modelVisible: true,
|
|
54
59
|
glyph: "🦊", // display icon; omit → the name is shown
|
|
55
60
|
example: "READ(foo://thing/42)", // terse hot-path one-liner, rendered every turn
|
|
56
|
-
documentation
|
|
61
|
+
documentation, // deep doc from docs/foo.md, pulled at plurnk://docs/foo.md
|
|
57
62
|
};
|
|
58
63
|
```
|
|
59
64
|
|
|
60
65
|
- **`example`** — the scheme's terse **hot-path** one-liner, rendered in the live catalogue every turn (like an execs runtime's `example`). Keep it to one canonical usage line; depth goes in `documentation`. Omit → not advertised.
|
|
61
|
-
- **`documentation`** — the **deep doc** (ops, channels, edge cases). The consumer materializes it as a pull-able `plurnk://docs/<name>.md` entry the model READs on demand — off the hot path. Mirrors `ExecInfo.documentation`.
|
|
66
|
+
- **`documentation`** — the **deep doc** (ops, channels, edge cases). The consumer materializes it as a pull-able `plurnk://docs/<name>.md` entry the model READs on demand — off the hot path. Mirrors `ExecInfo.documentation`. **Convention:** keep it in a **`docs/<name>.md`** file (root) and load it at module init with the snippet above — `../` resolves the same from `src/` (test) and `dist/` (built); add `docs/**/*` to `files`. A missing file fails-hard at import.
|
|
62
67
|
- **`glyph`** — a display icon (emoji / nerdfont). Omit it and the scheme `name` is rendered in its place.
|
|
63
68
|
|
|
64
69
|
### 4. Self-doc: terse pushes, depth pulls
|
package/SPEC.md
CHANGED
|
@@ -50,6 +50,8 @@ class Known {
|
|
|
50
50
|
|
|
51
51
|
**Self-doc split (terse pushes, depth pulls).** `example` + `glyph` are the hot-path listing rendered every turn — keep them terse. `documentation` is the deep prose (every op, channel, status code, gotcha); the consumer materializes it as a pull-able **`plurnk://docs/<name>.md`** entry the model READs on demand, off the hot path. Both live on the manifest; the consumer decides what's pushed vs pulled.
|
|
52
52
|
|
|
53
|
+
**Authoring convention — `docs/<name>.md`.** The contract field stays a plain `string`, but a sibling SHOULD keep the deep doc in a **`docs/<name>.md`** file at the package root rather than inline, and load it into the manifest at module init — e.g. `documentation: await readFile(new URL("../docs/<name>.md", import.meta.url), "utf-8")` (top-level await; `../` resolves identically from `src/` in test and `dist/` once built). Ship it by adding `docs/**/*` to `files`. This keeps prose out of the handler source and gives editors real Markdown; the contract and the consumer's `plurnk://docs/<name>.md` materialization are unchanged. A missing file fails-hard at import (no silent empty doc).
|
|
54
|
+
|
|
53
55
|
## §2 Interface
|
|
54
56
|
|
|
55
57
|
Sister scheme handlers implement op methods consumed by plurnk-service via dispatch: the engine calls `handler[statement.op.toLowerCase()](statement, ctx)` and returns **501** for any op whose method is absent. The op-dispatch surface is the exported **`SchemeHandler`** interface — every method optional, each `(statement, ctx) => Promise<SchemeResult>`, the per-op statement type from grammar:
|