@plurnk/plurnk-schemes 1.3.11 → 1.4.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 +25 -14
  2. package/SPEC.md +311 -75
  3. package/dist/DefaultRead.d.ts +8 -4
  4. package/dist/DefaultRead.d.ts.map +1 -1
  5. package/dist/DefaultRead.js +37 -13
  6. package/dist/DefaultRead.js.map +1 -1
  7. package/dist/Manifest.d.ts +6 -0
  8. package/dist/Manifest.d.ts.map +1 -0
  9. package/dist/Manifest.js +115 -0
  10. package/dist/Manifest.js.map +1 -0
  11. package/dist/Matcher.d.ts +5 -6
  12. package/dist/Matcher.d.ts.map +1 -1
  13. package/dist/Matcher.js +51 -59
  14. package/dist/Matcher.js.map +1 -1
  15. package/dist/MimetypeClassifier.d.ts +1 -1
  16. package/dist/MimetypeClassifier.d.ts.map +1 -1
  17. package/dist/MimetypeClassifier.js +11 -15
  18. package/dist/MimetypeClassifier.js.map +1 -1
  19. package/dist/NetworkAddress.d.ts +13 -0
  20. package/dist/NetworkAddress.d.ts.map +1 -0
  21. package/dist/NetworkAddress.js +43 -0
  22. package/dist/NetworkAddress.js.map +1 -0
  23. package/dist/OutputScheme.d.ts.map +1 -1
  24. package/dist/OutputScheme.js +5 -6
  25. package/dist/OutputScheme.js.map +1 -1
  26. package/dist/PacketSections.d.ts +6 -0
  27. package/dist/PacketSections.d.ts.map +1 -0
  28. package/dist/PacketSections.js +42 -0
  29. package/dist/PacketSections.js.map +1 -0
  30. package/dist/PathMimetype.js +9 -9
  31. package/dist/PathMimetype.js.map +1 -1
  32. package/dist/Results.d.ts +29 -8
  33. package/dist/Results.d.ts.map +1 -1
  34. package/dist/Results.js +102 -44
  35. package/dist/Results.js.map +1 -1
  36. package/dist/SchemeDiscovery.d.ts +2 -0
  37. package/dist/SchemeDiscovery.d.ts.map +1 -1
  38. package/dist/SchemeDiscovery.js +40 -42
  39. package/dist/SchemeDiscovery.js.map +1 -1
  40. package/dist/SchemeResolver.d.ts.map +1 -1
  41. package/dist/SchemeResolver.js +4 -5
  42. package/dist/SchemeResolver.js.map +1 -1
  43. package/dist/Slicer.d.ts +36 -14
  44. package/dist/Slicer.d.ts.map +1 -1
  45. package/dist/Slicer.js +330 -362
  46. package/dist/Slicer.js.map +1 -1
  47. package/dist/Summarize.js +3 -3
  48. package/dist/Summarize.js.map +1 -1
  49. package/dist/ctx.d.ts +60 -60
  50. package/dist/ctx.d.ts.map +1 -1
  51. package/dist/edit-receipt.d.ts +39 -0
  52. package/dist/edit-receipt.d.ts.map +1 -0
  53. package/dist/edit-receipt.js +2 -0
  54. package/dist/edit-receipt.js.map +1 -0
  55. package/dist/handler.d.ts +7 -8
  56. package/dist/handler.d.ts.map +1 -1
  57. package/dist/handler.js +4 -2
  58. package/dist/handler.js.map +1 -1
  59. package/dist/index.d.ts +13 -5
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +6 -0
  62. package/dist/index.js.map +1 -1
  63. package/dist/packet.d.ts +2 -3
  64. package/dist/packet.d.ts.map +1 -1
  65. package/dist/packet.js +2 -20
  66. package/dist/packet.js.map +1 -1
  67. package/dist/types.d.ts +3 -11
  68. package/dist/types.d.ts.map +1 -1
  69. package/dist/types.js +1 -7
  70. package/dist/types.js.map +1 -1
  71. package/package.json +10 -8
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
 
@@ -37,7 +37,18 @@ export default class Foo implements SchemeHandler {
37
37
  }
38
38
  ```
39
39
 
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.
40
+ Implement only the delegated methods you support - `read`, `find`, `editBatch`,
41
+ `send`, and the other optional methods in `SchemeHandler`. COPY and MOVE are
42
+ engine-owned compositions over `ctx.entries` and `editBatch`, so plugins do not
43
+ override them or author COPY/MOVE effect envelopes. A regional `editBatch`
44
+ returns `EditBatchResult` with its typed `EditBatchReceipt`; the engine validates
45
+ and projects it.
46
+ The optional synchronous `attributions(context)` hook may return no, one, or
47
+ many opaque tags for each provider emission attempt ({§plugin-attribution}).
48
+ `implements SchemeHandler` gives compile-time signature checking. The statement
49
+ and path types (`ReadStatement`, `SendStatement`, `UrlPath`, etc.) are re-exported
50
+ from this package, so you depend on and peer (`^1`) only
51
+ `@plurnk/plurnk-schemes`; grammar rides underneath.
41
52
 
42
53
  ### 3. Declare the manifest — including self-doc
43
54
 
@@ -52,11 +63,10 @@ static manifest: SchemeManifest = {
52
63
  channels: { body: "text/markdown" },
53
64
  defaultChannel: "body",
54
65
  category: "data",
55
- scope: "workspace",
56
66
  writableBy: ["model", "client"],
57
67
  volatile: false,
58
68
  modelVisible: true,
59
- glyph: "🦊", // display icon; omit → the name is shown
69
+ glyph: "🦊", // optional client-only display marker
60
70
  example: "READ(foo://thing/42)", // terse hot-path one-liner, rendered every turn
61
71
  documentation, // deep doc from docs/foo.md, pulled at worker://plurnk/docs/foo.md
62
72
  };
@@ -64,11 +74,11 @@ static manifest: SchemeManifest = {
64
74
 
65
75
  - **`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
76
  - **`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.
77
+ - **`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
78
 
69
79
  ### 4. Self-doc: terse pushes, depth pulls
70
80
 
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`.
81
+ `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
82
 
73
83
  That's the whole contract: declare, `implements SchemeHandler`, manifest with self-doc. Publish, install, discovered.
74
84
 
@@ -76,20 +86,21 @@ That's the whole contract: declare, `implements SchemeHandler`, manifest with se
76
86
 
77
87
  ### Types
78
88
 
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`.
89
+ - Manifest/flags: `SchemeManifest` (including `example` / `documentation` self-doc and client-only `glyph`), `SchemeFlagAffinity`, and `WriterTier`; contracts-owned `LoopFlags` / `DEFAULT_LOOP_FLAGS` are re-exported.
90
+ - Behavior contract: `SchemeHandler` + optional `PacketSectionTransformer` (`PacketSectionDraft`); the re-exported scheme-facing grammar types (`PlurnkStatement` + per-op statements + `ParsedPath` / `LocalPath` / `UrlPath`).
91
+ - Results: universal `SchemeResult` plus RFC 9457 `ProblemDetails`, optional `EntryResult` / `ProposalResult` / `PassthroughResult` authoring shapes, `SchemeResultBase`, and matcher navigation `MatchEvidence`.
82
92
  - 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
93
 
84
94
  ### Helpers (`export default class`, static methods)
85
95
 
86
96
  - `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.
97
+ - `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.
98
+ - `Slicer.lines` / `.linesRaw` / `.textReplacement` / `.lineMarkerEdit` / `.lineMarkerEditBatch` - universal text-region projection and same-snapshot replacement; `Slicer.page` handles ordered results separately.
89
99
  - `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).
100
+ - `Matcher.matchAgainstContent(body, content, mimetype, mimetypes)` - boolean resource selection over `Mimetypes.query` (glob/regex/jsonpath/xpath), returning locator/exact-region `MatchEvidence`.
101
+ - `Results.problem` / `.failure` / `.assert` / `.assertReadResult` / `.assertMatchEvidenceList` / `.attachInstance` / `.isEntry` / `.isProposal` / `.isPassthrough` / `.isErrorStatus` - RFC 9457 result builders, validators, durable-occurrence attachment, and guards.
102
+ - `PacketSections.assertDrafts(value, subject?)` — validates the exact tokenless section-draft list returned by a packet transformer.
103
+ - `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
104
 
94
105
  `SchemeCtx` is the stable semantic API for trusted in-process schemes, not a
95
106
  sandbox. The consumer injects its implementation; database layout and private