@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.
Files changed (71) hide show
  1. package/README.md +43 -17
  2. package/SPEC.md +368 -86
  3. package/dist/Manifest.d.ts +6 -0
  4. package/dist/Manifest.d.ts.map +1 -0
  5. package/dist/Manifest.js +115 -0
  6. package/dist/Manifest.js.map +1 -0
  7. package/dist/Matcher.d.ts +5 -6
  8. package/dist/Matcher.d.ts.map +1 -1
  9. package/dist/Matcher.js +51 -59
  10. package/dist/Matcher.js.map +1 -1
  11. package/dist/MimetypeClassifier.d.ts +1 -1
  12. package/dist/MimetypeClassifier.d.ts.map +1 -1
  13. package/dist/MimetypeClassifier.js +11 -15
  14. package/dist/MimetypeClassifier.js.map +1 -1
  15. package/dist/NetworkAddress.d.ts +13 -0
  16. package/dist/NetworkAddress.d.ts.map +1 -0
  17. package/dist/NetworkAddress.js +43 -0
  18. package/dist/NetworkAddress.js.map +1 -0
  19. package/dist/OutputScheme.d.ts.map +1 -1
  20. package/dist/OutputScheme.js +5 -6
  21. package/dist/OutputScheme.js.map +1 -1
  22. package/dist/PacketSections.d.ts +6 -0
  23. package/dist/PacketSections.d.ts.map +1 -0
  24. package/dist/PacketSections.js +42 -0
  25. package/dist/PacketSections.js.map +1 -0
  26. package/dist/PathMimetype.js +9 -9
  27. package/dist/PathMimetype.js.map +1 -1
  28. package/dist/Results.d.ts +42 -8
  29. package/dist/Results.d.ts.map +1 -1
  30. package/dist/Results.js +132 -44
  31. package/dist/Results.js.map +1 -1
  32. package/dist/SchemeDiscovery.d.ts +2 -0
  33. package/dist/SchemeDiscovery.d.ts.map +1 -1
  34. package/dist/SchemeDiscovery.js +40 -42
  35. package/dist/SchemeDiscovery.js.map +1 -1
  36. package/dist/SchemeResolver.d.ts.map +1 -1
  37. package/dist/SchemeResolver.js +4 -5
  38. package/dist/SchemeResolver.js.map +1 -1
  39. package/dist/Slicer.d.ts +27 -14
  40. package/dist/Slicer.d.ts.map +1 -1
  41. package/dist/Slicer.js +382 -374
  42. package/dist/Slicer.js.map +1 -1
  43. package/dist/Summarize.js +3 -3
  44. package/dist/Summarize.js.map +1 -1
  45. package/dist/ctx.d.ts +70 -67
  46. package/dist/ctx.d.ts.map +1 -1
  47. package/dist/edit-receipt.d.ts +39 -0
  48. package/dist/edit-receipt.d.ts.map +1 -0
  49. package/dist/edit-receipt.js +2 -0
  50. package/dist/edit-receipt.js.map +1 -0
  51. package/dist/handler.d.ts +13 -10
  52. package/dist/handler.d.ts.map +1 -1
  53. package/dist/handler.js +7 -5
  54. package/dist/handler.js.map +1 -1
  55. package/dist/index.d.ts +14 -8
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +6 -1
  58. package/dist/index.js.map +1 -1
  59. package/dist/packet.d.ts +2 -3
  60. package/dist/packet.d.ts.map +1 -1
  61. package/dist/packet.js +2 -20
  62. package/dist/packet.js.map +1 -1
  63. package/dist/types.d.ts +3 -11
  64. package/dist/types.d.ts.map +1 -1
  65. package/dist/types.js +1 -7
  66. package/dist/types.js.map +1 -1
  67. package/package.json +10 -8
  68. package/dist/DefaultRead.d.ts +0 -11
  69. package/dist/DefaultRead.d.ts.map +0 -1
  70. package/dist/DefaultRead.js +0 -27
  71. 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-grammar](https://github.com/plurnk/plurnk-grammar), [plurnk-mimetypes](https://github.com/plurnk/plurnk-mimetypes), [plurnk-providers](https://github.com/plurnk/plurnk-providers), [plurnk-execs](https://github.com/plurnk/plurnk-execs).
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
- SchemeHandler, SchemeManifest, SchemeCtx, SchemeResult, ReadStatement,
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 read(statement: ReadStatement, ctx: SchemeCtx): Promise<SchemeResult> {
35
- /* … use ctx's stable domain capabilities (SPEC §3.bis) … */
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
- Implement only the op methods you support — `read` / `find` / `edit` / `copy` / `move` / `send` / … — all optional; the engine calls `handler[op.toLowerCase()](statement, ctx)` and returns **501** for any op you omit. `implements SchemeHandler` gives you compile-time signature checking. The statement + path types (`ReadStatement`, `SendStatement`, `UrlPath`, …) are **re-exported from this package**, so you depend on and peer (`^1`) **only `@plurnk/plurnk-schemes`** — grammar rides underneath.
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: "🦊", // display icon; omit → the name is shown
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`** — a display icon (emoji / nerdfont). Omit it and the scheme `name` is rendered in its place.
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`/`glyph` render every turn — keep them 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`.
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` (incl. `example` / `documentation` / `glyph` self-doc), `SchemeFlagAffinity`, `WriterTier`, `LoopFlags`, `DEFAULT_LOOP_FLAGS`.
80
- - Behavior contract: `SchemeHandler` + optional `PacketSectionTransformer` (`PacketSection`); the re-exported scheme-facing grammar types (`PlurnkStatement` + per-op statements + `ParsedPath` / `LocalPath` / `UrlPath`).
81
- - Results: universal `SchemeResult` plus optional `EntryResult` / `ProposalResult` / `PassthroughResult` authoring shapes, `SchemeResultBase`, and `TelemetryEvent`.
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` / `.isLineNavigable` / `.isJson` / `.normalizeAutoText` (+ `TEXT_PRIMITIVE_MIMETYPE` named export) — mimetype classification.
88
- - `Slicer.lines` / `.linesRaw` / `.jsonItems` / `.lineMarkerEdit` / `.jsonItemEdit` — `<L>` slicing + structural EDIT.
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, baseLine?)` — body-matcher dispatch over `Mimetypes.query` (glob/regex/jsonpath/xpath).
91
- - `Results.error` / `.logCoordinate` / `.isEntry` / `.isProposal` / `.isPassthrough` / `.isErrorStatus` — result builders + guards.
92
- - `SchemeDiscovery.discover({ cwd? })` — scope-agnostic `node_modules` scan for `plurnk.kind:"scheme"` packages (trust-gated, fail-hard on prefix collision); returns descriptors for the consumer to register (SPEC §6).
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