@plurnk/plurnk-schemes 1.3.12 → 1.5.0
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 +43 -17
- package/SPEC.md +368 -86
- package/dist/Manifest.d.ts +6 -0
- package/dist/Manifest.d.ts.map +1 -0
- package/dist/Manifest.js +115 -0
- package/dist/Manifest.js.map +1 -0
- package/dist/Matcher.d.ts +5 -6
- package/dist/Matcher.d.ts.map +1 -1
- package/dist/Matcher.js +51 -59
- package/dist/Matcher.js.map +1 -1
- package/dist/MimetypeClassifier.d.ts +1 -1
- package/dist/MimetypeClassifier.d.ts.map +1 -1
- package/dist/MimetypeClassifier.js +11 -15
- package/dist/MimetypeClassifier.js.map +1 -1
- package/dist/NetworkAddress.d.ts +13 -0
- package/dist/NetworkAddress.d.ts.map +1 -0
- package/dist/NetworkAddress.js +43 -0
- package/dist/NetworkAddress.js.map +1 -0
- package/dist/OutputScheme.d.ts.map +1 -1
- package/dist/OutputScheme.js +5 -6
- package/dist/OutputScheme.js.map +1 -1
- package/dist/PacketSections.d.ts +6 -0
- package/dist/PacketSections.d.ts.map +1 -0
- package/dist/PacketSections.js +42 -0
- package/dist/PacketSections.js.map +1 -0
- package/dist/PathMimetype.js +9 -9
- package/dist/PathMimetype.js.map +1 -1
- package/dist/Results.d.ts +42 -8
- package/dist/Results.d.ts.map +1 -1
- package/dist/Results.js +132 -44
- package/dist/Results.js.map +1 -1
- package/dist/SchemeDiscovery.d.ts +2 -0
- package/dist/SchemeDiscovery.d.ts.map +1 -1
- package/dist/SchemeDiscovery.js +40 -42
- package/dist/SchemeDiscovery.js.map +1 -1
- package/dist/SchemeResolver.d.ts.map +1 -1
- package/dist/SchemeResolver.js +4 -5
- package/dist/SchemeResolver.js.map +1 -1
- package/dist/Slicer.d.ts +27 -14
- package/dist/Slicer.d.ts.map +1 -1
- package/dist/Slicer.js +382 -374
- package/dist/Slicer.js.map +1 -1
- package/dist/Summarize.js +3 -3
- package/dist/Summarize.js.map +1 -1
- package/dist/ctx.d.ts +70 -67
- package/dist/ctx.d.ts.map +1 -1
- package/dist/edit-receipt.d.ts +39 -0
- package/dist/edit-receipt.d.ts.map +1 -0
- package/dist/edit-receipt.js +2 -0
- package/dist/edit-receipt.js.map +1 -0
- package/dist/handler.d.ts +13 -10
- package/dist/handler.d.ts.map +1 -1
- package/dist/handler.js +7 -5
- package/dist/handler.js.map +1 -1
- package/dist/index.d.ts +14 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/packet.d.ts +2 -3
- package/dist/packet.d.ts.map +1 -1
- package/dist/packet.js +2 -20
- package/dist/packet.js.map +1 -1
- package/dist/types.d.ts +3 -11
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -7
- package/dist/types.js.map +1 -1
- package/package.json +10 -8
- package/dist/DefaultRead.d.ts +0 -11
- package/dist/DefaultRead.d.ts.map +0 -1
- package/dist/DefaultRead.js +0 -27
- package/dist/DefaultRead.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Framework + contract for `@plurnk/plurnk-schemes-*` URI handler packages. Consum
|
|
|
5
5
|
## Documentation
|
|
6
6
|
|
|
7
7
|
- [`SPEC.md`](./SPEC.md) — author-facing contract.
|
|
8
|
-
- Constellation: [plurnk-
|
|
8
|
+
- Constellation: [plurnk-contracts](https://github.com/plurnk/plurnk-service/tree/main/plurnk-contracts), [plurnk-mimetypes](https://github.com/plurnk/plurnk-service/tree/main/plurnk-mimetypes), [plurnk-providers](https://github.com/plurnk/plurnk-service/tree/main/plurnk-providers), [plurnk-execs](https://github.com/plurnk/plurnk-service/tree/main/plurnk-execs).
|
|
9
9
|
|
|
10
10
|
## Write a scheme
|
|
11
11
|
|
|
@@ -25,19 +25,45 @@ Ship a scheme by publishing a package — **under any scope** (`@acme/whatever`;
|
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
27
|
import type {
|
|
28
|
-
|
|
28
|
+
RepresentationPreparationRequest, RepresentationPreparationResult,
|
|
29
|
+
SchemeHandler, SchemeManifest, SchemeCtx,
|
|
29
30
|
} from "@plurnk/plurnk-schemes";
|
|
30
31
|
|
|
31
32
|
export default class Foo implements SchemeHandler {
|
|
32
33
|
static manifest: SchemeManifest = { /* step 3 */ };
|
|
33
34
|
|
|
34
|
-
async
|
|
35
|
-
|
|
35
|
+
async prepareRepresentation(
|
|
36
|
+
{ target, pathname }: RepresentationPreparationRequest,
|
|
37
|
+
ctx: SchemeCtx,
|
|
38
|
+
): Promise<RepresentationPreparationResult> {
|
|
39
|
+
const { content, mimetype } = await acquire(target);
|
|
40
|
+
const written = await ctx.entries.write(pathname, {
|
|
41
|
+
channels: { body: { content, mimetype } },
|
|
42
|
+
tags: [],
|
|
43
|
+
});
|
|
44
|
+
return written.status >= 400 ? written : { status: 200 };
|
|
36
45
|
}
|
|
37
46
|
}
|
|
38
47
|
```
|
|
39
48
|
|
|
40
|
-
|
|
49
|
+
Core owns READ. A stored scheme needs no READ method; an acquisition scheme
|
|
50
|
+
implements scope-blind `prepareRepresentation`, writes its complete channels,
|
|
51
|
+
and lets core select the channel and apply operation-owned semantics. Exact
|
|
52
|
+
READ, exact FIND, and COPY/MOVE source selection all reuse that acquisition;
|
|
53
|
+
the producer receives none of their scopes, matchers, or channel choices.
|
|
54
|
+
Implement only
|
|
55
|
+
the remaining delegated methods you support—`find`, `editBatch`, `send`, and
|
|
56
|
+
the other optional methods in `SchemeHandler`. COPY and MOVE are engine-owned
|
|
57
|
+
compositions over `ctx.entries` and `editBatch`, so plugins do not override
|
|
58
|
+
them or author COPY/MOVE effect envelopes. A regional `editBatch`
|
|
59
|
+
returns `EditBatchResult` with its typed `EditBatchReceipt`; the engine validates
|
|
60
|
+
and projects it.
|
|
61
|
+
The optional synchronous `attributions(context)` hook may return no, one, or
|
|
62
|
+
many opaque tags for each provider emission attempt ({§plugin-attribution}).
|
|
63
|
+
`implements SchemeHandler` gives compile-time signature checking. The statement
|
|
64
|
+
and path types (`FindStatement`, `SendStatement`, `UrlPath`, etc.) are re-exported
|
|
65
|
+
from this package, so you depend on and peer (`^1`) only
|
|
66
|
+
`@plurnk/plurnk-schemes`; grammar rides underneath.
|
|
41
67
|
|
|
42
68
|
### 3. Declare the manifest — including self-doc
|
|
43
69
|
|
|
@@ -52,11 +78,10 @@ static manifest: SchemeManifest = {
|
|
|
52
78
|
channels: { body: "text/markdown" },
|
|
53
79
|
defaultChannel: "body",
|
|
54
80
|
category: "data",
|
|
55
|
-
scope: "workspace",
|
|
56
81
|
writableBy: ["model", "client"],
|
|
57
82
|
volatile: false,
|
|
58
83
|
modelVisible: true,
|
|
59
|
-
glyph: "🦊", //
|
|
84
|
+
glyph: "🦊", // optional client-only display marker
|
|
60
85
|
example: "READ(foo://thing/42)", // terse hot-path one-liner, rendered every turn
|
|
61
86
|
documentation, // deep doc from docs/foo.md, pulled at worker://plurnk/docs/foo.md
|
|
62
87
|
};
|
|
@@ -64,11 +89,11 @@ static manifest: SchemeManifest = {
|
|
|
64
89
|
|
|
65
90
|
- **`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.
|
|
66
91
|
- **`documentation`** — the **deep doc** (ops, channels, edge cases). The consumer materializes it as a pull-able `worker://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.
|
|
67
|
-
- **`glyph`** —
|
|
92
|
+
- **`glyph`** — optional opaque client display metadata. It is discoverable through the client capability wire and never rendered into model teaching; clients choose fallback, fonts, and theme.
|
|
68
93
|
|
|
69
94
|
### 4. Self-doc: terse pushes, depth pulls
|
|
70
95
|
|
|
71
|
-
`example
|
|
96
|
+
`example` renders every turn — keep it terse. `documentation` is the deep prose; the consumer materializes it at `worker://plurnk/docs/<name>.md` for the model to READ on demand. Don't dump prose into `example` (it floods the hot path) — put it in `documentation`.
|
|
72
97
|
|
|
73
98
|
That's the whole contract: declare, `implements SchemeHandler`, manifest with self-doc. Publish, install, discovered.
|
|
74
99
|
|
|
@@ -76,20 +101,21 @@ That's the whole contract: declare, `implements SchemeHandler`, manifest with se
|
|
|
76
101
|
|
|
77
102
|
### Types
|
|
78
103
|
|
|
79
|
-
- Manifest/flags: `SchemeManifest` (
|
|
80
|
-
- Behavior contract: `SchemeHandler` + optional `PacketSectionTransformer` (`
|
|
81
|
-
- Results: universal `SchemeResult` plus optional `EntryResult` / `ProposalResult` / `PassthroughResult` authoring shapes, `SchemeResultBase`, and `
|
|
104
|
+
- Manifest/flags: `SchemeManifest` (including `example` / `documentation` self-doc and client-only `glyph`), `SchemeFlagAffinity`, and `WriterTier`; contracts-owned `LoopFlags` / `DEFAULT_LOOP_FLAGS` are re-exported.
|
|
105
|
+
- Behavior contract: `SchemeHandler` + optional `PacketSectionTransformer` (`PacketSectionDraft`); the re-exported scheme-facing grammar types (`PlurnkStatement` + per-op statements + `ParsedPath` / `LocalPath` / `UrlPath`).
|
|
106
|
+
- Results: universal `SchemeResult` plus RFC 9457 `ProblemDetails`, optional `EntryResult` / `ProposalResult` / `PassthroughResult` authoring shapes, `SchemeResultBase`, matcher navigation `MatchEvidence`, and target-shaped standard `EntryFindResult` pagination/count metadata.
|
|
82
107
|
- Capability ctx: `SchemeCtx` and its entry, channel, tag, notification, projection, and subscription domains. Entry schemes can reuse typed standard operations with semantic commons/worker ownership.
|
|
83
108
|
|
|
84
109
|
### Helpers (`export default class`, static methods)
|
|
85
110
|
|
|
86
111
|
- `SchemeResolver.forLoop(handlers, flags)` — active-scheme resolution under loop flags.
|
|
87
|
-
- `MimetypeClassifier.isBinary` / `.
|
|
88
|
-
- `Slicer.lines` / `.linesRaw` / `.
|
|
112
|
+
- `MimetypeClassifier.isBinary` / `.isJson` / `.normalizeAutoText` (+ `TEXT_PRIMITIVE_MIMETYPE` named export) - registry-free mimetype taxonomy and scheme-local helpers. Configured consumers use `Mimetypes.classify()` for handler-aware binary decisions.
|
|
113
|
+
- `Slicer.lines` / `.linesRaw` / `.textReplacement` / `.lineMarkerEdit` / `.lineMarkerEditBatch` - universal text-region projection and same-snapshot replacement; `Slicer.page` handles ordered results, and `.coversAvailable` derives complete coverage from their compact `RangeExtent`.
|
|
89
114
|
- `PathMimetype.resolve(pathname, default, mimetypes)` — path-extension mimetype resolver.
|
|
90
|
-
- `Matcher.matchAgainstContent(body, content, mimetype, mimetypes
|
|
91
|
-
- `Results.
|
|
92
|
-
- `
|
|
115
|
+
- `Matcher.matchAgainstContent(body, content, mimetype, mimetypes)` - boolean resource selection over `Mimetypes.query` (glob/regex/jsonpath/xpath), returning locator/exact-region `MatchEvidence`.
|
|
116
|
+
- `Results.problem` / `.failure` / `.assert` / `.assertReadResult` / `.assertMatchEvidenceList` / `.attachInstance` / `.isEntry` / `.isProposal` / `.isPassthrough` / `.isErrorStatus` - RFC 9457 result builders, validators, durable-occurrence attachment, and guards.
|
|
117
|
+
- `PacketSections.assertDrafts(value, subject?)` — validates the exact tokenless section-draft list returned by a packet transformer.
|
|
118
|
+
- `SchemeDiscovery.discover({ cwd? })` — scope-agnostic `node_modules` scan for `plurnk.kind:"scheme"` packages (trust-gated, fail-hard on prefix collision); returns descriptors plus canonical static attribution lists for represented packages (SPEC §6, {§plugin-attribution}).
|
|
93
119
|
|
|
94
120
|
`SchemeCtx` is the stable semantic API for trusted in-process schemes, not a
|
|
95
121
|
sandbox. The consumer injects its implementation; database layout and private
|