@plurnk/plurnk-schemes 3.3.5 → 3.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 CHANGED
@@ -48,7 +48,7 @@ export default class Foo implements SchemeHandler {
48
48
 
49
49
  | Owner | Responsibilities |
50
50
  | --- | --- |
51
- | **Core** | Owns `plurnk.read`, `plurnk.copy`, and `plurnk.move` channel selection, slicing, anchors, and effect composition over `ctx.entries` and `editBatch`. Passes canonical `authority`-bound `SchemeCtx` without scopes or matchers. |
51
+ | **Core** | Owns `read`, `copy`, and `move` channel selection, slicing, anchors, and effect composition over `ctx.entries` and `editBatch`. Passes canonical `authority`-bound `SchemeCtx` without scopes or matchers. |
52
52
  | **Handler** | Implements scope-blind `prepareRepresentation` (for acquisition schemes) and optional `find`, `editBatch` (returning `EditBatchResult` / `EditBatchReceipt`), `send`, and synchronous `attributions(context)` ({§extension-discovery}). |
53
53
 
54
54
  - Grammar and path types (`FindStatement`, `SendStatement`, `UrlPath`, etc.) re-export from `@plurnk/plurnk-schemes` (`peerDependencies: "^3.0.0"`).
@@ -99,7 +99,7 @@ That's the whole contract: declare, `implements SchemeHandler`, manifest with se
99
99
  ### Types
100
100
 
101
101
  - Manifest: `SchemeManifest` (including capability `traits`, `documentation`, and client-only `glyph`) and `WriterTier`.
102
- - Behavior contract: `SchemeHandler`, numeric-only `ResolvedEditStatement`, and optional `PacketSectionTransformer` (`PacketSectionDraft`); the remaining re-exported scheme-facing grammar types (`PlurnkStatement` + per-op statements + `ParsedPath` / `LocalPath` / `UrlPath`).
102
+ - Behavior contract: `SchemeHandler`, `SchemeHandlerConstructor`, numeric-only `ResolvedEditStatement`, and optional `PacketSectionTransformer` (`PacketSectionDraft`); the remaining re-exported scheme-facing grammar types (`PlurnkStatement` + per-op statements + `ParsedPath` / `LocalPath` / `UrlPath`).
103
103
  - 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.
104
104
  - Capability ctx: `SchemeCtx` and its entry, channel, notification, projection, and subscription domains. Entry schemes reuse typed standard operations at canonical workspace addresses.
105
105
 
package/SPEC.md CHANGED
@@ -19,7 +19,7 @@ Every scheme package declares `plurnk: { "kind": "scheme", "name": "<scheme>" }`
19
19
  | `folderScopes?` | `true` declares that a trailing slash on `FIND` is a collection scope; absent/`false` treats `/` as ordinary resource syntax. |
20
20
  | `lineAnchors?` | `true` publishes and accepts shared line anchors for stable textual representations without declaring `edit` support. |
21
21
  | `textEditScopes?` | `true` declares the shared textual `edit` coordinate and collision contract ({§line-anchors}). Handlers receive numeric coordinates only and route standard entry mutation through `ctx.entries.operations.editBatch`. |
22
- | `traits?` | Unique lowercase capability facts matching `^[a-z][a-z0-9-]*$` (e.g. `web`, `interaction`) consumed by {§capability-admission}. |
22
+ | `traits?` | Unique lowercase capability facts matching `^[a-z][a-z0-9-]*$` (e.g. `web`, `interaction`) consumed by session-owner interaction visibility ({§question-tool}). |
23
23
  | `documentation?` | Deep reference Markdown (loaded from `docs/<name>.md`) with an exact H2 `Summary`, materialized on demand at `plurnk:///<name>.md` (`find` projects H2 `Summary`; `read` retrieves the body). |
24
24
  | `glyph?` | Non-empty opaque client presentation glyph projected through {§mcp-server-definition}; never enters model teaching. |
25
25
  | `storedScheme?` | Non-null string persisted to `entries.scheme` when different from `name` (defaults to `name`). |
@@ -115,13 +115,13 @@ Additional framework helpers:
115
115
 
116
116
  | Scope | Meaning |
117
117
  |---|---|
118
- | `<N>` | Whole 1-based physical line, byte (`unit: "byte"`), or result item `N` |
119
- | `<N,M>` | Inclusive 1-based range `N..M` (`M = -1` selects through the end) |
120
- | `<SL,SC,EL,EC>` | Exact exclusive-end text region using 1-based Unicode code-point columns ({§text-region}) |
121
- | `<0>` / `<-1>` | Single-position mutation anchors before the first / after the final line (`start: null` on `window()`) |
118
+ | `"N"` | Whole 1-based physical line, byte (`unit: "byte"`), or result item `N` |
119
+ | `"N,M"` | Inclusive 1-based range `N..M` (`M = -1` selects through the end; on projection `lines()`, `window()`, and `page()`, negative coordinates `"-K,-M"` count backward from `total + 1`, clamping an oversized negative start to `1`) |
120
+ | `"SL,SC,EL,EC"` | Exact exclusive-end text region using 1-based Unicode code-point columns ({§text-region}) |
121
+ | `"0"` / `"-1"` | Single-position mutation anchors before the first / after the final line (`start: null` on `window()`) |
122
122
 
123
- - **One-based ranges (`range-starts-at-one`):** A two-coordinate range starts at `1`. `<0,M>` is refused `416 range-not-satisfiable` by `lines()`, `linesRaw()`, `textReplacement()`, `lineMarkerEdit[Batch]()`, `window()`, and `page()` (even on empty content/results) and never clamped to `<1,M>`. As a shared `READ` projection tolerance, `<0,M>` (for positive safe integer `M` or `-1`) selects `<1,M>`, retains `[0,M]` as requested, and emits scope-normalization evidence.
124
- - **3-coordinate lowering and end clamping:** `<startLine,startColumn,endLine>` lowers to `<startLine,startColumn,endLine,endCol>` with boundary-validated normalization evidence. Harmless end-bound overshoots clamp to EOF / final code point; start-bound overshoots and inverted ranges fail `416`.
123
+ - **One-based ranges (`range-starts-at-one`):** A two-coordinate range starts at `1`. `"0,M"` is refused `416 range-not-satisfiable` by `lines()`, `linesRaw()`, `textReplacement()`, `lineMarkerEdit[Batch]()`, `window()`, and `page()` (even on empty content/results) and never clamped to `"1,M"`. As a shared `READ` projection tolerance, `"0,M"` (for positive safe integer `M` or `-1`) selects `"1,M"`, retains `[0,M]` as requested, and emits scope-normalization evidence.
124
+ - **3-coordinate lowering and end clamping:** `"startLine,startColumn,endLine"` lowers to `"startLine,startColumn,endLine,endCol"` with boundary-validated normalization evidence. Harmless end-bound overshoots clamp to EOF / final code point; start-bound overshoots and inverted ranges fail `416`.
125
125
  - **`Slicer.wholeLineBody(content, marker, body)`:** Appends the content's line separator only for a non-empty body without a trailing newline at a zero-width column-1 region ({§zero-width-column-one-insert}).
126
126
  - **Batch edits (`lineMarkerEditBatch`):** Validates all replacements against one snapshot; resolves identical twins, co-located insertions, and evidenced 1-line shared endpoints (recorded in `merges`); rejects any other overlap with `409 overlapping-edits` (`conflicts`, `cleanRegions`, `conflictingRegions`, `editCount`, `applied: 0`) and applies all or none.
127
127
  - **Results and Matcher (`Results`, `Matcher`):** `Results.isErrorStatus(status)` is `status >= 400`; `Results.isEntry`, `isProposal`, and `isPassthrough` guard optional result shapes; `Results.assert`, `assertReadResult`, and `assertMatchEvidenceList` enforce RFC 9457 `ProblemDetails` on `400..599` and `{ locator?, region?, enclosingRegion?, matched? }` on matches. `Matcher.matchAgainstContent(body, content, mimetype, mimetypes, diagnostic?)` adapts `Mimetypes.query` (`200` matches, `204` empty, `400 invalid-expression` with bounded `diagnostic`, `415 unsupported-dialect`, `203` raw-text fallback with `reason`, {§matcher-dispatch}).
@@ -130,7 +130,7 @@ Additional framework helpers:
130
130
  |---|---:|---|
131
131
  | `range-not-satisfiable` | `416` | Range lies outside available extent (`Lines and columns count from 1.`, `An exact region names its earlier position first: "SL,SC,EL,EC".`, `-1 is the only position counted from the end; lines run 1..N.`, `Choose positions within 1..N.`, or ``Range "0,end" starts at 0, which is not a line; lines are numbered from 1 and 0 is only the "0" prepend position. Recovery: "L,M" selects lines L through M; "0" prepends and "-1" appends without replacing anything.`` / `Range "0,end" starts at 0; <unit> positions are numbered from 1.`). Unsupported scope arity: `A scope requires one position or an inclusive two-position range.` |
132
132
  | `overlapping-edits` | `409` | Two `edit` regions overlap, or a whole-resource replacement coexists with another `edit`. `Recovery: Submit the whole-resource replacement by itself.` |
133
- | `invalid-expression` | `400` | `The <dialect> matcher expression is invalid. Recovery: Revise the matcher expression.` |
133
+ | `invalid-expression` | `400` | `The <dialect> matcher expression is invalid.` with dialect working-form `Recovery` (`glob`, `regex`, `xpath`, `jsonpath`, or fallback `Revise the matcher expression.`) |
134
134
  | `unsupported-dialect` | `415` | `The <dialect> matcher is not supported for <mimetype>. Recovery: Use a matcher supported by the resource mimetype.` |
135
135
  | `attachments-invalid` | `400` | `attachments must be an array of non-empty resource addresses.` |
136
136
 
@@ -158,7 +158,7 @@ Additional framework helpers:
158
158
 
159
159
  ## §scheme-discovery First-party discovery
160
160
 
161
- `SchemeDiscovery.discover({ cwd? })` scans first-party `@plurnk/*` packages under `node_modules` via `@plurnk/plurnk-meta` ({§extension-discovery}) for packages declaring `plurnk.kind === "scheme"` (`plurnk.schemes: [{ name, export }]` or `plurnk.name`), ignoring non-`@plurnk/*` packages, failing hard on duplicate scheme prefixes or malformed declarations, and returning `{ schemes, packageAttributions }` descriptors without importing handler modules.
161
+ `SchemeDiscovery.discover({ cwd? })` scans first-party `@plurnk/*` packages under `node_modules` via `@plurnk/plurnk-meta` ({§extension-discovery}) for packages declaring `plurnk.kind === "scheme"` (`plurnk.schemes: [{ name, export }]` or `plurnk.name`), ignoring non-`@plurnk/*` packages, failing hard on duplicate scheme prefixes or malformed declarations, and returning `{ schemes, packageAttributions }` descriptors without importing handler modules. Each exported `SchemeHandlerConstructor` may declare an optional `static enabled?(env?: NodeJS.ProcessEnv): boolean`; returning `false` skips scheme registration.
162
162
 
163
163
  ## §message-source-scheme Message sources
164
164
 
@@ -1 +1 @@
1
- {"version":3,"file":"Matcher.d.ts","sourceRoot":"","sources":["../src/Matcher.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAqB,MAAM,0BAA0B,CAAC;AAOzF,OAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9E,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,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AE,SAAS,EACpB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GACxC,OAAO,CAAC,WAAW,CAAC,CAItB;IAGD,OAAa,SAAS,CAClB,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,UAAU,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,EACjD,OAAO,SAAK,EACZ,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,GACxC,OAAO,CAAC,WAAW,CAAC,CAsDtB;IAED,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAMnE;CACJ"}
package/dist/Matcher.js CHANGED
@@ -62,6 +62,20 @@ export default class Matcher {
62
62
  default: return body.raw;
63
63
  }
64
64
  }
65
+ static #invalidExpressionRecovery(dialect) {
66
+ switch (dialect) {
67
+ case "glob":
68
+ return 'Write a literal substring (`"needle"`) or balanced glob (`"*needle*"`).';
69
+ case "regex":
70
+ return 'Write `/pattern/flags`, such as `"/timeout/i"`; escape a literal `/` as `\\/`.';
71
+ case "xpath":
72
+ return 'Write an XPath 1.0 expression, such as `"//item"` or `"//item/@id"`.';
73
+ case "jsonpath":
74
+ return 'Write an RFC 9535 JSONPath expression, such as `"$.host"` or `"$.items[*]"`.';
75
+ default:
76
+ return "Revise the matcher expression.";
77
+ }
78
+ }
65
79
  static async matchAgainstContent(body, content, mimetype, mimetypes, diagnostic) {
66
80
  return Matcher.fromQuery(body, mimetype, () => mimetypes.query({ content, hint: mimetype }, Matcher.#parsedMatcher(body)), content, diagnostic);
67
81
  }
@@ -97,7 +111,7 @@ export default class Matcher {
97
111
  stage: "matcher",
98
112
  dialect: body.dialect,
99
113
  ...(causeDetail === "" ? {} : { diagnostic: causeDetail }),
100
- recovery: "Revise the matcher expression.",
114
+ recovery: Matcher.#invalidExpressionRecovery(body.dialect),
101
115
  retryable: false,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CAAC;YACN,CAAC;YACD,IAAI,IAAI,KAAK,wBAAwB,IAAI,GAAG,YAAY,sBAAsB,EAAE,CAAC;gBAC7E,6DAA6D;gBAC7D,2DAA2D;gBAC3D,OAAO;oBACH,MAAM,EAAE,GAAG;oBACX,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,uBAAuB;oBACjC,MAAM,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;iBAC3D,CAAC;YACN,CAAC;YACD,gEAAgE;YAChE,MAAM,GAAG,CAAC;QACd,CAAC;IACL,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAiB,EAAE,QAAgB;QAClD,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,EAChE,OAAO,IAAI,CAAC,OAAO,iCAAiC,QAAQ,GAAG,EAAE,EAAE,EAAE;YACjE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ;YACjD,QAAQ,EAAE,mDAAmD,EAAE,SAAS,EAAE,KAAK;SAClF,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["// {§matcher-dispatch} Body-matcher operation adapter. Mimetypes owns handler\n// resolution, dialect execution, and evidence; this layer maps its typed\n// outcomes to the universal scheme-result contract. PLURNK callers pass the\n// grammar's parsed dialect, while standalone raw strings retain framework\n// classification.\n//\n// Status 203 preserves readable content when its requested structural\n// projection cannot be parsed; the owning mapping lives in {§matcher-dispatch}.\n\nimport { isRecord } from \"@plurnk/plurnk-contracts\";\nimport type { MatcherBody } from \"@plurnk/plurnk-contracts\";\nimport type { Mimetypes, QueryMatch, ParsedBodyMatcher } from \"@plurnk/plurnk-mimetypes\";\nimport {\n UnsupportedDialectError,\n InvalidExpressionError,\n QueryParseFailureError,\n} from \"@plurnk/plurnk-mimetypes\";\nimport { TEXT_PRIMITIVE_MIMETYPE } from \"./MimetypeClassifier.ts\";\nimport Results, { type MatchEvidence, type SchemeResult } from \"./Results.ts\";\n\nexport interface MatchResult extends SchemeResult {\n body?: string; // raw fallback content (status 203)\n matches?: ReadonlyArray<MatchEvidence>; // addressable evidence (status 200 or 204)\n mimetype?: string; // overrides default text/markdown on the 203 fallback path\n reason?: string; // 203 fallback: framework's parse-failure reason for the model\n}\n\nexport default class Matcher {\n static #evidence(matches: readonly QueryMatch[], dialect: MatcherBody[\"dialect\"]): MatchEvidence[] {\n const evidence: MatchEvidence[] = [];\n const seen = new Set<string>();\n for (const match of matches) {\n const regions = [\n ...(match.regions ?? []).map((region) => ({ region })),\n ...(match.enclosingRegions ?? []).map((enclosingRegion) => ({ enclosingRegion })),\n ];\n // A text row (regex, glob) shows what it matched; structural dialects keep their locator.\n const matched = (dialect === \"regex\" || dialect === \"glob\") && match.text !== undefined ? { matched: match.text } : {};\n if (regions.length === 0 && match.matching !== undefined) {\n const item = Results.assertMatchEvidence({ locator: match.matching });\n const key = JSON.stringify(item);\n if (!seen.has(key)) {\n seen.add(key);\n evidence.push(item);\n }\n continue;\n }\n for (const location of regions) {\n const item = Results.assertMatchEvidence({\n ...(match.matching === undefined ? {} : { locator: match.matching }),\n ...location,\n ...matched,\n });\n const key = JSON.stringify(item);\n if (seen.has(key)) continue;\n seen.add(key);\n evidence.push(item);\n }\n }\n return evidence;\n }\n\n // {§matcher-dispatch} Hand the framework the ALREADY-PARSED matcher, not the raw\n // string — the grammar owns the matcher syntax, so re-classifying `raw`\n // inside mimetypes is a second parser for one syntax and a silent drift\n // surface (a body the grammar parsed as regex that re-classifies as xpath:\n // `#//foo#`). The declared dialect is authoritative; mimetypes dispatches it\n // verbatim. Only the four query dialects map; `semantic`/`graph` aren't\n // QueryDialects in mimetypes, so we pass `raw` and let it surface the same\n // UnsupportedDialectError (415) it does today.\n static #parsedMatcher(body: MatcherBody): string | ParsedBodyMatcher {\n switch (body.dialect) {\n case \"regex\": return { dialect: \"regex\", pattern: body.pattern, flags: body.flags };\n case \"glob\":\n case \"xpath\":\n case \"jsonpath\": return { dialect: body.dialect, pattern: body.raw };\n default: return body.raw;\n }\n }\n\n static async matchAgainstContent(\n body: MatcherBody,\n content: string,\n mimetype: string,\n mimetypes: Mimetypes,\n diagnostic?: (cause: unknown) => string,\n ): Promise<MatchResult> {\n return Matcher.fromQuery(body, mimetype, () => mimetypes.query(\n { content, hint: mimetype }, Matcher.#parsedMatcher(body),\n ), content, diagnostic);\n }\n\n // Representation adapters share typed outcomes and evidence mapping, not text coordinates.\n static async fromQuery(\n body: MatcherBody,\n mimetype: string,\n query: () => QueryMatch[] | Promise<QueryMatch[]>,\n content = \"\",\n diagnostic?: (cause: unknown) => string,\n ): Promise<MatchResult> {\n try {\n // Pass the parsed matcher (declared dialect authoritative) + `hint`\n // (source mimetype, so the framework picks the right per-mimetype\n // handler without re-detecting from content). No re-parse, no drift.\n const rawMatches = await query();\n if (rawMatches.length === 0) {\n return { status: 204, matches: [] };\n }\n return {\n status: 200,\n matches: Matcher.#evidence(rawMatches, body.dialect),\n };\n } catch (err) {\n // Name-based dispatch tolerates dup-copy node_modules layouts where\n // `instanceof` against the framework's exported classes can fail\n // because the consumer loads a different physical copy. The framework\n // sets each error subclass's `.name` to its class name.\n const name = err instanceof Error ? err.name : \"\";\n if (name === \"UnsupportedDialectError\" || err instanceof UnsupportedDialectError) {\n const unsupportedMimetype = isRecord(err) && typeof err.mimetype === \"string\" ? err.mimetype : mimetype;\n return Matcher.unsupported(body, unsupportedMimetype);\n }\n if (name === \"InvalidExpressionError\" || err instanceof InvalidExpressionError) {\n const cause = err instanceof Error ? err.cause : undefined;\n const causeDetail = cause === undefined || diagnostic === undefined ? \"\" : diagnostic(cause).trim();\n return Results.failure(\n \"schemes:matcher\",\n \"invalid-expression\",\n 400,\n `The ${body.dialect} matcher expression is invalid.`,\n {},\n {\n stage: \"matcher\",\n dialect: body.dialect,\n ...(causeDetail === \"\" ? {} : { diagnostic: causeDetail }),\n recovery: \"Revise the matcher expression.\",\n retryable: false,\n },\n );\n }\n if (name === \"QueryParseFailureError\" || err instanceof QueryParseFailureError) {\n // 203 soft fallback: return raw content as text so the model\n // can fall back to regex/visual parsing or fix the source.\n return {\n status: 203,\n body: content,\n mimetype: TEXT_PRIMITIVE_MIMETYPE,\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n // Unexpected — let it propagate so the engine logs it as a 500.\n throw err;\n }\n }\n\n static unsupported(body: MatcherBody, mimetype: string): MatchResult {\n return Results.failure(\"schemes:matcher\", \"unsupported-dialect\", 415,\n `The ${body.dialect} matcher is not supported for ${mimetype}.`, {}, {\n stage: \"matcher\", dialect: body.dialect, mimetype,\n recovery: \"Use a matcher supported by the resource mimetype.\", retryable: false,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"Matcher.js","sourceRoot":"","sources":["../src/Matcher.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,yEAAyE;AACzE,4EAA4E;AAC5E,0EAA0E;AAC1E,kBAAkB;AAClB,EAAE;AACF,sEAAsE;AACtE,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EACH,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,OAAO,EAAE,EAAyC,MAAM,cAAc,CAAC;AAS9E,MAAM,CAAC,OAAO,OAAO,OAAO;IACxB,MAAM,CAAC,SAAS,CAAC,OAA8B,EAAE,OAA+B;QAC5E,MAAM,QAAQ,GAAoB,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG;gBACZ,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAA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,CAAC,IAAiB,EAAE,QAAgB;QAClD,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,qBAAqB,EAAE,GAAG,EAChE,OAAO,IAAI,CAAC,OAAO,iCAAiC,QAAQ,GAAG,EAAE,EAAE,EAAE;YACjE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ;YACjD,QAAQ,EAAE,mDAAmD,EAAE,SAAS,EAAE,KAAK;SAClF,CAAC,CAAC;IACX,CAAC;CACJ","sourcesContent":["// {§matcher-dispatch} Body-matcher operation adapter. Mimetypes owns handler\n// resolution, dialect execution, and evidence; this layer maps its typed\n// outcomes to the universal scheme-result contract. PLURNK callers pass the\n// grammar's parsed dialect, while standalone raw strings retain framework\n// classification.\n//\n// Status 203 preserves readable content when its requested structural\n// projection cannot be parsed; the owning mapping lives in {§matcher-dispatch}.\n\nimport { isRecord } from \"@plurnk/plurnk-contracts\";\nimport type { MatcherBody } from \"@plurnk/plurnk-contracts\";\nimport type { Mimetypes, QueryMatch, ParsedBodyMatcher } from \"@plurnk/plurnk-mimetypes\";\nimport {\n UnsupportedDialectError,\n InvalidExpressionError,\n QueryParseFailureError,\n} from \"@plurnk/plurnk-mimetypes\";\nimport { TEXT_PRIMITIVE_MIMETYPE } from \"./MimetypeClassifier.ts\";\nimport Results, { type MatchEvidence, type SchemeResult } from \"./Results.ts\";\n\nexport interface MatchResult extends SchemeResult {\n body?: string; // raw fallback content (status 203)\n matches?: ReadonlyArray<MatchEvidence>; // addressable evidence (status 200 or 204)\n mimetype?: string; // overrides default text/markdown on the 203 fallback path\n reason?: string; // 203 fallback: framework's parse-failure reason for the model\n}\n\nexport default class Matcher {\n static #evidence(matches: readonly QueryMatch[], dialect: MatcherBody[\"dialect\"]): MatchEvidence[] {\n const evidence: MatchEvidence[] = [];\n const seen = new Set<string>();\n for (const match of matches) {\n const regions = [\n ...(match.regions ?? []).map((region) => ({ region })),\n ...(match.enclosingRegions ?? []).map((enclosingRegion) => ({ enclosingRegion })),\n ];\n // A text row (regex, glob) shows what it matched; structural dialects keep their locator.\n const matched = (dialect === \"regex\" || dialect === \"glob\") && match.text !== undefined ? { matched: match.text } : {};\n if (regions.length === 0 && match.matching !== undefined) {\n const item = Results.assertMatchEvidence({ locator: match.matching });\n const key = JSON.stringify(item);\n if (!seen.has(key)) {\n seen.add(key);\n evidence.push(item);\n }\n continue;\n }\n for (const location of regions) {\n const item = Results.assertMatchEvidence({\n ...(match.matching === undefined ? {} : { locator: match.matching }),\n ...location,\n ...matched,\n });\n const key = JSON.stringify(item);\n if (seen.has(key)) continue;\n seen.add(key);\n evidence.push(item);\n }\n }\n return evidence;\n }\n\n // {§matcher-dispatch} Hand the framework the ALREADY-PARSED matcher, not the raw\n // string — the grammar owns the matcher syntax, so re-classifying `raw`\n // inside mimetypes is a second parser for one syntax and a silent drift\n // surface (a body the grammar parsed as regex that re-classifies as xpath:\n // `#//foo#`). The declared dialect is authoritative; mimetypes dispatches it\n // verbatim. Only the four query dialects map; `semantic`/`graph` aren't\n // QueryDialects in mimetypes, so we pass `raw` and let it surface the same\n // UnsupportedDialectError (415) it does today.\n static #parsedMatcher(body: MatcherBody): string | ParsedBodyMatcher {\n switch (body.dialect) {\n case \"regex\": return { dialect: \"regex\", pattern: body.pattern, flags: body.flags };\n case \"glob\":\n case \"xpath\":\n case \"jsonpath\": return { dialect: body.dialect, pattern: body.raw };\n default: return body.raw;\n }\n }\n\n static #invalidExpressionRecovery(dialect: MatcherBody[\"dialect\"]): string {\n switch (dialect) {\n case \"glob\":\n return 'Write a literal substring (`\"needle\"`) or balanced glob (`\"*needle*\"`).';\n case \"regex\":\n return 'Write `/pattern/flags`, such as `\"/timeout/i\"`; escape a literal `/` as `\\\\/`.';\n case \"xpath\":\n return 'Write an XPath 1.0 expression, such as `\"//item\"` or `\"//item/@id\"`.';\n case \"jsonpath\":\n return 'Write an RFC 9535 JSONPath expression, such as `\"$.host\"` or `\"$.items[*]\"`.';\n default:\n return \"Revise the matcher expression.\";\n }\n }\n\n static async matchAgainstContent(\n body: MatcherBody,\n content: string,\n mimetype: string,\n mimetypes: Mimetypes,\n diagnostic?: (cause: unknown) => string,\n ): Promise<MatchResult> {\n return Matcher.fromQuery(body, mimetype, () => mimetypes.query(\n { content, hint: mimetype }, Matcher.#parsedMatcher(body),\n ), content, diagnostic);\n }\n\n // Representation adapters share typed outcomes and evidence mapping, not text coordinates.\n static async fromQuery(\n body: MatcherBody,\n mimetype: string,\n query: () => QueryMatch[] | Promise<QueryMatch[]>,\n content = \"\",\n diagnostic?: (cause: unknown) => string,\n ): Promise<MatchResult> {\n try {\n // Pass the parsed matcher (declared dialect authoritative) + `hint`\n // (source mimetype, so the framework picks the right per-mimetype\n // handler without re-detecting from content). No re-parse, no drift.\n const rawMatches = await query();\n if (rawMatches.length === 0) {\n return { status: 204, matches: [] };\n }\n return {\n status: 200,\n matches: Matcher.#evidence(rawMatches, body.dialect),\n };\n } catch (err) {\n // Name-based dispatch tolerates dup-copy node_modules layouts where\n // `instanceof` against the framework's exported classes can fail\n // because the consumer loads a different physical copy. The framework\n // sets each error subclass's `.name` to its class name.\n const name = err instanceof Error ? err.name : \"\";\n if (name === \"UnsupportedDialectError\" || err instanceof UnsupportedDialectError) {\n const unsupportedMimetype = isRecord(err) && typeof err.mimetype === \"string\" ? err.mimetype : mimetype;\n return Matcher.unsupported(body, unsupportedMimetype);\n }\n if (name === \"InvalidExpressionError\" || err instanceof InvalidExpressionError) {\n const cause = err instanceof Error ? err.cause : undefined;\n const causeDetail = cause === undefined || diagnostic === undefined ? \"\" : diagnostic(cause).trim();\n return Results.failure(\n \"schemes:matcher\",\n \"invalid-expression\",\n 400,\n `The ${body.dialect} matcher expression is invalid.`,\n {},\n {\n stage: \"matcher\",\n dialect: body.dialect,\n ...(causeDetail === \"\" ? {} : { diagnostic: causeDetail }),\n recovery: Matcher.#invalidExpressionRecovery(body.dialect),\n retryable: false,\n },\n );\n }\n if (name === \"QueryParseFailureError\" || err instanceof QueryParseFailureError) {\n // 203 soft fallback: return raw content as text so the model\n // can fall back to regex/visual parsing or fix the source.\n return {\n status: 203,\n body: content,\n mimetype: TEXT_PRIMITIVE_MIMETYPE,\n reason: err instanceof Error ? err.message : String(err),\n };\n }\n // Unexpected — let it propagate so the engine logs it as a 500.\n throw err;\n }\n }\n\n static unsupported(body: MatcherBody, mimetype: string): MatchResult {\n return Results.failure(\"schemes:matcher\", \"unsupported-dialect\", 415,\n `The ${body.dialect} matcher is not supported for ${mimetype}.`, {}, {\n stage: \"matcher\", dialect: body.dialect, mimetype,\n recovery: \"Use a matcher supported by the resource mimetype.\", retryable: false,\n });\n }\n}\n"]}
@@ -43,7 +43,7 @@ export default class NetworkAddress {
43
43
  const queryStart = pathname.indexOf("?");
44
44
  const path = queryStart === -1 ? pathname : pathname.slice(0, queryStart);
45
45
  const query = queryStart === -1 ? "" : pathname.slice(queryStart);
46
- return PathSyntax.escapeTarget(`${scheme.toLowerCase()}://${authority}${PathSyntax.encodeParens(path)}${query}`);
46
+ return PathSyntax.escapeTarget(`${scheme.toLowerCase()}://${authority}${path}${query}`);
47
47
  }
48
48
  }
49
49
  //# sourceMappingURL=NetworkAddress.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkAddress.js","sourceRoot":"","sources":["../src/NetworkAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,0BAA0B,CAAC;AAGpE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAEhE,gGAAgG;AAChG,MAAM,CAAC,OAAO,OAAO,cAAc;IACtB,MAAM,CAAS;IACf,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,GAAG,CAAS;IACZ,cAAc,CAAU;IAEjC,YAAoB,MAAe;QAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;Q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AAC,OAAsD;QAChE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAChD,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACnC,MAAM,IAAI,SAAS,CAAC,+BAA+B,MAAM,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,SAAS,CAAC,2CAA2C,CAAC,CAAC;QACrE,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;QACtE,CAAC;QACD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAC1E,MAAM,KAAK,GAAG,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAClE,OAAO,UAAU,CAAC,YAAY,CAC1B,GAAG,MAAM,CAAC,WAAW,EAAE,MAAM,SAAS,GAAG,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,KAAK,EAAE,CACnF,CAAC;IACN,CAAC;CACJ","sourcesContent":["import { PathSyntax, type UrlPath } from \"@plurnk/plurnk-contracts\";\nimport type { EntryCoordinate } from \"./types.ts\";\n\nconst NETWORK_SCHEMES = new Set([\"http\", \"https\", \"ws\", \"wss\"]);\n\n/** Canonical, non-secret identity and transport form for network targets. {§network-address} */\nexport default class NetworkAddress {\n readonly scheme: string;\n readonly authority: string;\n readonly pathname: string;\n readonly url: string;\n readonly hasCredentials: boolean;\n\n private constructor(target: UrlPath) {\n const scheme = target.scheme.toLowerCase();\n if (!NetworkAddress.supports(scheme)) {\n throw new TypeError(`unsupported network scheme: ${target.scheme}`);\n }\n if (target.hostname === null) {\n throw new TypeError(`${scheme} target requires an authority`);\n }\n\n const authority = `${target.hostname}${target.port === null ? \"\" : `:${target.port}`}`;\n const query = target.query === null ? \"\" : `?${target.query}`;\n\n this.scheme = scheme;\n this.authority = authority;\n this.pathname = PathSyntax.decodeParens(target.pathname) + query;\n this.url = `${scheme}://${authority}${target.pathname}${query}`;\n this.hasCredentials = target.username !== null || target.password !== null;\n }\n\n static supports(scheme: string): boolean {\n return NETWORK_SCHEMES.has(scheme.toLowerCase());\n }\n\n static from(target: UrlPath): NetworkAddress {\n return new NetworkAddress(target);\n }\n\n static render(address: EntryCoordinate & { readonly scheme: string }): string {\n const { scheme, authority, pathname } = address;\n if (!NetworkAddress.supports(scheme)) {\n throw new TypeError(`unsupported network scheme: ${scheme}`);\n }\n if (authority.length === 0) {\n throw new TypeError(\"network entry authority must not be empty\");\n }\n if (!pathname.startsWith(\"/\")) {\n throw new TypeError(\"network entry pathname must begin with `/`\");\n }\n const queryStart = pathname.indexOf(\"?\");\n const path = queryStart === -1 ? pathname : pathname.slice(0, queryStart);\n const query = queryStart === -1 ? \"\" : pathname.slice(queryStart);\n return PathSyntax.escapeTarget(\n `${scheme.toLowerCase()}://${authority}${PathSyntax.encodeParens(path)}${query}`,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"NetworkAddress.js","sourceRoot":"","sources":["../src/NetworkAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,0BAA0B,CAAC;AAGpE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAEhE,gGAAgG;AAChG,MAAM,CAAC,OAAO,OAAO,cAAc;IACtB,MAAM,CA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set([\"http\", \"https\", \"ws\", \"wss\"]);\n\n/** Canonical, non-secret identity and transport form for network targets. {§network-address} */\nexport default class NetworkAddress {\n readonly scheme: string;\n readonly authority: string;\n readonly pathname: string;\n readonly url: string;\n readonly hasCredentials: boolean;\n\n private constructor(target: UrlPath) {\n const scheme = target.scheme.toLowerCase();\n if (!NetworkAddress.supports(scheme)) {\n throw new TypeError(`unsupported network scheme: ${target.scheme}`);\n }\n if (target.hostname === null) {\n throw new TypeError(`${scheme} target requires an authority`);\n }\n\n const authority = `${target.hostname}${target.port === null ? \"\" : `:${target.port}`}`;\n const query = target.query === null ? \"\" : `?${target.query}`;\n\n this.scheme = scheme;\n this.authority = authority;\n this.pathname = PathSyntax.decodeParens(target.pathname) + query;\n this.url = `${scheme}://${authority}${target.pathname}${query}`;\n this.hasCredentials = target.username !== null || target.password !== null;\n }\n\n static supports(scheme: string): boolean {\n return NETWORK_SCHEMES.has(scheme.toLowerCase());\n }\n\n static from(target: UrlPath): NetworkAddress {\n return new NetworkAddress(target);\n }\n\n static render(address: EntryCoordinate & { readonly scheme: string }): string {\n const { scheme, authority, pathname } = address;\n if (!NetworkAddress.supports(scheme)) {\n throw new TypeError(`unsupported network scheme: ${scheme}`);\n }\n if (authority.length === 0) {\n throw new TypeError(\"network entry authority must not be empty\");\n }\n if (!pathname.startsWith(\"/\")) {\n throw new TypeError(\"network entry pathname must begin with `/`\");\n }\n const queryStart = pathname.indexOf(\"?\");\n const path = queryStart === -1 ? pathname : pathname.slice(0, queryStart);\n const query = queryStart === -1 ? \"\" : pathname.slice(queryStart);\n return PathSyntax.escapeTarget(\n `${scheme.toLowerCase()}://${authority}${path}${query}`,\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Slicer.d.ts","sourceRoot":"","sources":["../src/Slicer.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACpF,OAAO,EAAE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CAAA;KAAE,GAC9H,eAAe,GAAG,UAAU,CAkB9B;IAkHD,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,WAAW,CA6E7D;IAKD,MAAM,CAAC,IAAI,CAAC,CAAC,EACT,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAA;KAAO,GAC5C,UAAU,CAAC,CAAC,CAAC,CAwFf;IAQD,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,WAAW,CAmBhE;IAUD,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAEnF;IAED,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,SAAS,EAAE,GAAG,UAAU,CAuKnF;CAEJ"}
package/dist/Slicer.js CHANGED
@@ -1,21 +1,21 @@
1
- // `<L>` line-marker semantics (plurnk.md §`<L>`):
1
+ // {§slicer-text-algebra} Line-marker range semantics:
2
2
  //
3
- // <N> selects position N (1-indexed)
4
- // <N,M> selects positions N..M inclusive
5
- // <0> sentinel: before position 1 (EDIT prepend)
6
- // <-1> sentinel: after the last position (EDIT append)
7
- // <1,-1> every position (in range context, -1 normalizes to last line)
8
- // <1,1,-1,1> the whole text; -1 as a region line is the content's end, so <-1,1,-1,1> appends
9
- // <SL,SC,EL,EC> selects an exact text region with an exclusive end.
3
+ // "N" selects position N (1-indexed)
4
+ // "N,M" selects positions N..M inclusive
5
+ // "-K,-M" projection-only end-relative range (`-1` is the last position, `-K` is `total + 1 - K`, clamped to `1`)
6
+ // "0" sentinel: before position 1 (EDIT prepend)
7
+ // "-1" sentinel: after the last position (EDIT append; empty on single-mark projection)
8
+ // "1,-1" every position (in range context, -1 normalizes to last line)
9
+ // "1,1,-1,1" the whole text; -1 as a region line is the content's end, so "-1,1,-1,1" appends
10
+ // "SL,SC,EL,EC" selects an exact text region with an exclusive end.
10
11
  //
11
- // Runtime tolerance (not canonical producer syntax): <SL,SC,EL> is accepted
12
- // as <SL,SC> through the end of line EL and lowered immediately to four
12
+ // Runtime tolerance (not canonical producer syntax): "SL,SC,EL" is accepted
13
+ // as "SL,SC" through the end of line EL and lowered immediately to four
13
14
  // coordinates. Successful results carry the exact normalization evidence.
14
15
  //
15
- // "N and M are signed integers" — but plurnk.md only documents <0> and
16
- // <-1> as defined sentinels. Other negatives (<-2>, <-3>) are not
17
- // specified and rejected as 416. Within a range, -1 as the M endpoint
18
- // means "include through the last line" (so <1,-1> is whole content).
16
+ // On mutation, N and M are positive integers with 0 and -1 as the defined sentinels
17
+ // (other negatives fail 416). On two-coordinate projections (`lines()`, `window()`, `page()`),
18
+ // negative endpoints count backward from the end (`total + 1 + mark`).
19
19
  import { TextCoordinates } from "@plurnk/plurnk-mimetypes";
20
20
  import Results, {} from "./Results.js";
21
21
  export default class Slicer {
@@ -75,7 +75,7 @@ export default class Slicer {
75
75
  if (marker.marks.length !== 1 && marker.marks.length !== 2) {
76
76
  return Slicer.#regionFailure(`Positional windows take one or two coordinates; received ${marker.marks.length}.`, marker);
77
77
  }
78
- const norm = Slicer.#normalize(marker, total, unit);
78
+ const norm = Slicer.#normalize(marker, total, unit, true);
79
79
  const extent = Slicer.#extent(marker, total, unit);
80
80
  if ("error" in norm)
81
81
  return Slicer.#rangeFailure(norm.error, extent, norm.recovery);
@@ -152,9 +152,9 @@ export default class Slicer {
152
152
  resolvedEnd, endLine === -1 || endColumn === -1 ? endOf(resolvedEnd) : endColumn,
153
153
  ];
154
154
  }
155
- // {§zero-width-column-one-insert} — the fence artifact repaired where a fenced EDIT body becomes
156
- // inserted content: a zero-width region at column 1 inserts whole lines, so a non-empty body that
157
- // does not end in a newline gains the content's separator. Every other body is returned verbatim.
155
+ // {§zero-width-column-one-insert} — an edit body inserted at a zero-width column-1 region inserts
156
+ // whole lines, so a non-empty body that does not end in a newline gains the content's separator.
157
+ // Every other body is returned verbatim.
158
158
  static wholeLineBody(content, marker, body) {
159
159
  const [startLine, startColumn, endLine, endColumn] = marker.marks;
160
160
  const zeroWidthAtColumnOne = marker.marks.length === 4
@@ -173,7 +173,7 @@ export default class Slicer {
173
173
  if (lines.length === 0 && marker.marks.length === 1 && marker.marks[0] === 1) {
174
174
  return { start: 0, end: 0, body, startLine: 1, endLine: 1 };
175
175
  }
176
- const norm = Slicer.#normalize(marker, lines.length, "line");
176
+ const norm = Slicer.#normalize(marker, lines.length, "line", false);
177
177
  if ("error" in norm)
178
178
  return norm;
179
179
  const separator = Slicer.#preferredSeparator(content, lines);
@@ -275,7 +275,7 @@ export default class Slicer {
275
275
  recovery: '"L,M" selects lines L through M; "0" prepends and "-1" appends without replacing anything.',
276
276
  };
277
277
  }
278
- static #normalize(marker, totalLines, unit) {
278
+ static #normalize(marker, totalLines, unit, projection = false) {
279
279
  // {§diagnostic-observation} — a window over another unit (a resource's bytes) names that unit.
280
280
  const noun = unit === "matchLocation" ? "match location" : unit;
281
281
  const Noun = `${noun[0].toUpperCase()}${noun.slice(1)}`;
@@ -305,21 +305,36 @@ export default class Slicer {
305
305
  }
306
306
  if (first === 0)
307
307
  return Slicer.#zeroStart(last, unit);
308
- // Whole-content `<1,-1>` is valid even on empty content — it selects the entire,
309
- // possibly-empty range ({§op-shapes}). start>end here yields an empty
310
- // slice for READ and a full replacement for EDIT.
308
+ // Whole-content `<1,-1>` (and a projection tail range `<-K,-1>` with `-K <= -1`) is valid
309
+ // even on empty content — it selects the entire, possibly-empty range ({§op-shapes}).
311
310
  if (totalLines === 0) {
312
311
  if (first === 1 && (last === -1 || last > 0)) {
313
312
  return { kind: "range", start: 1, end: 0 };
314
313
  }
314
+ if (projection && first < 0 && last < 0 && first <= last) {
315
+ return { kind: "range", start: 1, end: 0 };
316
+ }
315
317
  return { error: `Range ${first},${last} cannot select from empty content.` };
316
318
  }
319
+ if (projection && (first < 0 || last < -1)) {
320
+ if (first < 0 && last < 0 && first > last) {
321
+ return { error: `Range start ${first} exceeds end ${last}.` };
322
+ }
323
+ const m = last < 0 ? totalLines + 1 + last : Math.min(last, totalLines);
324
+ if (m < 1)
325
+ return { error: `Range end ${last} is outside the available ${noun} range 1..${totalLines}.` };
326
+ const n = first < 0 ? Math.max(1, totalLines + 1 + first) : first;
327
+ if (n < 1 || n > totalLines)
328
+ return { error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.` };
329
+ if (n > m)
330
+ return { error: `Range start ${first} exceeds end ${last}.` };
331
+ return { kind: "range", start: n, end: m };
332
+ }
317
333
  const n = first;
318
334
  let m = last;
319
335
  if (m === -1 || m > totalLines)
320
336
  m = totalLines;
321
- // {§op-shapes} — -1 is the only position counted from the end; a `<-N,-1>` start is
322
- // refused with the line extent, never rebuilt into a tail ({§diagnostic-observation}).
337
+ // {§op-shapes} — on mutation, -1 is the only position counted from the end.
323
338
  if (n < -1 && last === -1) {
324
339
  return {
325
340
  error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.`,
@@ -372,7 +387,7 @@ export default class Slicer {
372
387
  return Slicer.#regionFailure(`Text regions require one, two, or four coordinates; received ${marker.marks.length}.`, marker);
373
388
  }
374
389
  const lines = TextCoordinates.logicalLines(content);
375
- const norm = Slicer.#normalize(marker, lines.length, "line");
390
+ const norm = Slicer.#normalize(marker, lines.length, "line", true);
376
391
  if ("error" in norm) {
377
392
  return Slicer.#rangeFailure(norm.error, Slicer.#extent(marker, lines.length, "line"), norm.recovery);
378
393
  }
@@ -457,13 +472,16 @@ export default class Slicer {
457
472
  if (total === 0) {
458
473
  // Any well-formed range over an empty result set selects nothing: the answer is
459
474
  // "no matches", a 200 with zero items. Only an inverted range is unsatisfiable.
460
- if (first >= 1 && (last === -1 || last >= first)) {
475
+ if ((first >= 1 && (last === -1 || last >= first)) || (first < 0 && last < 0 && first <= last)) {
461
476
  return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };
462
477
  }
463
478
  return Slicer.#rangeFailure(`Result range ${first},${last} is inverted; a range runs from a lower position to a higher one.`, extent);
464
479
  }
465
- const n = first;
466
- const m = last === -1 ? total : Math.min(last, total);
480
+ if (first < 0 && last < 0 && first > last) {
481
+ return Slicer.#rangeFailure(`Result range start ${first} exceeds end ${last}.`, extent);
482
+ }
483
+ const m = last < 0 ? total + 1 + last : Math.min(last, total);
484
+ const n = first < 0 ? Math.max(1, total + 1 + first) : first;
467
485
  if (n < 1 || n > total)
468
486
  return Slicer.#rangeFailure(`Result range start ${first} is out of range; available positions are 1..${total}; this scope pages ${extent.unit} items.`, extent, Slicer.#pageRecovery(total));
469
487
  if (m < 1)
@@ -1 +1 @@
1
- {"version":3,"file":"Slicer.js","sourceRoot":"","sources":["../src/Slicer.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,4CAA4C;AAC5C,8CAA8C;AAC9C,wDAAwD;AACxD,6DAA6D;AAC7D,2EAA2E;AAC3E,gGAAgG;AAChG,sEAAsE;AACtE,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,EAAE;AACF,uEAAuE;AACvE,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AAGtE,OAAO,EAAE,eAAe,EAAiB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,OAAO,EAAE,EAA8C,MAAM,cAAc,CAAC;AAuDnF,MAAM,CAAC,OAAO,OAAO,MAAM;IACvB,4FAA4F;IAC5F,MAAM,CAAC,SAAS,CAAC,MAAkB;QAC/B,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QACnC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,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,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SACtD,CAAC;IACN,CAAC;CAEJ","sourcesContent":["// `<L>` line-marker semantics (plurnk.md §`<L>`):\n//\n// <N> selects position N (1-indexed)\n// <N,M> selects positions N..M inclusive\n// <0> sentinel: before position 1 (EDIT prepend)\n// <-1> sentinel: after the last position (EDIT append)\n// <1,-1> every position (in range context, -1 normalizes to last line)\n// <1,1,-1,1> the whole text; -1 as a region line is the content's end, so <-1,1,-1,1> appends\n// <SL,SC,EL,EC> selects an exact text region with an exclusive end.\n//\n// Runtime tolerance (not canonical producer syntax): <SL,SC,EL> is accepted\n// as <SL,SC> through the end of line EL and lowered immediately to four\n// coordinates. Successful results carry the exact normalization evidence.\n//\n// \"N and M are signed integers\" — but plurnk.md only documents <0> and\n// <-1> as defined sentinels. Other negatives (<-2>, <-3>) are not\n// specified and rejected as 416. Within a range, -1 as the M endpoint\n// means \"include through the last line\" (so <1,-1> is whole content).\n\nimport type { LineMarker, RangeExtent, TextRegion } from \"@plurnk/plurnk-contracts\";\nimport { TextCoordinates, type TextLine } from \"@plurnk/plurnk-mimetypes\";\nimport Results, { type SchemeResult, type ScopeNormalization } from \"./Results.ts\";\n\nexport interface ScopeError {\n readonly error: string;\n readonly recovery?: string;\n}\ninterface NormalizedMarker {\n kind: \"range\" | \"before-first\" | \"after-last\";\n start: number;\n end: number;\n}\n\nexport interface TextReplacement {\n readonly start: number;\n readonly end: number;\n readonly body: string;\n readonly startLine: number;\n readonly endLine: number;\n readonly normalization?: ScopeNormalization;\n}\n\nexport type RangeUnit = RangeExtent[\"unit\"];\nexport interface SliceResult extends SchemeResult {\n text?: string;\n startLine?: number;\n region?: TextRegion;\n range?: RangeExtent;\n}\nexport interface PageResult<T> extends SchemeResult { items?: T[]; range?: RangeExtent }\n// {§op-methods-op-dispatch} — an evidence-gated resolution of two authored regions, reported on the\n// row it changed so the model can verify or undo it; `index` is the position in the batch.\ntype EditMerge =\n | { readonly index: number; readonly rule: \"duplicate-of\"; readonly of: number; readonly whitespaceOnly?: true }\n | { readonly index: number; readonly rule: \"shared-endpoint\"; readonly line: number; readonly text: string; readonly authored: readonly number[]; readonly applied: readonly number[]; readonly claimedBy: number }\n | { readonly index: number; readonly rule: \"same-insertion-point\"; readonly after: number }\n | { readonly index: number; readonly rule: \"contained-relocated\"; readonly outer: number; readonly at: number; readonly authored: readonly number[]; readonly originalLines: number }\n | { readonly index: number; readonly rule: \"contained-already-applied\"; readonly outer: number };\nexport interface EditResult extends SchemeResult {\n result?: string;\n range?: RangeExtent;\n merges?: readonly EditMerge[];\n // The edits as applied, in authored order with dropped duplicates omitted; receipts are\n // built from these, and a dropped row carries its merge fact instead of an effect.\n applied?: readonly BatchEdit[];\n}\nexport interface BatchEdit {\n readonly marker: LineMarker;\n readonly body: string;\n}\nexport interface WindowResult extends SchemeResult {\n start?: number | null;\n end?: number | null;\n range?: RangeExtent;\n}\n\nexport default class Slicer {\n // {§slicer-text-algebra} Projection tolerance is separate from the strict mutation algebra.\n static readScope(marker: LineMarker): ScopeNormalization | undefined {\n const [first, last] = marker.marks;\n return marker.marks.length === 2 && first === 0 && Number.isSafeInteger(last) && (last === -1 || last > 0)\n ? { requested: [0, last], canonical: [1, last] }\n : undefined;\n }\n\n static #failure(\n code: string,\n status: number,\n detail: string,\n fields: Readonly<Record<string, unknown>> = {},\n extensions: Readonly<Record<string, unknown>> = {},\n ): SchemeResult {\n return Results.failure(\"schemes:slicer\", code, status, detail, fields, extensions);\n }\n\n static #rangeFailure(\n detail: string,\n range: RangeExtent,\n recovery = \"Choose a range within the available extent.\",\n ): SchemeResult {\n return Slicer.#failure(\n \"range-not-satisfiable\",\n 416,\n detail,\n { range },\n {\n range,\n stage: \"projection\",\n recovery,\n retryable: false,\n },\n );\n }\n\n // A result position outside the page: the recovery states the positions the page holds and\n // names no other operation ({§diagnostic-observation}).\n static #pageRecovery(total: number): string {\n return `Choose positions within 1..${total}.`;\n }\n\n static #regionFailure(\n detail: string,\n marker: LineMarker,\n recovery = \"Choose a region within the available text.\",\n ): SchemeResult {\n return Slicer.#failure(\n \"range-not-satisfiable\",\n 416,\n detail,\n {},\n {\n requestedCoordinates: marker.marks,\n columnKind: \"unicodeCodePoints\",\n stage: \"projection\",\n recovery,\n retryable: false,\n },\n );\n }\n\n static #extent(marker: LineMarker, total: number, unit: RangeUnit): RangeExtent {\n const first = marker.marks[0];\n return {\n unit,\n total,\n requested: [first, marker.marks[1] ?? first],\n };\n }\n\n static #projectedExtent(\n extent: RangeExtent,\n first: number | null,\n last: number | null,\n ): RangeExtent {\n return first === null || last === null\n ? extent\n : { ...extent, returned: [first, last] };\n }\n\n static coversAvailable(range: RangeExtent): boolean {\n return range.total === 0\n || (range.returned?.[0] === 1 && range.returned[1] === range.total);\n }\n // {§slicer-text-algebra} — the positional contract of `lines()` over any 1-based unit whose content\n // is not text in memory (a resource's bytes): the same normalization, extents, sentinels, and\n // 416s, resolved against a total alone. A null start is a sentinel selection of nothing.\n static window(marker: LineMarker, total: number, unit: RangeUnit): WindowResult {\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return Slicer.#regionFailure(\n `Positional windows take one or two coordinates; received ${marker.marks.length}.`,\n marker,\n );\n }\n const norm = Slicer.#normalize(marker, total, unit);\n const extent = Slicer.#extent(marker, total, unit);\n if (\"error\" in norm) return Slicer.#rangeFailure(norm.error, extent, norm.recovery);\n if (norm.kind !== \"range\" || norm.start > norm.end) {\n return { status: 200, start: null, end: null, range: Slicer.#projectedExtent(extent, null, null) };\n }\n return { status: 200, start: norm.start, end: norm.end, range: Slicer.#projectedExtent(extent, norm.start, norm.end) };\n }\n\n static #exactTextReplacement(\n content: string,\n marker: LineMarker,\n body: string,\n cache?: { readonly coords: TextCoordinates; readonly lines: readonly TextLine[] },\n ): TextReplacement | ScopeError {\n if (marker.marks.length !== 4 || !marker.marks.every(Number.isSafeInteger)) {\n return { error: \"An exact text region requires four integer coordinates.\" };\n }\n const resolved = Slicer.#exactRegion(content, marker, body, cache);\n // {§op-shapes} — lines and columns count from 1; a refused region holding a zero\n // says so as read and is never rebuilt into another region ({§diagnostic-observation}).\n if (!(\"error\" in resolved) || !marker.marks.includes(0)) return resolved;\n return { error: resolved.error, recovery: \"Lines and columns count from 1.\" };\n }\n\n static #exactRegion(\n content: string,\n marker: LineMarker,\n body: string,\n cache?: { readonly coords: TextCoordinates; readonly lines: readonly TextLine[] },\n ): TextReplacement | ScopeError {\n const lines = cache?.lines ?? TextCoordinates.lines(content);\n const coords = cache?.coords ?? new TextCoordinates(content);\n // {§op-shapes} — `-1` is the final addressable endpoint in every form: as a region line it\n // is the end of the content, so `<1,1,-1,1>` is the whole text and `<-1,1,-1,1>` appends; as a column\n // it is the end of its line, so `<3,1,3,-1>` is line 3 to its end and `<3,-1,3,-1>` appends to it.\n if (!Slicer.#fourMarks(marker.marks)) return { error: \"A region names four marks: start line, start column, end line, end column.\" };\n const [startLine, startColumn, endLine, rawEndColumn] = Slicer.#finalEndpoint(content, lines, marker.marks);\n if (startLine < 1 || startLine > lines.length) {\n return { error: `Start line ${startLine} is outside the available line range 1..${lines.length}.` };\n }\n if (endLine < 1) {\n return { error: `End line ${endLine} is outside the available line range 1..${lines.length}.` };\n }\n if (rawEndColumn < 1) {\n return { error: `End column ${rawEndColumn} must be positive.` };\n }\n const pastEof = endLine > lines.length;\n const resolvedEndLine = pastEof ? lines.length : endLine;\n const endLineData = lines[resolvedEndLine - 1];\n const maxEndColumn = Array.from(content.slice(endLineData.start, endLineData.contentEnd)).length + 1;\n const endColumn = pastEof ? maxEndColumn : Math.min(rawEndColumn, maxEndColumn);\n let start: number;\n let end: number;\n try {\n start = coords.offsetAtPosition(startLine, startColumn);\n end = coords.offsetAtPosition(resolvedEndLine, endColumn);\n } catch (cause) {\n return { error: cause instanceof Error ? cause.message : String(cause) };\n }\n if (end < start) {\n return {\n error: `Exact region ${startLine},${startColumn},${endLine},${rawEndColumn} ends before it starts.`,\n recovery: 'An exact region names its earlier position first: \"SL,SC,EL,EC\".',\n };\n }\n return { start, end, body, startLine, endLine: resolvedEndLine };\n }\n\n // The four marks a region names, as the marker's tuple type cannot say.\n static #fourMarks(marks: readonly number[]): marks is readonly [number, number, number, number] {\n return marks.length === 4;\n }\n\n static #finalEndpoint(content: string, lines: readonly TextLine[], marks: readonly [number, number, number, number]): [number, number, number, number] {\n const [startLine, startColumn, endLine, endColumn] = marks;\n const endOf = (line: number): number => {\n const data = lines[Math.min(Math.max(line, 1), lines.length) - 1];\n return Array.from(content.slice(data.start, data.contentEnd)).length + 1;\n };\n const resolvedStart = startLine === -1 ? lines.length : startLine;\n const resolvedEnd = endLine === -1 ? lines.length : endLine;\n return [\n resolvedStart, startLine === -1 || startColumn === -1 ? endOf(resolvedStart) : startColumn,\n resolvedEnd, endLine === -1 || endColumn === -1 ? endOf(resolvedEnd) : endColumn,\n ];\n }\n\n // {§zero-width-column-one-insert} — the fence artifact repaired where a fenced EDIT body becomes\n // inserted content: a zero-width region at column 1 inserts whole lines, so a non-empty body that\n // does not end in a newline gains the content's separator. Every other body is returned verbatim.\n static wholeLineBody(content: string, marker: LineMarker, body: string): string {\n const [startLine, startColumn, endLine, endColumn] = marker.marks;\n const zeroWidthAtColumnOne = marker.marks.length === 4\n && startLine === endLine && startColumn === 1 && endColumn === 1;\n if (!zeroWidthAtColumnOne || body.length === 0 || /[\\r\\n]$/.test(body)) return body;\n return `${body}${Slicer.#preferredSeparator(content, TextCoordinates.lines(content))}`;\n }\n\n static #preferredSeparator(content: string, lines: readonly TextLine[]): string {\n return lines.find(({ separator }) => separator.length > 0)?.separator\n ?? (content.includes(\"\\r\\n\") ? \"\\r\\n\" : content.includes(\"\\r\") ? \"\\r\" : \"\\n\");\n }\n\n static #lineTextReplacement(\n content: string,\n marker: LineMarker,\n body: string,\n logicalLines?: readonly TextLine[],\n ): TextReplacement | ScopeError {\n const lines = logicalLines ?? TextCoordinates.logicalLines(content);\n // {§op-shapes}: position 1 is writable without inventing a readable line.\n if (lines.length === 0 && marker.marks.length === 1 && marker.marks[0] === 1) {\n return { start: 0, end: 0, body, startLine: 1, endLine: 1 };\n }\n const norm = Slicer.#normalize(marker, lines.length, \"line\");\n if (\"error\" in norm) return norm;\n const separator = Slicer.#preferredSeparator(content, lines);\n if (norm.kind === \"before-first\") {\n const inserted = body.length > 0 && content.length > 0 && !/[\\r\\n]$/.test(body)\n ? `${body}${separator}`\n : body;\n return { start: 0, end: 0, body: inserted, startLine: 1, endLine: 1 };\n }\n if (norm.kind === \"after-last\") {\n const stripped = content.length > 0 && !/[\\r\\n]$/.test(content)\n ? body.replace(/(?:\\r\\n|\\r|\\n)$/, \"\")\n : body;\n const prefix = stripped.length > 0 && content.length > 0 && !/[\\r\\n]$/.test(content) && !/^[\\r\\n]/.test(stripped)\n ? separator\n : \"\";\n const suffix = stripped.length > 0 && /[\\r\\n]$/.test(content) && !/[\\r\\n]$/.test(stripped)\n ? separator\n : \"\";\n return {\n start: content.length,\n end: content.length,\n body: `${prefix}${stripped}${suffix}`,\n startLine: Math.max(lines.length, 1),\n endLine: Math.max(lines.length, 1),\n };\n }\n const first = lines[norm.start - 1];\n const last = lines[norm.end - 1];\n if (first === undefined || last === undefined) {\n if (lines.length === 0 && norm.start === 1 && norm.end === 0) {\n return { start: 0, end: 0, body, startLine: 1, endLine: 1 };\n }\n return { error: `Line range ${norm.start},${norm.end} cannot be resolved.` };\n }\n const inserted = body.length > 0 && last.separator.length > 0 && !/[\\r\\n]$/.test(body)\n ? `${body}${last.separator}`\n : body;\n return {\n start: first.start,\n end: last.end,\n body: inserted,\n startLine: norm.start,\n endLine: norm.end,\n };\n }\n\n static textReplacement(\n content: string,\n marker: LineMarker,\n body: string,\n cache?: { readonly coords: TextCoordinates; readonly lines: readonly TextLine[]; readonly logicalLines: readonly TextLine[] },\n ): TextReplacement | ScopeError {\n if (marker.marks.length === 3) {\n const expanded = Slicer.#expandRegion3(content, marker, cache?.lines);\n if (\"error\" in expanded) return expanded;\n const replacement = Slicer.#exactTextReplacement(content, expanded.marker, body, cache);\n return \"error\" in replacement\n ? replacement\n : { ...replacement, normalization: expanded.normalization };\n }\n if (marker.marks.length === 4) {\n return Slicer.#exactTextReplacement(content, marker, body, cache);\n }\n if (marker.marks.length === 1 || marker.marks.length === 2) {\n return Slicer.#lineTextReplacement(content, marker, body, cache?.logicalLines);\n }\n return {\n error: `Text regions require one, two, or four coordinates; received ${marker.marks.length}.`,\n };\n }\n\n static #expandRegion3(\n content: string,\n marker: LineMarker,\n cachedLines?: readonly TextLine[],\n ): { marker: LineMarker; normalization: ScopeNormalization } | { error: string } {\n const [startLine, startColumn, requestedEndLine] = marker.marks;\n if (![startLine, startColumn, requestedEndLine].every(Number.isSafeInteger)) {\n return { error: \"A tolerated three-coordinate text region requires integer coordinates.\" };\n }\n const lines = cachedLines ?? TextCoordinates.lines(content);\n const endLine = requestedEndLine === -1 ? lines.length : requestedEndLine;\n if (endLine < 1) {\n return { error: `End line ${endLine} is outside the available line range 1..${lines.length}.` };\n }\n const resolvedEndLine = Math.min(endLine, lines.length);\n const last = lines[resolvedEndLine - 1];\n if (last === undefined) {\n return { error: `End line ${endLine} cannot select from empty content.` };\n }\n const endColumn = Array.from(content.slice(last.start, last.contentEnd)).length + 1;\n const requested: ScopeNormalization[\"requested\"] = [startLine, startColumn, requestedEndLine];\n const canonical: ScopeNormalization[\"canonical\"] = [startLine, startColumn, resolvedEndLine, endColumn];\n return {\n marker: { ...marker, marks: [...canonical] },\n normalization: { requested, canonical },\n };\n }\n\n // {§slicer-text-algebra} A two-coordinate range never starts at 0. The refusal says so in the\n // range's unit; a line range's recovery shows the working line forms, never a range rebuilt\n // from the refused one ({§diagnostic-observation}).\n static #zeroStart(last: number, unit: RangeUnit): ScopeError {\n if (unit !== \"line\") {\n return { error: `Range \"0,${last}\" starts at 0; ${unit} positions are numbered from 1.` };\n }\n return {\n error: `Range \"0,${last}\" starts at 0, which is not a line; lines are numbered from 1 and 0 is only the \"0\" prepend position.`,\n recovery: '\"L,M\" selects lines L through M; \"0\" prepends and \"-1\" appends without replacing anything.',\n };\n }\n\n static #normalize(marker: LineMarker, totalLines: number, unit: RangeUnit): NormalizedMarker | ScopeError {\n // {§diagnostic-observation} — a window over another unit (a resource's bytes) names that unit.\n const noun = unit === \"matchLocation\" ? \"match location\" : unit;\n const Noun = `${noun[0].toUpperCase()}${noun.slice(1)}`;\n // {§slicer-text-algebra} The parser carries raw `marks: [number, ...]`;\n // this owner assigns roles: marks[0] = first/position, marks[1] = last\n // (range end). A single mark is a position/sentinel; two is a range.\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return { error: `A positional range requires one or two coordinates; received ${marker.marks.length}.` };\n }\n const first = marker.marks[0];\n const last = marker.marks.length > 1 ? marker.marks[1] : null;\n if (!Number.isInteger(first) || (last !== null && !Number.isInteger(last))) {\n return { error: `${Noun} scopes require integer coordinates.` };\n }\n if (last === null) {\n if (first === 0) return { kind: \"before-first\", start: 0, end: 0 };\n if (first === -1) return { kind: \"after-last\", start: totalLines, end: totalLines };\n if (first > 0 && first <= totalLines) return { kind: \"range\", start: first, end: first };\n return {\n error: totalLines === 0\n ? `${Noun} ${first} cannot select from empty content.`\n : `${Noun} ${first} is outside the available ${noun} range 1..${totalLines}.`,\n };\n }\n if (first === 0) return Slicer.#zeroStart(last, unit);\n // Whole-content `<1,-1>` is valid even on empty content — it selects the entire,\n // possibly-empty range ({§op-shapes}). start>end here yields an empty\n // slice for READ and a full replacement for EDIT.\n if (totalLines === 0) {\n if (first === 1 && (last === -1 || last > 0)) {\n return { kind: \"range\", start: 1, end: 0 };\n }\n return { error: `Range ${first},${last} cannot select from empty content.` };\n }\n const n = first;\n let m = last;\n if (m === -1 || m > totalLines) m = totalLines;\n // {§op-shapes} — -1 is the only position counted from the end; a `<-N,-1>` start is\n // refused with the line extent, never rebuilt into a tail ({§diagnostic-observation}).\n if (n < -1 && last === -1) {\n return {\n error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.`,\n recovery: `-1 is the only position counted from the end; ${noun}s run 1..${totalLines}.`,\n };\n }\n if (n < 1 || n > totalLines) return { error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.` };\n if (m < 1) return { error: `Range end ${last} is outside the available ${noun} range 1..${totalLines}.` };\n if (n > m) return { error: `Range start ${first} exceeds end ${last}.` };\n return { kind: \"range\", start: n, end: m };\n }\n\n // READ a line range. Returns the raw selected lines (no `N:` prefix)\n // plus the 1-indexed position of the first selected line. The render\n // READ projection and packet presentation add the applicable coordinate\n // prefix from `startLine`; canonical content remains unprefixed.\n //\n // Sentinel positions <0> and <-1> select no content (they're insertion\n // points, not lines) → status 200 with empty text.\n static lines(content: string, marker: LineMarker): SliceResult {\n const requestedMarker = marker;\n let normalization: ScopeNormalization | undefined;\n if (marker.marks.length === 3) {\n const expanded = Slicer.#expandRegion3(content, marker);\n if (\"error\" in expanded) return Slicer.#regionFailure(expanded.error, requestedMarker);\n marker = expanded.marker;\n normalization = expanded.normalization;\n }\n if (marker.marks.length === 4) {\n const selected = Slicer.#exactTextReplacement(content, marker, \"\");\n if (\"error\" in selected) {\n return Slicer.#regionFailure(selected.error, requestedMarker, selected.recovery);\n }\n const region = TextCoordinates.regionFromOffsets(\n content,\n selected.start,\n selected.end,\n );\n if (region === null) {\n throw new Error(\"Slicer resolved an exact replacement with no addressable TextRegion.\");\n }\n return {\n status: 200,\n text: content.slice(selected.start, selected.end),\n startLine: selected.startLine,\n region,\n ...(normalization === undefined ? {} : { scopeNormalizations: [normalization] }),\n };\n }\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return Slicer.#regionFailure(\n `Text regions require one, two, or four coordinates; received ${marker.marks.length}.`,\n marker,\n );\n }\n const lines = TextCoordinates.logicalLines(content);\n const norm = Slicer.#normalize(marker, lines.length, \"line\");\n if (\"error\" in norm) {\n return Slicer.#rangeFailure(norm.error, Slicer.#extent(marker, lines.length, \"line\"), norm.recovery);\n }\n const extent = Slicer.#extent(marker, lines.length, \"line\");\n if (norm.kind !== \"range\") {\n return {\n status: 200,\n text: \"\",\n startLine: undefined,\n range: Slicer.#projectedExtent(extent, null, null),\n };\n }\n if (lines.length === 0) {\n const region = TextCoordinates.regionFromOffsets(content, 0, 0);\n if (region === null) {\n throw new Error(\"Slicer could not address an empty text resource.\");\n }\n return {\n status: 200,\n text: \"\",\n startLine: 1,\n region,\n range: Slicer.#projectedExtent(extent, null, null),\n };\n }\n const selected = lines\n .slice(norm.start - 1, norm.end)\n .map(({ start, contentEnd }) => content.slice(start, contentEnd));\n const region = TextCoordinates.lineRegion(content, norm.start, norm.end);\n if (region === null) {\n throw new Error(\"Slicer resolved a whole-line selection with no addressable TextRegion.\");\n }\n return {\n status: 200,\n text: selected.join(\"\\n\"),\n startLine: norm.start,\n region,\n range: Slicer.#projectedExtent(extent, norm.start, norm.end),\n };\n }\n\n // `<L>` over an ordered result set uses the same positional contract as\n // READ slicing. The returned extent lets a scheme put exact recovery facts\n // in RFC 9457 Problem Details instead of emitting a bare 416.\n static page<T>(\n items: readonly T[],\n marker: LineMarker,\n options: { readonly unit?: RangeUnit } = {},\n ): PageResult<T> {\n const total = items.length;\n // {§text-region} An extent holds one or two positions; a request of any other arity is named as written.\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return Slicer.#failure(\n \"range-not-satisfiable\",\n 416,\n `Result pagination requires one position or an inclusive two-position range; received ${marker.marks.length} positions.`,\n {},\n {\n requestedPositions: marker.marks,\n stage: \"projection\",\n recovery: 'Use \"N\" or \"N,M\" to select results.',\n retryable: false,\n },\n );\n }\n const extent = Slicer.#extent(marker, total, options.unit ?? \"result\");\n const [first, last] = extent.requested;\n if (!Number.isInteger(first) || !Number.isInteger(last)) {\n return Slicer.#rangeFailure(\n `Result ranges require integer positions; the result set contains ${total} item(s).`,\n extent,\n );\n }\n if (marker.marks.length === 1) {\n if (first === 0 || first === -1) {\n return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };\n }\n // An empty result set satisfies any single position: there is nothing to page,\n // and nothing was found — a 200 with zero items, never a range error (#425 F9).\n if (total === 0 && first > 0) {\n return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };\n }\n if (first > 0 && first <= total) {\n return {\n status: 200,\n items: [items[first - 1]],\n range: Slicer.#projectedExtent(extent, first, first),\n };\n }\n return Slicer.#rangeFailure(\n `Result ${first} is out of range; available positions are 1..${total}; this scope pages ${extent.unit} items.`,\n extent,\n Slicer.#pageRecovery(total),\n );\n }\n if (first === 0) {\n const zero = Slicer.#zeroStart(last, options.unit ?? \"result\");\n return Slicer.#rangeFailure(zero.error, extent, zero.recovery);\n }\n if (total === 0) {\n // Any well-formed range over an empty result set selects nothing: the answer is\n // \"no matches\", a 200 with zero items. Only an inverted range is unsatisfiable.\n if (first >= 1 && (last === -1 || last >= first)) {\n return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };\n }\n return Slicer.#rangeFailure(\n `Result range ${first},${last} is inverted; a range runs from a lower position to a higher one.`,\n extent,\n );\n }\n const n = first;\n const m = last === -1 ? total : Math.min(last, total);\n if (n < 1 || n > total) return Slicer.#rangeFailure(\n `Result range start ${first} is out of range; available positions are 1..${total}; this scope pages ${extent.unit} items.`,\n extent,\n Slicer.#pageRecovery(total),\n );\n if (m < 1) return Slicer.#rangeFailure(\n `Result range end ${last} is out of range; available positions are 1..${total}.`,\n extent,\n );\n if (n > m) return Slicer.#rangeFailure(\n `Result range start ${first} exceeds end ${last}.`,\n extent,\n );\n return {\n status: 200,\n items: items.slice(n - 1, m),\n range: Slicer.#projectedExtent(extent, n, m),\n };\n }\n\n // COPY-style raw slice. Returns the selected source bytes verbatim (no\n // line-number prefix), including any separators owned by a whole-line\n // selection.\n // Used for COPY/MOVE `<L>` per the service SPEC (COPY/MOVE source-range, symmetric\n // with READ but without the READ-output prefix that's a render concern,\n // not a data concern).\n static linesRaw(content: string, marker: LineMarker): SliceResult {\n const selected = Slicer.textReplacement(content, marker, \"\");\n if (\"error\" in selected) {\n return marker.marks.length !== 1 && marker.marks.length !== 2\n ? Slicer.#regionFailure(selected.error, marker, selected.recovery)\n : Slicer.#rangeFailure(\n selected.error,\n Slicer.#extent(marker, TextCoordinates.logicalLines(content).length, \"line\"),\n selected.recovery,\n );\n }\n return {\n status: 200,\n text: content.slice(selected.start, selected.end),\n startLine: selected.startLine,\n ...(selected.normalization === undefined\n ? {}\n : { scopeNormalizations: [selected.normalization] }),\n };\n }\n\n // EDIT applies body at the marker position:\n // <0> prepend body before line 1\n // <-1> append body after the last line\n // <N> replace line N with body\n // <N,M> replace lines N..M with body\n // <SL,SC,EL,EC> replace an exact region; equal endpoints insert\n // <1,-1> whole content (replace everything); empty body clears.\n // Empty body with <N>/<N,M> deletes those lines.\n static lineMarkerEdit(content: string, marker: LineMarker, body: string): EditResult {\n return Slicer.lineMarkerEditBatch(content, [{ marker, body }]);\n }\n\n static lineMarkerEditBatch(content: string, edits: readonly BatchEdit[]): EditResult {\n const coords = new TextCoordinates(content);\n const cache = { coords, lines: TextCoordinates.lines(content), logicalLines: coords.logicalLines() };\n const replacements: Array<TextReplacement & { readonly marker: LineMarker }> = [];\n for (const edit of edits) {\n const replacement = Slicer.textReplacement(content, edit.marker, edit.body, cache);\n if (\"error\" in replacement) {\n return edit.marker.marks.length !== 1 && edit.marker.marks.length !== 2\n ? Slicer.#regionFailure(replacement.error, edit.marker, replacement.recovery)\n : Slicer.#rangeFailure(\n replacement.error,\n Slicer.#extent(edit.marker, cache.logicalLines.length, \"line\"),\n replacement.recovery,\n );\n }\n replacements.push({ ...replacement, marker: edit.marker });\n }\n if (replacements.length > 1 && replacements.some(({ start, end }) =>\n start === 0 && end === content.length && start !== end)) {\n return Slicer.#failure(\n \"overlapping-edits\",\n 409,\n \"A whole-resource replacement cannot coexist with another edit.\",\n {},\n {\n stage: \"mutation\",\n editCount: replacements.length,\n recovery: \"Submit the whole-resource replacement by itself.\",\n retryable: false,\n },\n );\n }\n // {§op-methods-op-dispatch} — evidence-gated resolutions before the conflict check, each\n // reported on its row: an identical twin is applied once; two insertions at one point\n // land in authored order; a one-line shared endpoint goes to the body that reproduces\n // that line (the other region shrinks by one). Everything else stays a refusal.\n const indexed = replacements.map((replacement, index) => ({ ...replacement, index }));\n const merges: EditMerge[] = [];\n const dropped = new Set<number>();\n const lines = TextCoordinates.logicalLines(content);\n const lineText = (line: number): string => { const l = lines[line - 1]; return l === undefined ? \"\" : content.slice(l.start, l.contentEnd); };\n const bodyLines = (body: string): Set<string> => new Set(body.split(\"\\n\").map((l) => l.trim()).filter((l) => l.length > 0));\n // A twin is the same edit even when it differs by trailing whitespace or trailing newlines.\n const shape = (body: string): string => body.split(\"\\n\").map((l) => l.trimEnd()).join(\"\\n\").replace(/\\n+$/, \"\");\n for (let i = 0; i < indexed.length; i += 1) {\n for (let j = i + 1; j < indexed.length; j += 1) {\n if (dropped.has(i) || dropped.has(j)) continue;\n const a = indexed[i], b = indexed[j];\n if (a.start === b.start && a.end === b.end && shape(a.body) === shape(b.body)) {\n dropped.add(j); merges.push({ index: j, rule: \"duplicate-of\", of: i, ...(a.body === b.body ? {} : { whitespaceOnly: true as const }) }); continue;\n }\n const aInsertion = a.start === a.end, bInsertion = b.start === b.end;\n if (aInsertion && bInsertion && a.start === b.start) {\n merges.push({ index: j, rule: \"same-insertion-point\", after: i }); continue;\n }\n if (aInsertion || bInsertion || a.marker.marks.length > 2 || b.marker.marks.length > 2) continue;\n // one region inside another: the inner change relocates into the outer body when the\n // inner region's original lines occur there exactly once; an outer body that already\n // carries the inner body makes the inner redundant. Anything else stays a refusal.\n const containsLines = (outerR: typeof a, innerR: typeof a): boolean =>\n outerR.startLine <= innerR.startLine && innerR.endLine <= outerR.endLine\n && !(outerR.startLine === innerR.startLine && outerR.endLine === innerR.endLine);\n if (containsLines(a, b) || containsLines(b, a)) {\n const outer = containsLines(a, b) ? a : b; const inner = outer === a ? b : a;\n const split = (body: string): string[] => { const rows = body.split(\"\\n\"); if (rows.length > 1 && rows.at(-1) === \"\") rows.pop(); return rows.map((r) => r.trimEnd()); };\n const outerRows = split(outer.body);\n const innerOriginal: string[] = []; for (let l = inner.startLine; l <= inner.endLine; l += 1) innerOriginal.push(lineText(l).trimEnd());\n const occurrences = (block: string[]): number[] => { const at: number[] = []; if (block.length === 0) return at; for (let k = 0; k + block.length <= outerRows.length; k += 1) { if (block.every((row, o) => outerRows[k + o] === row)) at.push(k); } return at; };\n const originalAt = occurrences(innerOriginal);\n if (originalAt.length === 1) {\n const k = originalAt[0]; const innerRows = inner.body.length === 0 ? [] : split(inner.body);\n const composed = [...outerRows.slice(0, k), ...innerRows, ...outerRows.slice(k + innerOriginal.length)].join(\"\\n\") + (outer.body.endsWith(\"\\n\") ? \"\\n\" : \"\");\n indexed[outer.index] = { ...indexed[outer.index], body: composed };\n dropped.add(inner.index);\n merges.push({ index: inner.index, rule: \"contained-relocated\", outer: outer.index, at: k + 1, authored: [...inner.marker.marks], originalLines: innerOriginal.length });\n continue;\n }\n if (originalAt.length === 0 && inner.body.length > 0 && occurrences(split(inner.body)).length === 1) {\n dropped.add(inner.index);\n merges.push({ index: inner.index, rule: \"contained-already-applied\", outer: outer.index });\n continue;\n }\n continue;\n }\n // one shared endpoint line between two whole-line regions\n const [lo, hi] = a.startLine <= b.startLine ? [a, b] : [b, a];\n if (lo.endLine !== hi.startLine || lo.startLine === lo.endLine || hi.startLine === hi.endLine) continue;\n const line = lo.endLine; const text = lineText(line).trim();\n if (text.length === 0) continue;\n const loHas = bodyLines(lo.body).has(text), hiHas = bodyLines(hi.body).has(text);\n if (loHas === hiHas) continue;\n const keeper = loHas ? lo : hi; const shrunk = loHas ? hi : lo;\n const shrunkStartLine = shrunk === lo ? shrunk.startLine : shrunk.startLine + 1;\n const shrunkEndLine = shrunk === lo ? shrunk.endLine - 1 : shrunk.endLine;\n const narrowed = Slicer.textReplacement(content, { marks: [shrunkStartLine, shrunkEndLine] }, shrunk.body);\n if (\"error\" in narrowed) continue;\n const target = indexed[shrunk.index];\n indexed[shrunk.index] = { ...target, start: narrowed.start, end: narrowed.end, startLine: narrowed.startLine, endLine: narrowed.endLine, marker: { marks: [shrunkStartLine, shrunkEndLine] } };\n merges.push({ index: shrunk.index, rule: \"shared-endpoint\", line, text, authored: [...shrunk.marker.marks], applied: [shrunkStartLine, shrunkEndLine], claimedBy: keeper.index });\n }\n }\n const live = indexed.filter(({ index }) => !dropped.has(index));\n // {§op-methods-op-dispatch} — the whole conflict graph in one receipt: every conflicting\n // pair with its relation, and the regions that were clean, so the model knows exactly\n // what to change and that nothing was applied (#428).\n const conflicts: Array<{ regions: [readonly (number | string)[], readonly (number | string)[]]; relation: string; line?: number; text?: string }> = [];\n const conflicted = new Set<number>();\n for (let i = 0; i < live.length; i += 1) {\n for (let j = i + 1; j < live.length; j += 1) {\n const a = live[i];\n const b = live[j];\n const aInsertion = a.start === a.end;\n const bInsertion = b.start === b.end;\n const overlaps = aInsertion && bInsertion\n ? false\n : aInsertion\n ? a.start > b.start && a.start < b.end\n : bInsertion\n ? b.start > a.start && b.start < a.end\n : a.start < b.end && b.start < a.end;\n if (!overlaps) continue;\n const [lo, hi] = a.startLine <= b.startLine ? [a, b] : [b, a];\n const sharedEndpoint = !aInsertion && !bInsertion && lo.endLine === hi.startLine && lo.startLine !== lo.endLine && hi.startLine !== hi.endLine;\n const relation = a.start === b.start && a.end === b.end ? \"duplicate\"\n : sharedEndpoint ? \"shared endpoint\"\n : (a.start <= b.start && b.end <= a.end) || (b.start <= a.start && a.end <= b.end) ? \"one contains the other\"\n : \"overlap\";\n conflicts.push({ regions: [a.marker.marks, b.marker.marks], relation, ...(sharedEndpoint ? { line: lo.endLine, text: lineText(lo.endLine) } : {}) });\n conflicted.add(i); conflicted.add(j);\n }\n }\n if (conflicts.length > 0) {\n const clean = live.flatMap((r, index) => conflicted.has(index) ? [] : [r.marker.marks]);\n const shared = conflicts.filter((c) => c.relation === \"shared endpoint\");\n const guidance = shared.map((c) => `\\`\"SL,EL\"\\` is inclusive: line ${c.line} (${JSON.stringify(c.text)}) is claimed by both \"${c.regions[0].join(\",\")}\" and \"${c.regions[1].join(\",\")}\" and neither body reproduces it.`);\n return Slicer.#failure(\n \"overlapping-edits\",\n 409,\n \"Two edit regions overlap.\",\n {},\n {\n stage: \"mutation\",\n conflictingRegions: conflicts[0].regions,\n conflicts,\n cleanRegions: clean,\n editCount: replacements.length,\n applied: 0,\n recovery: `${conflicts.length} conflicting pair${conflicts.length === 1 ? \"\" : \"s\"} (${[...new Set(conflicts.map((c) => c.relation))].join(\", \")}); ${clean.length} of ${replacements.length} regions are clean; 0 of ${replacements.length} were applied. ${guidance.length > 0 ? guidance.join(\" \") : \"Submit non-overlapping edit regions.\"}`,\n retryable: false,\n },\n );\n }\n let result = content;\n // Bottom-up; two insertions at one point apply later-authored first so authored order is\n // what lands.\n for (const replacement of live.toSorted((a, b) => b.start - a.start || b.end - a.end || b.index - a.index)) {\n result = `${result.slice(0, replacement.start)}${replacement.body}${result.slice(replacement.end)}`;\n }\n const scopeNormalizations = live.flatMap(({ normalization }) =>\n normalization === undefined ? [] : [normalization]);\n const applied: BatchEdit[] = live.map((r) => ({ marker: r.marker, body: r.body }));\n return {\n status: 200,\n result,\n ...(scopeNormalizations.length === 0 ? {} : { scopeNormalizations }),\n ...(merges.length === 0 ? {} : { merges, applied }),\n };\n }\n\n}\n"]}
1
+ {"version":3,"file":"Slicer.js","sourceRoot":"","sources":["../src/Slicer.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,kDAAkD;AAClD,oDAAoD;AACpD,2HAA2H;AAC3H,8DAA8D;AAC9D,oGAAoG;AACpG,iFAAiF;AACjF,oGAAoG;AACpG,uEAAuE;AACvE,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,EAAE;AACF,oFAAoF;AACpF,+FAA+F;AAC/F,uEAAuE;AAGvE,OAAO,EAAE,eAAe,EAAiB,MAAM,0BAA0B,CAAC;AAC1E,OAAO,OAAO,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GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACzG,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;QACxG,CAAC;QACD,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAC3D,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;QACxD,MAAM,OAAO,GAAgB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,OAAO;YACH,MAAM,EAAE,GAAG;YACX,MAAM;YACN,GAAG,CAAC,mBAAmB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC;YACpE,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;SACtD,CAAC;IACN,CAAC;CAEJ","sourcesContent":["// {§slicer-text-algebra} Line-marker range semantics:\n//\n// \"N\" selects position N (1-indexed)\n// \"N,M\" selects positions N..M inclusive\n// \"-K,-M\" projection-only end-relative range (`-1` is the last position, `-K` is `total + 1 - K`, clamped to `1`)\n// \"0\" sentinel: before position 1 (EDIT prepend)\n// \"-1\" sentinel: after the last position (EDIT append; empty on single-mark projection)\n// \"1,-1\" every position (in range context, -1 normalizes to last line)\n// \"1,1,-1,1\" the whole text; -1 as a region line is the content's end, so \"-1,1,-1,1\" appends\n// \"SL,SC,EL,EC\" selects an exact text region with an exclusive end.\n//\n// Runtime tolerance (not canonical producer syntax): \"SL,SC,EL\" is accepted\n// as \"SL,SC\" through the end of line EL and lowered immediately to four\n// coordinates. Successful results carry the exact normalization evidence.\n//\n// On mutation, N and M are positive integers with 0 and -1 as the defined sentinels\n// (other negatives fail 416). On two-coordinate projections (`lines()`, `window()`, `page()`),\n// negative endpoints count backward from the end (`total + 1 + mark`).\n\nimport type { LineMarker, RangeExtent, TextRegion } from \"@plurnk/plurnk-contracts\";\nimport { TextCoordinates, type TextLine } from \"@plurnk/plurnk-mimetypes\";\nimport Results, { type SchemeResult, type ScopeNormalization } from \"./Results.ts\";\n\nexport interface ScopeError {\n readonly error: string;\n readonly recovery?: string;\n}\ninterface NormalizedMarker {\n kind: \"range\" | \"before-first\" | \"after-last\";\n start: number;\n end: number;\n}\n\nexport interface TextReplacement {\n readonly start: number;\n readonly end: number;\n readonly body: string;\n readonly startLine: number;\n readonly endLine: number;\n readonly normalization?: ScopeNormalization;\n}\n\nexport type RangeUnit = RangeExtent[\"unit\"];\nexport interface SliceResult extends SchemeResult {\n text?: string;\n startLine?: number;\n region?: TextRegion;\n range?: RangeExtent;\n}\nexport interface PageResult<T> extends SchemeResult { items?: T[]; range?: RangeExtent }\n// {§op-methods-op-dispatch} — an evidence-gated resolution of two authored regions, reported on the\n// row it changed so the model can verify or undo it; `index` is the position in the batch.\ntype EditMerge =\n | { readonly index: number; readonly rule: \"duplicate-of\"; readonly of: number; readonly whitespaceOnly?: true }\n | { readonly index: number; readonly rule: \"shared-endpoint\"; readonly line: number; readonly text: string; readonly authored: readonly number[]; readonly applied: readonly number[]; readonly claimedBy: number }\n | { readonly index: number; readonly rule: \"same-insertion-point\"; readonly after: number }\n | { readonly index: number; readonly rule: \"contained-relocated\"; readonly outer: number; readonly at: number; readonly authored: readonly number[]; readonly originalLines: number }\n | { readonly index: number; readonly rule: \"contained-already-applied\"; readonly outer: number };\nexport interface EditResult extends SchemeResult {\n result?: string;\n range?: RangeExtent;\n merges?: readonly EditMerge[];\n // The edits as applied, in authored order with dropped duplicates omitted; receipts are\n // built from these, and a dropped row carries its merge fact instead of an effect.\n applied?: readonly BatchEdit[];\n}\nexport interface BatchEdit {\n readonly marker: LineMarker;\n readonly body: string;\n}\nexport interface WindowResult extends SchemeResult {\n start?: number | null;\n end?: number | null;\n range?: RangeExtent;\n}\n\nexport default class Slicer {\n // {§slicer-text-algebra} Projection tolerance is separate from the strict mutation algebra.\n static readScope(marker: LineMarker): ScopeNormalization | undefined {\n const [first, last] = marker.marks;\n return marker.marks.length === 2 && first === 0 && Number.isSafeInteger(last) && (last === -1 || last > 0)\n ? { requested: [0, last], canonical: [1, last] }\n : undefined;\n }\n\n static #failure(\n code: string,\n status: number,\n detail: string,\n fields: Readonly<Record<string, unknown>> = {},\n extensions: Readonly<Record<string, unknown>> = {},\n ): SchemeResult {\n return Results.failure(\"schemes:slicer\", code, status, detail, fields, extensions);\n }\n\n static #rangeFailure(\n detail: string,\n range: RangeExtent,\n recovery = \"Choose a range within the available extent.\",\n ): SchemeResult {\n return Slicer.#failure(\n \"range-not-satisfiable\",\n 416,\n detail,\n { range },\n {\n range,\n stage: \"projection\",\n recovery,\n retryable: false,\n },\n );\n }\n\n // A result position outside the page: the recovery states the positions the page holds and\n // names no other operation ({§diagnostic-observation}).\n static #pageRecovery(total: number): string {\n return `Choose positions within 1..${total}.`;\n }\n\n static #regionFailure(\n detail: string,\n marker: LineMarker,\n recovery = \"Choose a region within the available text.\",\n ): SchemeResult {\n return Slicer.#failure(\n \"range-not-satisfiable\",\n 416,\n detail,\n {},\n {\n requestedCoordinates: marker.marks,\n columnKind: \"unicodeCodePoints\",\n stage: \"projection\",\n recovery,\n retryable: false,\n },\n );\n }\n\n static #extent(marker: LineMarker, total: number, unit: RangeUnit): RangeExtent {\n const first = marker.marks[0];\n return {\n unit,\n total,\n requested: [first, marker.marks[1] ?? first],\n };\n }\n\n static #projectedExtent(\n extent: RangeExtent,\n first: number | null,\n last: number | null,\n ): RangeExtent {\n return first === null || last === null\n ? extent\n : { ...extent, returned: [first, last] };\n }\n\n static coversAvailable(range: RangeExtent): boolean {\n return range.total === 0\n || (range.returned?.[0] === 1 && range.returned[1] === range.total);\n }\n // {§slicer-text-algebra} — the positional contract of `lines()` over any 1-based unit whose content\n // is not text in memory (a resource's bytes): the same normalization, extents, sentinels, and\n // 416s, resolved against a total alone. A null start is a sentinel selection of nothing.\n static window(marker: LineMarker, total: number, unit: RangeUnit): WindowResult {\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return Slicer.#regionFailure(\n `Positional windows take one or two coordinates; received ${marker.marks.length}.`,\n marker,\n );\n }\n const norm = Slicer.#normalize(marker, total, unit, true);\n const extent = Slicer.#extent(marker, total, unit);\n if (\"error\" in norm) return Slicer.#rangeFailure(norm.error, extent, norm.recovery);\n if (norm.kind !== \"range\" || norm.start > norm.end) {\n return { status: 200, start: null, end: null, range: Slicer.#projectedExtent(extent, null, null) };\n }\n return { status: 200, start: norm.start, end: norm.end, range: Slicer.#projectedExtent(extent, norm.start, norm.end) };\n }\n\n static #exactTextReplacement(\n content: string,\n marker: LineMarker,\n body: string,\n cache?: { readonly coords: TextCoordinates; readonly lines: readonly TextLine[] },\n ): TextReplacement | ScopeError {\n if (marker.marks.length !== 4 || !marker.marks.every(Number.isSafeInteger)) {\n return { error: \"An exact text region requires four integer coordinates.\" };\n }\n const resolved = Slicer.#exactRegion(content, marker, body, cache);\n // {§op-shapes} — lines and columns count from 1; a refused region holding a zero\n // says so as read and is never rebuilt into another region ({§diagnostic-observation}).\n if (!(\"error\" in resolved) || !marker.marks.includes(0)) return resolved;\n return { error: resolved.error, recovery: \"Lines and columns count from 1.\" };\n }\n\n static #exactRegion(\n content: string,\n marker: LineMarker,\n body: string,\n cache?: { readonly coords: TextCoordinates; readonly lines: readonly TextLine[] },\n ): TextReplacement | ScopeError {\n const lines = cache?.lines ?? TextCoordinates.lines(content);\n const coords = cache?.coords ?? new TextCoordinates(content);\n // {§op-shapes} — `-1` is the final addressable endpoint in every form: as a region line it\n // is the end of the content, so `<1,1,-1,1>` is the whole text and `<-1,1,-1,1>` appends; as a column\n // it is the end of its line, so `<3,1,3,-1>` is line 3 to its end and `<3,-1,3,-1>` appends to it.\n if (!Slicer.#fourMarks(marker.marks)) return { error: \"A region names four marks: start line, start column, end line, end column.\" };\n const [startLine, startColumn, endLine, rawEndColumn] = Slicer.#finalEndpoint(content, lines, marker.marks);\n if (startLine < 1 || startLine > lines.length) {\n return { error: `Start line ${startLine} is outside the available line range 1..${lines.length}.` };\n }\n if (endLine < 1) {\n return { error: `End line ${endLine} is outside the available line range 1..${lines.length}.` };\n }\n if (rawEndColumn < 1) {\n return { error: `End column ${rawEndColumn} must be positive.` };\n }\n const pastEof = endLine > lines.length;\n const resolvedEndLine = pastEof ? lines.length : endLine;\n const endLineData = lines[resolvedEndLine - 1];\n const maxEndColumn = Array.from(content.slice(endLineData.start, endLineData.contentEnd)).length + 1;\n const endColumn = pastEof ? maxEndColumn : Math.min(rawEndColumn, maxEndColumn);\n let start: number;\n let end: number;\n try {\n start = coords.offsetAtPosition(startLine, startColumn);\n end = coords.offsetAtPosition(resolvedEndLine, endColumn);\n } catch (cause) {\n return { error: cause instanceof Error ? cause.message : String(cause) };\n }\n if (end < start) {\n return {\n error: `Exact region ${startLine},${startColumn},${endLine},${rawEndColumn} ends before it starts.`,\n recovery: 'An exact region names its earlier position first: \"SL,SC,EL,EC\".',\n };\n }\n return { start, end, body, startLine, endLine: resolvedEndLine };\n }\n\n // The four marks a region names, as the marker's tuple type cannot say.\n static #fourMarks(marks: readonly number[]): marks is readonly [number, number, number, number] {\n return marks.length === 4;\n }\n\n static #finalEndpoint(content: string, lines: readonly TextLine[], marks: readonly [number, number, number, number]): [number, number, number, number] {\n const [startLine, startColumn, endLine, endColumn] = marks;\n const endOf = (line: number): number => {\n const data = lines[Math.min(Math.max(line, 1), lines.length) - 1];\n return Array.from(content.slice(data.start, data.contentEnd)).length + 1;\n };\n const resolvedStart = startLine === -1 ? lines.length : startLine;\n const resolvedEnd = endLine === -1 ? lines.length : endLine;\n return [\n resolvedStart, startLine === -1 || startColumn === -1 ? endOf(resolvedStart) : startColumn,\n resolvedEnd, endLine === -1 || endColumn === -1 ? endOf(resolvedEnd) : endColumn,\n ];\n }\n\n // {§zero-width-column-one-insert} — an edit body inserted at a zero-width column-1 region inserts\n // whole lines, so a non-empty body that does not end in a newline gains the content's separator.\n // Every other body is returned verbatim.\n static wholeLineBody(content: string, marker: LineMarker, body: string): string {\n const [startLine, startColumn, endLine, endColumn] = marker.marks;\n const zeroWidthAtColumnOne = marker.marks.length === 4\n && startLine === endLine && startColumn === 1 && endColumn === 1;\n if (!zeroWidthAtColumnOne || body.length === 0 || /[\\r\\n]$/.test(body)) return body;\n return `${body}${Slicer.#preferredSeparator(content, TextCoordinates.lines(content))}`;\n }\n\n static #preferredSeparator(content: string, lines: readonly TextLine[]): string {\n return lines.find(({ separator }) => separator.length > 0)?.separator\n ?? (content.includes(\"\\r\\n\") ? \"\\r\\n\" : content.includes(\"\\r\") ? \"\\r\" : \"\\n\");\n }\n\n static #lineTextReplacement(\n content: string,\n marker: LineMarker,\n body: string,\n logicalLines?: readonly TextLine[],\n ): TextReplacement | ScopeError {\n const lines = logicalLines ?? TextCoordinates.logicalLines(content);\n // {§op-shapes}: position 1 is writable without inventing a readable line.\n if (lines.length === 0 && marker.marks.length === 1 && marker.marks[0] === 1) {\n return { start: 0, end: 0, body, startLine: 1, endLine: 1 };\n }\n const norm = Slicer.#normalize(marker, lines.length, \"line\", false);\n if (\"error\" in norm) return norm;\n const separator = Slicer.#preferredSeparator(content, lines);\n if (norm.kind === \"before-first\") {\n const inserted = body.length > 0 && content.length > 0 && !/[\\r\\n]$/.test(body)\n ? `${body}${separator}`\n : body;\n return { start: 0, end: 0, body: inserted, startLine: 1, endLine: 1 };\n }\n if (norm.kind === \"after-last\") {\n const stripped = content.length > 0 && !/[\\r\\n]$/.test(content)\n ? body.replace(/(?:\\r\\n|\\r|\\n)$/, \"\")\n : body;\n const prefix = stripped.length > 0 && content.length > 0 && !/[\\r\\n]$/.test(content) && !/^[\\r\\n]/.test(stripped)\n ? separator\n : \"\";\n const suffix = stripped.length > 0 && /[\\r\\n]$/.test(content) && !/[\\r\\n]$/.test(stripped)\n ? separator\n : \"\";\n return {\n start: content.length,\n end: content.length,\n body: `${prefix}${stripped}${suffix}`,\n startLine: Math.max(lines.length, 1),\n endLine: Math.max(lines.length, 1),\n };\n }\n const first = lines[norm.start - 1];\n const last = lines[norm.end - 1];\n if (first === undefined || last === undefined) {\n if (lines.length === 0 && norm.start === 1 && norm.end === 0) {\n return { start: 0, end: 0, body, startLine: 1, endLine: 1 };\n }\n return { error: `Line range ${norm.start},${norm.end} cannot be resolved.` };\n }\n const inserted = body.length > 0 && last.separator.length > 0 && !/[\\r\\n]$/.test(body)\n ? `${body}${last.separator}`\n : body;\n return {\n start: first.start,\n end: last.end,\n body: inserted,\n startLine: norm.start,\n endLine: norm.end,\n };\n }\n\n static textReplacement(\n content: string,\n marker: LineMarker,\n body: string,\n cache?: { readonly coords: TextCoordinates; readonly lines: readonly TextLine[]; readonly logicalLines: readonly TextLine[] },\n ): TextReplacement | ScopeError {\n if (marker.marks.length === 3) {\n const expanded = Slicer.#expandRegion3(content, marker, cache?.lines);\n if (\"error\" in expanded) return expanded;\n const replacement = Slicer.#exactTextReplacement(content, expanded.marker, body, cache);\n return \"error\" in replacement\n ? replacement\n : { ...replacement, normalization: expanded.normalization };\n }\n if (marker.marks.length === 4) {\n return Slicer.#exactTextReplacement(content, marker, body, cache);\n }\n if (marker.marks.length === 1 || marker.marks.length === 2) {\n return Slicer.#lineTextReplacement(content, marker, body, cache?.logicalLines);\n }\n return {\n error: `Text regions require one, two, or four coordinates; received ${marker.marks.length}.`,\n };\n }\n\n static #expandRegion3(\n content: string,\n marker: LineMarker,\n cachedLines?: readonly TextLine[],\n ): { marker: LineMarker; normalization: ScopeNormalization } | { error: string } {\n const [startLine, startColumn, requestedEndLine] = marker.marks;\n if (![startLine, startColumn, requestedEndLine].every(Number.isSafeInteger)) {\n return { error: \"A tolerated three-coordinate text region requires integer coordinates.\" };\n }\n const lines = cachedLines ?? TextCoordinates.lines(content);\n const endLine = requestedEndLine === -1 ? lines.length : requestedEndLine;\n if (endLine < 1) {\n return { error: `End line ${endLine} is outside the available line range 1..${lines.length}.` };\n }\n const resolvedEndLine = Math.min(endLine, lines.length);\n const last = lines[resolvedEndLine - 1];\n if (last === undefined) {\n return { error: `End line ${endLine} cannot select from empty content.` };\n }\n const endColumn = Array.from(content.slice(last.start, last.contentEnd)).length + 1;\n const requested: ScopeNormalization[\"requested\"] = [startLine, startColumn, requestedEndLine];\n const canonical: ScopeNormalization[\"canonical\"] = [startLine, startColumn, resolvedEndLine, endColumn];\n return {\n marker: { ...marker, marks: [...canonical] },\n normalization: { requested, canonical },\n };\n }\n\n // {§slicer-text-algebra} A two-coordinate range never starts at 0. The refusal says so in the\n // range's unit; a line range's recovery shows the working line forms, never a range rebuilt\n // from the refused one ({§diagnostic-observation}).\n static #zeroStart(last: number, unit: RangeUnit): ScopeError {\n if (unit !== \"line\") {\n return { error: `Range \"0,${last}\" starts at 0; ${unit} positions are numbered from 1.` };\n }\n return {\n error: `Range \"0,${last}\" starts at 0, which is not a line; lines are numbered from 1 and 0 is only the \"0\" prepend position.`,\n recovery: '\"L,M\" selects lines L through M; \"0\" prepends and \"-1\" appends without replacing anything.',\n };\n }\n\n static #normalize(marker: LineMarker, totalLines: number, unit: RangeUnit, projection = false): NormalizedMarker | ScopeError {\n // {§diagnostic-observation} — a window over another unit (a resource's bytes) names that unit.\n const noun = unit === \"matchLocation\" ? \"match location\" : unit;\n const Noun = `${noun[0].toUpperCase()}${noun.slice(1)}`;\n // {§slicer-text-algebra} The parser carries raw `marks: [number, ...]`;\n // this owner assigns roles: marks[0] = first/position, marks[1] = last\n // (range end). A single mark is a position/sentinel; two is a range.\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return { error: `A positional range requires one or two coordinates; received ${marker.marks.length}.` };\n }\n const first = marker.marks[0];\n const last = marker.marks.length > 1 ? marker.marks[1] : null;\n if (!Number.isInteger(first) || (last !== null && !Number.isInteger(last))) {\n return { error: `${Noun} scopes require integer coordinates.` };\n }\n if (last === null) {\n if (first === 0) return { kind: \"before-first\", start: 0, end: 0 };\n if (first === -1) return { kind: \"after-last\", start: totalLines, end: totalLines };\n if (first > 0 && first <= totalLines) return { kind: \"range\", start: first, end: first };\n return {\n error: totalLines === 0\n ? `${Noun} ${first} cannot select from empty content.`\n : `${Noun} ${first} is outside the available ${noun} range 1..${totalLines}.`,\n };\n }\n if (first === 0) return Slicer.#zeroStart(last, unit);\n // Whole-content `<1,-1>` (and a projection tail range `<-K,-1>` with `-K <= -1`) is valid\n // even on empty content — it selects the entire, possibly-empty range ({§op-shapes}).\n if (totalLines === 0) {\n if (first === 1 && (last === -1 || last > 0)) {\n return { kind: \"range\", start: 1, end: 0 };\n }\n if (projection && first < 0 && last < 0 && first <= last) {\n return { kind: \"range\", start: 1, end: 0 };\n }\n return { error: `Range ${first},${last} cannot select from empty content.` };\n }\n if (projection && (first < 0 || last < -1)) {\n if (first < 0 && last < 0 && first > last) {\n return { error: `Range start ${first} exceeds end ${last}.` };\n }\n const m = last < 0 ? totalLines + 1 + last : Math.min(last, totalLines);\n if (m < 1) return { error: `Range end ${last} is outside the available ${noun} range 1..${totalLines}.` };\n const n = first < 0 ? Math.max(1, totalLines + 1 + first) : first;\n if (n < 1 || n > totalLines) return { error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.` };\n if (n > m) return { error: `Range start ${first} exceeds end ${last}.` };\n return { kind: \"range\", start: n, end: m };\n }\n const n = first;\n let m = last;\n if (m === -1 || m > totalLines) m = totalLines;\n // {§op-shapes} — on mutation, -1 is the only position counted from the end.\n if (n < -1 && last === -1) {\n return {\n error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.`,\n recovery: `-1 is the only position counted from the end; ${noun}s run 1..${totalLines}.`,\n };\n }\n if (n < 1 || n > totalLines) return { error: `Range start ${first} is outside the available ${noun} range 1..${totalLines}.` };\n if (m < 1) return { error: `Range end ${last} is outside the available ${noun} range 1..${totalLines}.` };\n if (n > m) return { error: `Range start ${first} exceeds end ${last}.` };\n return { kind: \"range\", start: n, end: m };\n }\n\n // READ a line range. Returns the raw selected lines (no `N:` prefix)\n // plus the 1-indexed position of the first selected line. The render\n // READ projection and packet presentation add the applicable coordinate\n // prefix from `startLine`; canonical content remains unprefixed.\n //\n // Sentinel positions <0> and <-1> select no content (they're insertion\n // points, not lines) → status 200 with empty text.\n static lines(content: string, marker: LineMarker): SliceResult {\n const requestedMarker = marker;\n let normalization: ScopeNormalization | undefined;\n if (marker.marks.length === 3) {\n const expanded = Slicer.#expandRegion3(content, marker);\n if (\"error\" in expanded) return Slicer.#regionFailure(expanded.error, requestedMarker);\n marker = expanded.marker;\n normalization = expanded.normalization;\n }\n if (marker.marks.length === 4) {\n const selected = Slicer.#exactTextReplacement(content, marker, \"\");\n if (\"error\" in selected) {\n return Slicer.#regionFailure(selected.error, requestedMarker, selected.recovery);\n }\n const region = TextCoordinates.regionFromOffsets(\n content,\n selected.start,\n selected.end,\n );\n if (region === null) {\n throw new Error(\"Slicer resolved an exact replacement with no addressable TextRegion.\");\n }\n return {\n status: 200,\n text: content.slice(selected.start, selected.end),\n startLine: selected.startLine,\n region,\n ...(normalization === undefined ? {} : { scopeNormalizations: [normalization] }),\n };\n }\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return Slicer.#regionFailure(\n `Text regions require one, two, or four coordinates; received ${marker.marks.length}.`,\n marker,\n );\n }\n const lines = TextCoordinates.logicalLines(content);\n const norm = Slicer.#normalize(marker, lines.length, \"line\", true);\n if (\"error\" in norm) {\n return Slicer.#rangeFailure(norm.error, Slicer.#extent(marker, lines.length, \"line\"), norm.recovery);\n }\n const extent = Slicer.#extent(marker, lines.length, \"line\");\n if (norm.kind !== \"range\") {\n return {\n status: 200,\n text: \"\",\n startLine: undefined,\n range: Slicer.#projectedExtent(extent, null, null),\n };\n }\n if (lines.length === 0) {\n const region = TextCoordinates.regionFromOffsets(content, 0, 0);\n if (region === null) {\n throw new Error(\"Slicer could not address an empty text resource.\");\n }\n return {\n status: 200,\n text: \"\",\n startLine: 1,\n region,\n range: Slicer.#projectedExtent(extent, null, null),\n };\n }\n const selected = lines\n .slice(norm.start - 1, norm.end)\n .map(({ start, contentEnd }) => content.slice(start, contentEnd));\n const region = TextCoordinates.lineRegion(content, norm.start, norm.end);\n if (region === null) {\n throw new Error(\"Slicer resolved a whole-line selection with no addressable TextRegion.\");\n }\n return {\n status: 200,\n text: selected.join(\"\\n\"),\n startLine: norm.start,\n region,\n range: Slicer.#projectedExtent(extent, norm.start, norm.end),\n };\n }\n\n // `<L>` over an ordered result set uses the same positional contract as\n // READ slicing. The returned extent lets a scheme put exact recovery facts\n // in RFC 9457 Problem Details instead of emitting a bare 416.\n static page<T>(\n items: readonly T[],\n marker: LineMarker,\n options: { readonly unit?: RangeUnit } = {},\n ): PageResult<T> {\n const total = items.length;\n // {§text-region} An extent holds one or two positions; a request of any other arity is named as written.\n if (marker.marks.length !== 1 && marker.marks.length !== 2) {\n return Slicer.#failure(\n \"range-not-satisfiable\",\n 416,\n `Result pagination requires one position or an inclusive two-position range; received ${marker.marks.length} positions.`,\n {},\n {\n requestedPositions: marker.marks,\n stage: \"projection\",\n recovery: 'Use \"N\" or \"N,M\" to select results.',\n retryable: false,\n },\n );\n }\n const extent = Slicer.#extent(marker, total, options.unit ?? \"result\");\n const [first, last] = extent.requested;\n if (!Number.isInteger(first) || !Number.isInteger(last)) {\n return Slicer.#rangeFailure(\n `Result ranges require integer positions; the result set contains ${total} item(s).`,\n extent,\n );\n }\n if (marker.marks.length === 1) {\n if (first === 0 || first === -1) {\n return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };\n }\n // An empty result set satisfies any single position: there is nothing to page,\n // and nothing was found — a 200 with zero items, never a range error (#425 F9).\n if (total === 0 && first > 0) {\n return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };\n }\n if (first > 0 && first <= total) {\n return {\n status: 200,\n items: [items[first - 1]],\n range: Slicer.#projectedExtent(extent, first, first),\n };\n }\n return Slicer.#rangeFailure(\n `Result ${first} is out of range; available positions are 1..${total}; this scope pages ${extent.unit} items.`,\n extent,\n Slicer.#pageRecovery(total),\n );\n }\n if (first === 0) {\n const zero = Slicer.#zeroStart(last, options.unit ?? \"result\");\n return Slicer.#rangeFailure(zero.error, extent, zero.recovery);\n }\n if (total === 0) {\n // Any well-formed range over an empty result set selects nothing: the answer is\n // \"no matches\", a 200 with zero items. Only an inverted range is unsatisfiable.\n if ((first >= 1 && (last === -1 || last >= first)) || (first < 0 && last < 0 && first <= last)) {\n return { status: 200, items: [], range: Slicer.#projectedExtent(extent, null, null) };\n }\n return Slicer.#rangeFailure(\n `Result range ${first},${last} is inverted; a range runs from a lower position to a higher one.`,\n extent,\n );\n }\n if (first < 0 && last < 0 && first > last) {\n return Slicer.#rangeFailure(\n `Result range start ${first} exceeds end ${last}.`,\n extent,\n );\n }\n const m = last < 0 ? total + 1 + last : Math.min(last, total);\n const n = first < 0 ? Math.max(1, total + 1 + first) : first;\n if (n < 1 || n > total) return Slicer.#rangeFailure(\n `Result range start ${first} is out of range; available positions are 1..${total}; this scope pages ${extent.unit} items.`,\n extent,\n Slicer.#pageRecovery(total),\n );\n if (m < 1) return Slicer.#rangeFailure(\n `Result range end ${last} is out of range; available positions are 1..${total}.`,\n extent,\n );\n if (n > m) return Slicer.#rangeFailure(\n `Result range start ${first} exceeds end ${last}.`,\n extent,\n );\n return {\n status: 200,\n items: items.slice(n - 1, m),\n range: Slicer.#projectedExtent(extent, n, m),\n };\n }\n\n // COPY-style raw slice. Returns the selected source bytes verbatim (no\n // line-number prefix), including any separators owned by a whole-line\n // selection.\n // Used for COPY/MOVE `<L>` per the service SPEC (COPY/MOVE source-range, symmetric\n // with READ but without the READ-output prefix that's a render concern,\n // not a data concern).\n static linesRaw(content: string, marker: LineMarker): SliceResult {\n const selected = Slicer.textReplacement(content, marker, \"\");\n if (\"error\" in selected) {\n return marker.marks.length !== 1 && marker.marks.length !== 2\n ? Slicer.#regionFailure(selected.error, marker, selected.recovery)\n : Slicer.#rangeFailure(\n selected.error,\n Slicer.#extent(marker, TextCoordinates.logicalLines(content).length, \"line\"),\n selected.recovery,\n );\n }\n return {\n status: 200,\n text: content.slice(selected.start, selected.end),\n startLine: selected.startLine,\n ...(selected.normalization === undefined\n ? {}\n : { scopeNormalizations: [selected.normalization] }),\n };\n }\n\n // EDIT applies body at the marker position:\n // <0> prepend body before line 1\n // <-1> append body after the last line\n // <N> replace line N with body\n // <N,M> replace lines N..M with body\n // <SL,SC,EL,EC> replace an exact region; equal endpoints insert\n // <1,-1> whole content (replace everything); empty body clears.\n // Empty body with <N>/<N,M> deletes those lines.\n static lineMarkerEdit(content: string, marker: LineMarker, body: string): EditResult {\n return Slicer.lineMarkerEditBatch(content, [{ marker, body }]);\n }\n\n static lineMarkerEditBatch(content: string, edits: readonly BatchEdit[]): EditResult {\n const coords = new TextCoordinates(content);\n const cache = { coords, lines: TextCoordinates.lines(content), logicalLines: coords.logicalLines() };\n const replacements: Array<TextReplacement & { readonly marker: LineMarker }> = [];\n for (const edit of edits) {\n const replacement = Slicer.textReplacement(content, edit.marker, edit.body, cache);\n if (\"error\" in replacement) {\n return edit.marker.marks.length !== 1 && edit.marker.marks.length !== 2\n ? Slicer.#regionFailure(replacement.error, edit.marker, replacement.recovery)\n : Slicer.#rangeFailure(\n replacement.error,\n Slicer.#extent(edit.marker, cache.logicalLines.length, \"line\"),\n replacement.recovery,\n );\n }\n replacements.push({ ...replacement, marker: edit.marker });\n }\n if (replacements.length > 1 && replacements.some(({ start, end }) =>\n start === 0 && end === content.length && start !== end)) {\n return Slicer.#failure(\n \"overlapping-edits\",\n 409,\n \"A whole-resource replacement cannot coexist with another edit.\",\n {},\n {\n stage: \"mutation\",\n editCount: replacements.length,\n recovery: \"Submit the whole-resource replacement by itself.\",\n retryable: false,\n },\n );\n }\n // {§op-methods-op-dispatch} — evidence-gated resolutions before the conflict check, each\n // reported on its row: an identical twin is applied once; two insertions at one point\n // land in authored order; a one-line shared endpoint goes to the body that reproduces\n // that line (the other region shrinks by one). Everything else stays a refusal.\n const indexed = replacements.map((replacement, index) => ({ ...replacement, index }));\n const merges: EditMerge[] = [];\n const dropped = new Set<number>();\n const lines = TextCoordinates.logicalLines(content);\n const lineText = (line: number): string => { const l = lines[line - 1]; return l === undefined ? \"\" : content.slice(l.start, l.contentEnd); };\n const bodyLines = (body: string): Set<string> => new Set(body.split(\"\\n\").map((l) => l.trim()).filter((l) => l.length > 0));\n // A twin is the same edit even when it differs by trailing whitespace or trailing newlines.\n const shape = (body: string): string => body.split(\"\\n\").map((l) => l.trimEnd()).join(\"\\n\").replace(/\\n+$/, \"\");\n for (let i = 0; i < indexed.length; i += 1) {\n for (let j = i + 1; j < indexed.length; j += 1) {\n if (dropped.has(i) || dropped.has(j)) continue;\n const a = indexed[i], b = indexed[j];\n if (a.start === b.start && a.end === b.end && shape(a.body) === shape(b.body)) {\n dropped.add(j); merges.push({ index: j, rule: \"duplicate-of\", of: i, ...(a.body === b.body ? {} : { whitespaceOnly: true as const }) }); continue;\n }\n const aInsertion = a.start === a.end, bInsertion = b.start === b.end;\n if (aInsertion && bInsertion && a.start === b.start) {\n merges.push({ index: j, rule: \"same-insertion-point\", after: i }); continue;\n }\n if (aInsertion || bInsertion || a.marker.marks.length > 2 || b.marker.marks.length > 2) continue;\n // one region inside another: the inner change relocates into the outer body when the\n // inner region's original lines occur there exactly once; an outer body that already\n // carries the inner body makes the inner redundant. Anything else stays a refusal.\n const containsLines = (outerR: typeof a, innerR: typeof a): boolean =>\n outerR.startLine <= innerR.startLine && innerR.endLine <= outerR.endLine\n && !(outerR.startLine === innerR.startLine && outerR.endLine === innerR.endLine);\n if (containsLines(a, b) || containsLines(b, a)) {\n const outer = containsLines(a, b) ? a : b; const inner = outer === a ? b : a;\n const split = (body: string): string[] => { const rows = body.split(\"\\n\"); if (rows.length > 1 && rows.at(-1) === \"\") rows.pop(); return rows.map((r) => r.trimEnd()); };\n const outerRows = split(outer.body);\n const innerOriginal: string[] = []; for (let l = inner.startLine; l <= inner.endLine; l += 1) innerOriginal.push(lineText(l).trimEnd());\n const occurrences = (block: string[]): number[] => { const at: number[] = []; if (block.length === 0) return at; for (let k = 0; k + block.length <= outerRows.length; k += 1) { if (block.every((row, o) => outerRows[k + o] === row)) at.push(k); } return at; };\n const originalAt = occurrences(innerOriginal);\n if (originalAt.length === 1) {\n const k = originalAt[0]; const innerRows = inner.body.length === 0 ? [] : split(inner.body);\n const composed = [...outerRows.slice(0, k), ...innerRows, ...outerRows.slice(k + innerOriginal.length)].join(\"\\n\") + (outer.body.endsWith(\"\\n\") ? \"\\n\" : \"\");\n indexed[outer.index] = { ...indexed[outer.index], body: composed };\n dropped.add(inner.index);\n merges.push({ index: inner.index, rule: \"contained-relocated\", outer: outer.index, at: k + 1, authored: [...inner.marker.marks], originalLines: innerOriginal.length });\n continue;\n }\n if (originalAt.length === 0 && inner.body.length > 0 && occurrences(split(inner.body)).length === 1) {\n dropped.add(inner.index);\n merges.push({ index: inner.index, rule: \"contained-already-applied\", outer: outer.index });\n continue;\n }\n continue;\n }\n // one shared endpoint line between two whole-line regions\n const [lo, hi] = a.startLine <= b.startLine ? [a, b] : [b, a];\n if (lo.endLine !== hi.startLine || lo.startLine === lo.endLine || hi.startLine === hi.endLine) continue;\n const line = lo.endLine; const text = lineText(line).trim();\n if (text.length === 0) continue;\n const loHas = bodyLines(lo.body).has(text), hiHas = bodyLines(hi.body).has(text);\n if (loHas === hiHas) continue;\n const keeper = loHas ? lo : hi; const shrunk = loHas ? hi : lo;\n const shrunkStartLine = shrunk === lo ? shrunk.startLine : shrunk.startLine + 1;\n const shrunkEndLine = shrunk === lo ? shrunk.endLine - 1 : shrunk.endLine;\n const narrowed = Slicer.textReplacement(content, { marks: [shrunkStartLine, shrunkEndLine] }, shrunk.body);\n if (\"error\" in narrowed) continue;\n const target = indexed[shrunk.index];\n indexed[shrunk.index] = { ...target, start: narrowed.start, end: narrowed.end, startLine: narrowed.startLine, endLine: narrowed.endLine, marker: { marks: [shrunkStartLine, shrunkEndLine] } };\n merges.push({ index: shrunk.index, rule: \"shared-endpoint\", line, text, authored: [...shrunk.marker.marks], applied: [shrunkStartLine, shrunkEndLine], claimedBy: keeper.index });\n }\n }\n const live = indexed.filter(({ index }) => !dropped.has(index));\n // {§op-methods-op-dispatch} — the whole conflict graph in one receipt: every conflicting\n // pair with its relation, and the regions that were clean, so the model knows exactly\n // what to change and that nothing was applied (#428).\n const conflicts: Array<{ regions: [readonly (number | string)[], readonly (number | string)[]]; relation: string; line?: number; text?: string }> = [];\n const conflicted = new Set<number>();\n for (let i = 0; i < live.length; i += 1) {\n for (let j = i + 1; j < live.length; j += 1) {\n const a = live[i];\n const b = live[j];\n const aInsertion = a.start === a.end;\n const bInsertion = b.start === b.end;\n const overlaps = aInsertion && bInsertion\n ? false\n : aInsertion\n ? a.start > b.start && a.start < b.end\n : bInsertion\n ? b.start > a.start && b.start < a.end\n : a.start < b.end && b.start < a.end;\n if (!overlaps) continue;\n const [lo, hi] = a.startLine <= b.startLine ? [a, b] : [b, a];\n const sharedEndpoint = !aInsertion && !bInsertion && lo.endLine === hi.startLine && lo.startLine !== lo.endLine && hi.startLine !== hi.endLine;\n const relation = a.start === b.start && a.end === b.end ? \"duplicate\"\n : sharedEndpoint ? \"shared endpoint\"\n : (a.start <= b.start && b.end <= a.end) || (b.start <= a.start && a.end <= b.end) ? \"one contains the other\"\n : \"overlap\";\n conflicts.push({ regions: [a.marker.marks, b.marker.marks], relation, ...(sharedEndpoint ? { line: lo.endLine, text: lineText(lo.endLine) } : {}) });\n conflicted.add(i); conflicted.add(j);\n }\n }\n if (conflicts.length > 0) {\n const clean = live.flatMap((r, index) => conflicted.has(index) ? [] : [r.marker.marks]);\n const shared = conflicts.filter((c) => c.relation === \"shared endpoint\");\n const guidance = shared.map((c) => `\\`\"SL,EL\"\\` is inclusive: line ${c.line} (${JSON.stringify(c.text)}) is claimed by both \"${c.regions[0].join(\",\")}\" and \"${c.regions[1].join(\",\")}\" and neither body reproduces it.`);\n return Slicer.#failure(\n \"overlapping-edits\",\n 409,\n \"Two edit regions overlap.\",\n {},\n {\n stage: \"mutation\",\n conflictingRegions: conflicts[0].regions,\n conflicts,\n cleanRegions: clean,\n editCount: replacements.length,\n applied: 0,\n recovery: `${conflicts.length} conflicting pair${conflicts.length === 1 ? \"\" : \"s\"} (${[...new Set(conflicts.map((c) => c.relation))].join(\", \")}); ${clean.length} of ${replacements.length} regions are clean; 0 of ${replacements.length} were applied. ${guidance.length > 0 ? guidance.join(\" \") : \"Submit non-overlapping edit regions.\"}`,\n retryable: false,\n },\n );\n }\n let result = content;\n // Bottom-up; two insertions at one point apply later-authored first so authored order is\n // what lands.\n for (const replacement of live.toSorted((a, b) => b.start - a.start || b.end - a.end || b.index - a.index)) {\n result = `${result.slice(0, replacement.start)}${replacement.body}${result.slice(replacement.end)}`;\n }\n const scopeNormalizations = live.flatMap(({ normalization }) =>\n normalization === undefined ? [] : [normalization]);\n const applied: BatchEdit[] = live.map((r) => ({ marker: r.marker, body: r.body }));\n return {\n status: 200,\n result,\n ...(scopeNormalizations.length === 0 ? {} : { scopeNormalizations }),\n ...(merges.length === 0 ? {} : { merges, applied }),\n };\n }\n\n}\n"]}
package/dist/handler.d.ts CHANGED
@@ -30,7 +30,7 @@ export interface SchemeHandler extends ExtensionAttributionSource {
30
30
  }
31
31
  export interface RuntimeSchemeFacet {
32
32
  claims(pathname: string): boolean;
33
- readonly manifest?: Partial<Pick<SchemeManifest, "authority" | "channels" | "defaultChannel" | "writableBy">>;
33
+ readonly manifest?: Partial<Pick<SchemeManifest, "authority" | "channels" | "defaultChannel" | "writableBy" | "folderScopes">>;
34
34
  prepareRepresentation?(request: RepresentationPreparationRequest, ctx: SchemeCtx): Promise<RepresentationPreparationResult>;
35
35
  prepareFind?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;
36
36
  find?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;
@@ -42,6 +42,11 @@ export interface RuntimeSchemeFacet {
42
42
  export interface SchemeRegistrationSeam {
43
43
  registerScheme(name: string, handler: SchemeHandler): Promise<void>;
44
44
  }
45
+ export interface SchemeHandlerConstructor {
46
+ new (): SchemeHandler;
47
+ readonly manifest?: SchemeManifest;
48
+ readonly enabled?: (env?: NodeJS.ProcessEnv) => boolean;
49
+ }
45
50
  export interface ResourceTree {
46
51
  list(): Promise<readonly string[]>;
47
52
  resource(relativePath: string): ByteSource;
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EACR,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,UAAU,EACb,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,+BAA+B,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAClF,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,WAAW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../src/handler.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,gFAAgF;AAChF,mEAAmE;AACnE,sEAAsE;AACtE,6EAA6E;AAC7E,8EAA8E;AAC9E,qCAAqC;AACrC,6EAA6E;AAC7E,gFAAgF;AAChF,0DAA0D;AAC1D,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF","sourcesContent":["// The scheme BEHAVIOR contract — the typed counterpart to SchemeManifest\n// (which types a scheme's declaration). A handler implements a method per op it\n// supports, named for the lowercased op (SEND → send, FIND → find,\n// …). Log curation is deliberately absent: core routes the log's KILL\n// only to its log owner. Core owns every READ: stored schemes inherit it and\n// other readable schemes provide a scope-blind representation first. FIND may\n// still be candidate-store-specific.\n// Every method is therefore OPTIONAL — a scheme implements only its distinct\n// surface. Operation methods share `(statement, ctx) => Promise<SchemeResult>`;\n// preparation hooks deliberately receive narrower inputs.\n//\n// `implements SchemeHandler` gives a sibling compile-time checking of its op\n// signatures instead of the duck-typed `object` the engine falls back to. The\n// per-op statement types are re-exported from the barrel, so a sibling depends\n// on (and exact-pins) ONLY @plurnk/plurnk-schemes — grammar rides underneath as\n// the framework's transitive pin, not a second pin every scheme tracks by hand.\n\n// This interface contains only operations the engine delegates to one scheme.\n// COPY and MOVE are engine-owned compositions over entry capabilities and\n// editBatch, not overridable handler methods.\nimport type {\n FindStatement,\n SendStatement,\n ExecStatement,\n KillStatement,\n ParsedPath,\n} from \"@plurnk/plurnk-contracts\";\nimport type { ExtensionAttributionSource } from \"@plurnk/plurnk-meta\";\nimport type { EntryAddress, ProposalApplyRequest, ProposalApplyResult, SchemeAddressCtx, SchemeCtx } from \"./ctx.ts\";\nimport type { WebMaterializer } from \"./WebMaterialization.ts\";\nimport type { EditBatchResult, ResolvedEditStatement } from \"./edit-receipt.ts\";\nimport type { RepresentationPreparationResult, SchemeResult } from \"./Results.ts\";\nimport type { SchemeManifest, EntryCoordinate } from \"./types.ts\";\nimport type { ByteSource } from \"./ByteSource.ts\";\n\nexport interface RepresentationPreparationRequest {\n readonly target: ParsedPath;\n readonly headers: Readonly<Record<string, string>> | null;\n readonly authority: string;\n readonly pathname: string;\n}\n\nexport interface SchemeHandler extends ExtensionAttributionSource {\n // Per-instance manifest option. Every handler must expose either this or a\n // class-level `static manifest`; Manifest.of validates the resolved value at\n // registration. Per-tag executor schemes derive this instance value from\n // their runtime declaration ({§network-address}).\n readonly manifest?: SchemeManifest;\n\n // Optional process hooks under {§scheme-operation-dispatch}: readiness precedes\n // advertisement; shutdown follows dispatch drain and precedes store closure.\n // Both run once per unique handler object identity.\n ready?(): Promise<void>;\n close?(): Promise<void>;\n\n // {§scheme-operation-dispatch}: the handler that acquires and materializes web resources\n // publishes it here; the entry sink resolves it through the registry, never a package by name.\n readonly webMaterializer?: WebMaterializer;\n applyResolution?(request: ProposalApplyRequest, ctx: SchemeCtx): Promise<ProposalApplyResult>;\n\n // Resolve a client-visible address through the same pathname rules as this\n // scheme's model-facing operations. The capability-free address context\n // prevents storage access before Core binds the resource.\n // null means no resolvable resource. An expected protocol/authority refusal\n // returns its exact non-success result instead of losing it to a generic miss.\n // {§line-anchors}: READ also checks model write eligibility here;\n // resolution observes authority without mutation, acquisition, or proposals.\n resolveEntryAddress?(\n target: ParsedPath,\n ctx: SchemeAddressCtx,\n access?: \"read\" | \"write\",\n ): Promise<EntryAddress | SchemeResult | null>;\n\n // Entry-bearing schemes receive the standard resource-selection\n // implementation from the consumer. A scheme implements this hook only\n // when the requested target must be discovered or materialized before FIND\n // selects stored entries.\n prepareFind?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n // Exact-resource acquisition receives an already-resolved pathname and a\n // target stripped of channel selection. Operation-specific READ/FIND/COPY\n // intent and scope are never available. Core binds ctx capabilities to the\n // resolved owner, then owns selection and projection after readiness.\n prepareRepresentation?(\n request: RepresentationPreparationRequest,\n ctx: SchemeCtx,\n ): Promise<RepresentationPreparationResult>;\n byteSource?(address: EntryCoordinate, ctx: SchemeAddressCtx): ByteSource;\n find?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n editBatch?(statements: readonly ResolvedEditStatement[], ctx: SchemeCtx): Promise<EditBatchResult>;\n send?(statement: SendStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n exec?(statement: ExecStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n kill?(statement: KillStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n}\n\n// {§resource-tree-scheme} — what a daemon module contributes to the scheme kind: a scheme handler,\n// or a scheme facet over a runtime's own resources. The base module contract is\n// `@plurnk/plurnk-modules` ({§module-seam-slices}).\n//\n// A module-owned runtime may expose protocol resources under the same scheme name as its output\n// streams. The facet claims only its own path subtree, and there it is the scheme's whole live\n// half: every operation it implements is its own. Unclaimed coordinates retain the standard\n// executor-output behavior.\nexport interface RuntimeSchemeFacet {\n claims(pathname: string): boolean;\n // The representation of the claimed resources where it is not the executor's own output\n // contract: whether the URI authority names the resource, their channels, the one a\n // fragmentless address reads and a subscription publishes, and who may write them. `claims`\n // always sees the authority folded into the pathname.\n readonly manifest?: Partial<Pick<SchemeManifest, \"authority\" | \"channels\" | \"defaultChannel\" | \"writableBy\">>;\n prepareRepresentation?(\n request: RepresentationPreparationRequest,\n ctx: SchemeCtx,\n ): Promise<RepresentationPreparationResult>;\n prepareFind?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n find?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n editBatch?(statements: readonly ResolvedEditStatement[], ctx: SchemeCtx): Promise<EditBatchResult>;\n send?(statement: SendStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n kill?(statement: KillStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n // An operation the facet proposed is also the facet's to apply ({§http-manifest}),\n // routed by the proposal's own `target`.\n applyResolution?(request: ProposalApplyRequest, ctx: SchemeCtx): Promise<SchemeResult>;\n}\n\n// The setup slice a module uses to add one process-wide addressable scheme.\nexport interface SchemeRegistrationSeam {\n registerScheme(name: string, handler: SchemeHandler): Promise<void>;\n}\n\n// {§resource-tree-scheme} — source truth, without a storage or selection API.\nexport interface ResourceTree {\n list(): Promise<readonly string[]>;\n resource(relativePath: string): ByteSource;\n}\n\nexport interface ResourceTreeSource {\n trees(workspaceId: number): ReadonlyMap<string, ResourceTree>;\n // Translate only recognized source failures. null leaves normal missing-file\n // handling or the original unexpected exception with the host.\n refusal?(cause: unknown, address: EntryCoordinate): RepresentationPreparationResult | null;\n}\n\nexport interface ResourceTreeRegistrationSeam {\n registerResourceTreeScheme(name: string, source: ResourceTreeSource): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,gFAAgF;AAChF,mEAAmE;AACnE,sEAAsE;AACtE,6EAA6E;AAC7E,8EAA8E;AAC9E,qCAAqC;AACrC,6EAA6E;AAC7E,gFAAgF;AAChF,0DAA0D;AAC1D,EAAE;AACF,6EAA6E;AAC7E,8EAA8E;AAC9E,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF","sourcesContent":["// The scheme BEHAVIOR contract — the typed counterpart to SchemeManifest\n// (which types a scheme's declaration). A handler implements a method per op it\n// supports, named for the lowercased op (SEND → send, FIND → find,\n// …). Log curation is deliberately absent: core routes the log's KILL\n// only to its log owner. Core owns every READ: stored schemes inherit it and\n// other readable schemes provide a scope-blind representation first. FIND may\n// still be candidate-store-specific.\n// Every method is therefore OPTIONAL — a scheme implements only its distinct\n// surface. Operation methods share `(statement, ctx) => Promise<SchemeResult>`;\n// preparation hooks deliberately receive narrower inputs.\n//\n// `implements SchemeHandler` gives a sibling compile-time checking of its op\n// signatures instead of the duck-typed `object` the engine falls back to. The\n// per-op statement types are re-exported from the barrel, so a sibling depends\n// on (and exact-pins) ONLY @plurnk/plurnk-schemes — grammar rides underneath as\n// the framework's transitive pin, not a second pin every scheme tracks by hand.\n\n// This interface contains only operations the engine delegates to one scheme.\n// COPY and MOVE are engine-owned compositions over entry capabilities and\n// editBatch, not overridable handler methods.\nimport type {\n FindStatement,\n SendStatement,\n ExecStatement,\n KillStatement,\n ParsedPath,\n} from \"@plurnk/plurnk-contracts\";\nimport type { ExtensionAttributionSource } from \"@plurnk/plurnk-meta\";\nimport type { EntryAddress, ProposalApplyRequest, ProposalApplyResult, SchemeAddressCtx, SchemeCtx } from \"./ctx.ts\";\nimport type { WebMaterializer } from \"./WebMaterialization.ts\";\nimport type { EditBatchResult, ResolvedEditStatement } from \"./edit-receipt.ts\";\nimport type { RepresentationPreparationResult, SchemeResult } from \"./Results.ts\";\nimport type { SchemeManifest, EntryCoordinate } from \"./types.ts\";\nimport type { ByteSource } from \"./ByteSource.ts\";\n\nexport interface RepresentationPreparationRequest {\n readonly target: ParsedPath;\n readonly headers: Readonly<Record<string, string>> | null;\n readonly authority: string;\n readonly pathname: string;\n}\n\nexport interface SchemeHandler extends ExtensionAttributionSource {\n // Per-instance manifest option. Every handler must expose either this or a\n // class-level `static manifest`; Manifest.of validates the resolved value at\n // registration. Per-tag executor schemes derive this instance value from\n // their runtime declaration ({§network-address}).\n readonly manifest?: SchemeManifest;\n\n // Optional process hooks under {§scheme-operation-dispatch}: readiness precedes\n // advertisement; shutdown follows dispatch drain and precedes store closure.\n // Both run once per unique handler object identity.\n ready?(): Promise<void>;\n close?(): Promise<void>;\n\n // {§scheme-operation-dispatch}: the handler that acquires and materializes web resources\n // publishes it here; the entry sink resolves it through the registry, never a package by name.\n readonly webMaterializer?: WebMaterializer;\n applyResolution?(request: ProposalApplyRequest, ctx: SchemeCtx): Promise<ProposalApplyResult>;\n\n // Resolve a client-visible address through the same pathname rules as this\n // scheme's model-facing operations. The capability-free address context\n // prevents storage access before Core binds the resource.\n // null means no resolvable resource. An expected protocol/authority refusal\n // returns its exact non-success result instead of losing it to a generic miss.\n // {§line-anchors}: READ also checks model write eligibility here;\n // resolution observes authority without mutation, acquisition, or proposals.\n resolveEntryAddress?(\n target: ParsedPath,\n ctx: SchemeAddressCtx,\n access?: \"read\" | \"write\",\n ): Promise<EntryAddress | SchemeResult | null>;\n\n // Entry-bearing schemes receive the standard resource-selection\n // implementation from the consumer. A scheme implements this hook only\n // when the requested target must be discovered or materialized before FIND\n // selects stored entries.\n prepareFind?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n // Exact-resource acquisition receives an already-resolved pathname and a\n // target stripped of channel selection. Operation-specific READ/FIND/COPY\n // intent and scope are never available. Core binds ctx capabilities to the\n // resolved owner, then owns selection and projection after readiness.\n prepareRepresentation?(\n request: RepresentationPreparationRequest,\n ctx: SchemeCtx,\n ): Promise<RepresentationPreparationResult>;\n byteSource?(address: EntryCoordinate, ctx: SchemeAddressCtx): ByteSource;\n find?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n editBatch?(statements: readonly ResolvedEditStatement[], ctx: SchemeCtx): Promise<EditBatchResult>;\n send?(statement: SendStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n exec?(statement: ExecStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n kill?(statement: KillStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n}\n\n// {§resource-tree-scheme} — what a daemon module contributes to the scheme kind: a scheme handler,\n// or a scheme facet over a runtime's own resources. The base module contract is\n// `@plurnk/plurnk-modules` ({§module-seam-slices}).\n//\n// A module-owned runtime may expose protocol resources under the same scheme name as its output\n// streams. The facet claims only its own path subtree, and there it is the scheme's whole live\n// half: every operation it implements is its own. Unclaimed coordinates retain the standard\n// executor-output behavior.\nexport interface RuntimeSchemeFacet {\n claims(pathname: string): boolean;\n // The representation of the claimed resources where it is not the executor's own output\n // contract: whether the URI authority names the resource, their channels, the one a\n // fragmentless address reads and a subscription publishes, and who may write them. `claims`\n // always sees the authority folded into the pathname.\n readonly manifest?: Partial<Pick<SchemeManifest, \"authority\" | \"channels\" | \"defaultChannel\" | \"writableBy\" | \"folderScopes\">>;\n prepareRepresentation?(\n request: RepresentationPreparationRequest,\n ctx: SchemeCtx,\n ): Promise<RepresentationPreparationResult>;\n prepareFind?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n find?(statement: FindStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n editBatch?(statements: readonly ResolvedEditStatement[], ctx: SchemeCtx): Promise<EditBatchResult>;\n send?(statement: SendStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n kill?(statement: KillStatement, ctx: SchemeCtx): Promise<SchemeResult>;\n // An operation the facet proposed is also the facet's to apply ({§http-manifest}),\n // routed by the proposal's own `target`.\n applyResolution?(request: ProposalApplyRequest, ctx: SchemeCtx): Promise<SchemeResult>;\n}\n\n// The setup slice a module uses to add one process-wide addressable scheme.\nexport interface SchemeRegistrationSeam {\n registerScheme(name: string, handler: SchemeHandler): Promise<void>;\n}\n\n// {§scheme-discovery} — the exported handler constructor a scheme package exposes (`default` or\n// `plurnk.schemes[].export`). Returning `false` from `enabled` skips scheme registration.\nexport interface SchemeHandlerConstructor {\n new (): SchemeHandler;\n readonly manifest?: SchemeManifest;\n readonly enabled?: (env?: NodeJS.ProcessEnv) => boolean;\n}\n\n// {§resource-tree-scheme} — source truth, without a storage or selection API.\nexport interface ResourceTree {\n list(): Promise<readonly string[]>;\n resource(relativePath: string): ByteSource;\n}\n\nexport interface ResourceTreeSource {\n trees(workspaceId: number): ReadonlyMap<string, ResourceTree>;\n // Translate only recognized source failures. null leaves normal missing-file\n // handling or the original unexpected exception with the host.\n refusal?(cause: unknown, address: EntryCoordinate): RepresentationPreparationResult | null;\n}\n\nexport interface ResourceTreeRegistrationSeam {\n registerResourceTreeScheme(name: string, source: ResourceTreeSource): Promise<void>;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ export { MimetypeInputLimitError as ProjectionInputLimitError } from "@plurnk/pl
24
24
  export type { AppliedEditBatchReceipt, AppliedEditReceipt, EditBatchReceipt, EditBatchResult, EditEffectReceipt, EditReceipt, EditReceiptUnit, ParseIssueTransition, ResolvedEditStatement, ReviewerReplacementEditBatchReceipt, SupersededEditReceipt, } from "./edit-receipt.ts";
25
25
  export type { ChannelProducerResult, EntryResult, MatchEvidence, PassthroughResult, ProposalResult, ProblemDetails, RepresentationPreparationResult, ScopeNormalization, SchemeResult, SchemeResultBase, } from "./Results.ts";
26
26
  export type { ChannelCaps, ChannelState, TerminalChannelState, EntryCaps, EntryCatalogChannel, EntryCatalogDefaultChannel, EntryCatalogItem, EntryCatalogScope, EntryCatalogScopeGroup, EntryData, EntryEditResult, EntryFindResult, EntryOperationCaps, EntryAddress, EntryReadResult, EntryStorageReadResult, EntryStreamLifecycle, EntryStorageWriteResult, StoredEntryData, StreamSubscription, ProjectionCaps, InteractionCaps, ProjectedText, ProjectedBinary, NotifyCaps, ProposalApplyRequest, ProposalApplyResult, ProposalAware, SchemeAddressCtx, SchemeCtx, ResourceCaps, MessageCaps, SubscriptionCaps, SubscriptionHandle, } from "./ctx.ts";
27
- export type { RepresentationPreparationRequest, ResourceTree, ResourceTreeRegistrationSeam, ResourceTreeSource, RuntimeSchemeFacet, SchemeHandler, SchemeRegistrationSeam, } from "./handler.ts";
27
+ export type { RepresentationPreparationRequest, ResourceTree, ResourceTreeRegistrationSeam, ResourceTreeSource, RuntimeSchemeFacet, SchemeHandler, SchemeHandlerConstructor, SchemeRegistrationSeam, } from "./handler.ts";
28
28
  export type { ExtensionAttributionContext, ExtensionAttributionDeclaration, ExtensionAttributionSource, } from "@plurnk/plurnk-meta";
29
29
  export type { PlurnkStatement, FindStatement, ReadStatement, CopyStatement, MoveStatement, SendStatement, ExecStatement, WorkStatement, ForkStatement, KillStatement, DispositionStatement, ParsedPath, LocalPath, UrlPath, } from "@plurnk/plurnk-contracts";
30
30
  export { FileByteSource, GeneratedByteSource, type ByteSource } from "./ByteSource.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAA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AuB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["// Public API barrel for @plurnk/plurnk-schemes.\n\n// ── Manifest types ────────────────────────────────────────────────────────\nexport type {\n EntryCoordinate,\n SchemeAuthority,\n SchemeManifest,\n WriterTier,\n} from \"./types.ts\";\n\n// ── Behavior classes ─────────────────────────────────────────────────────\nexport { default as Manifest } from \"./Manifest.ts\";\nexport { default as NetworkAddress } from \"./NetworkAddress.ts\";\nexport { default as EntryCoordinates } from \"./EntryCoordinates.ts\";\nexport { default as MimetypeClassifier, PathMimetype, TEXT_PRIMITIVE_MIMETYPE } from \"./MimetypeClassifier.ts\";\nexport { default as Slicer } from \"./Slicer.ts\";\nexport type {\n BatchEdit,\n EditResult as LineEditResult,\n PageResult,\n RangeUnit,\n SliceResult,\n TextReplacement,\n WindowResult,\n} from \"./Slicer.ts\";\nexport { default as Matcher } from \"./Matcher.ts\";\nexport type { MatchResult } from \"./Matcher.ts\";\nexport { default as SchemeDiscovery } from \"./SchemeDiscovery.ts\";\nexport type { SchemeInfo, SchemeDiscoveryResult, DiscoverOptions } from \"./SchemeDiscovery.ts\";\nexport { default as Summarize } from \"./Summarize.ts\";\nexport type { OrientIndex } from \"./Summarize.ts\";\nexport { default as OutputScheme } from \"./OutputScheme.ts\";\nexport { default as ResourceNames } from \"./ResourceNames.ts\";\nexport type { RuntimeDecl } from \"./OutputScheme.ts\";\nexport { default as Results, InvalidOperationResultError } from \"./Results.ts\";\nexport { default as MessageAttachments } from \"./MessageAttachments.ts\";\nexport { default as MessageScheme } from \"./MessageScheme.ts\";\nexport { default as PacketSections } from \"./PacketSections.ts\";\nexport type { PacketSectionDraft, PacketSectionTransformer } from \"./PacketSections.ts\";\nexport { PathSyntax } from \"@plurnk/plurnk-contracts\";\nexport { MimetypeInputLimitError as ProjectionInputLimitError } from \"@plurnk/plurnk-mimetypes\";\nexport type {\n AppliedEditBatchReceipt,\n AppliedEditReceipt,\n EditBatchReceipt,\n EditBatchResult,\n EditEffectReceipt,\n EditReceipt,\n EditReceiptUnit,\n ParseIssueTransition,\n ResolvedEditStatement,\n ReviewerReplacementEditBatchReceipt,\n SupersededEditReceipt,\n} from \"./edit-receipt.ts\";\nexport type {\n ChannelProducerResult,\n EntryResult,\n MatchEvidence,\n PassthroughResult,\n ProposalResult,\n ProblemDetails,\n RepresentationPreparationResult,\n ScopeNormalization,\n SchemeResult,\n SchemeResultBase,\n} from \"./Results.ts\";\n\n// {§capability-ctx} Capability ctx — DB-free authoring surface for siblings.\n// Interfaces only; plurnk-service injects the implementation.\nexport type {\n ChannelCaps,\n ChannelState,\n TerminalChannelState,\n EntryCaps,\n EntryCatalogChannel,\n EntryCatalogDefaultChannel,\n EntryCatalogItem,\n EntryCatalogScope,\n EntryCatalogScopeGroup,\n EntryData,\n EntryEditResult,\n EntryFindResult,\n EntryOperationCaps,\n EntryAddress,\n EntryReadResult,\n EntryStorageReadResult,\n EntryStreamLifecycle,\n EntryStorageWriteResult,\n StoredEntryData,\n StreamSubscription,\n ProjectionCaps,\n InteractionCaps,\n ProjectedText,\n ProjectedBinary,\n NotifyCaps,\n ProposalApplyRequest,\n ProposalApplyResult,\n ProposalAware,\n SchemeAddressCtx,\n SchemeCtx,\n ResourceCaps,\n MessageCaps,\n SubscriptionCaps,\n SubscriptionHandle,\n} from \"./ctx.ts\";\n\n// ── Behavior contract + the scheme-facing grammar types ──────────────────────\n// SchemeHandler is the typed op surface a sibling `implements`. The per-op\n// statement + path types are re-exported from grammar here so a sibling depends\n// on and exact-pins ONLY this package; grammar is the framework's transitive pin\n// (this repo already peers it). The engine speaks one grammar — keep it single.\nexport type {\n RepresentationPreparationRequest,\n ResourceTree,\n ResourceTreeRegistrationSeam,\n ResourceTreeSource,\n RuntimeSchemeFacet,\n SchemeHandler,\n SchemeRegistrationSeam,\n} from \"./handler.ts\";\nexport type {\n ExtensionAttributionContext,\n ExtensionAttributionDeclaration,\n ExtensionAttributionSource,\n} from \"@plurnk/plurnk-meta\";\nexport type {\n PlurnkStatement,\n FindStatement,\n ReadStatement,\n CopyStatement,\n MoveStatement,\n SendStatement,\n ExecStatement,\n WorkStatement,\n ForkStatement,\n KillStatement,\n DispositionStatement,\n ParsedPath,\n LocalPath,\n UrlPath,\n} from \"@plurnk/plurnk-contracts\";\nexport { FileByteSource, GeneratedByteSource, type ByteSource } from \"./ByteSource.ts\";\nexport { WebMaterializationError } from \"./WebMaterialization.ts\";\nexport type {\n WebChannelFailure,\n WebChannelOutcome,\n WebFetchResult,\n WebMaterializationSource,\n WebMaterializedResult,\n WebMaterializer,\n WebResponseBody,\n} from \"./WebMaterialization.ts\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAUhD,4EAA4E;AAC5E,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAC/G,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAUhD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,uBAAuB,IAAI,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAsGhG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAmB,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["// Public API barrel for @plurnk/plurnk-schemes.\n\n// ── Manifest types ────────────────────────────────────────────────────────\nexport type {\n EntryCoordinate,\n SchemeAuthority,\n SchemeManifest,\n WriterTier,\n} from \"./types.ts\";\n\n// ── Behavior classes ─────────────────────────────────────────────────────\nexport { default as Manifest } from \"./Manifest.ts\";\nexport { default as NetworkAddress } from \"./NetworkAddress.ts\";\nexport { default as EntryCoordinates } from \"./EntryCoordinates.ts\";\nexport { default as MimetypeClassifier, PathMimetype, TEXT_PRIMITIVE_MIMETYPE } from \"./MimetypeClassifier.ts\";\nexport { default as Slicer } from \"./Slicer.ts\";\nexport type {\n BatchEdit,\n EditResult as LineEditResult,\n PageResult,\n RangeUnit,\n SliceResult,\n TextReplacement,\n WindowResult,\n} from \"./Slicer.ts\";\nexport { default as Matcher } from \"./Matcher.ts\";\nexport type { MatchResult } from \"./Matcher.ts\";\nexport { default as SchemeDiscovery } from \"./SchemeDiscovery.ts\";\nexport type { SchemeInfo, SchemeDiscoveryResult, DiscoverOptions } from \"./SchemeDiscovery.ts\";\nexport { default as Summarize } from \"./Summarize.ts\";\nexport type { OrientIndex } from \"./Summarize.ts\";\nexport { default as OutputScheme } from \"./OutputScheme.ts\";\nexport { default as ResourceNames } from \"./ResourceNames.ts\";\nexport type { RuntimeDecl } from \"./OutputScheme.ts\";\nexport { default as Results, InvalidOperationResultError } from \"./Results.ts\";\nexport { default as MessageAttachments } from \"./MessageAttachments.ts\";\nexport { default as MessageScheme } from \"./MessageScheme.ts\";\nexport { default as PacketSections } from \"./PacketSections.ts\";\nexport type { PacketSectionDraft, PacketSectionTransformer } from \"./PacketSections.ts\";\nexport { PathSyntax } from \"@plurnk/plurnk-contracts\";\nexport { MimetypeInputLimitError as ProjectionInputLimitError } from \"@plurnk/plurnk-mimetypes\";\nexport type {\n AppliedEditBatchReceipt,\n AppliedEditReceipt,\n EditBatchReceipt,\n EditBatchResult,\n EditEffectReceipt,\n EditReceipt,\n EditReceiptUnit,\n ParseIssueTransition,\n ResolvedEditStatement,\n ReviewerReplacementEditBatchReceipt,\n SupersededEditReceipt,\n} from \"./edit-receipt.ts\";\nexport type {\n ChannelProducerResult,\n EntryResult,\n MatchEvidence,\n PassthroughResult,\n ProposalResult,\n ProblemDetails,\n RepresentationPreparationResult,\n ScopeNormalization,\n SchemeResult,\n SchemeResultBase,\n} from \"./Results.ts\";\n\n// {§capability-ctx} Capability ctx — DB-free authoring surface for siblings.\n// Interfaces only; plurnk-service injects the implementation.\nexport type {\n ChannelCaps,\n ChannelState,\n TerminalChannelState,\n EntryCaps,\n EntryCatalogChannel,\n EntryCatalogDefaultChannel,\n EntryCatalogItem,\n EntryCatalogScope,\n EntryCatalogScopeGroup,\n EntryData,\n EntryEditResult,\n EntryFindResult,\n EntryOperationCaps,\n EntryAddress,\n EntryReadResult,\n EntryStorageReadResult,\n EntryStreamLifecycle,\n EntryStorageWriteResult,\n StoredEntryData,\n StreamSubscription,\n ProjectionCaps,\n InteractionCaps,\n ProjectedText,\n ProjectedBinary,\n NotifyCaps,\n ProposalApplyRequest,\n ProposalApplyResult,\n ProposalAware,\n SchemeAddressCtx,\n SchemeCtx,\n ResourceCaps,\n MessageCaps,\n SubscriptionCaps,\n SubscriptionHandle,\n} from \"./ctx.ts\";\n\n// ── Behavior contract + the scheme-facing grammar types ──────────────────────\n// SchemeHandler is the typed op surface a sibling `implements`. The per-op\n// statement + path types are re-exported from grammar here so a sibling depends\n// on and exact-pins ONLY this package; grammar is the framework's transitive pin\n// (this repo already peers it). The engine speaks one grammar — keep it single.\nexport type {\n RepresentationPreparationRequest,\n ResourceTree,\n ResourceTreeRegistrationSeam,\n ResourceTreeSource,\n RuntimeSchemeFacet,\n SchemeHandler,\n SchemeHandlerConstructor,\n SchemeRegistrationSeam,\n} from \"./handler.ts\";\nexport type {\n ExtensionAttributionContext,\n ExtensionAttributionDeclaration,\n ExtensionAttributionSource,\n} from \"@plurnk/plurnk-meta\";\nexport type {\n PlurnkStatement,\n FindStatement,\n ReadStatement,\n CopyStatement,\n MoveStatement,\n SendStatement,\n ExecStatement,\n WorkStatement,\n ForkStatement,\n KillStatement,\n DispositionStatement,\n ParsedPath,\n LocalPath,\n UrlPath,\n} from \"@plurnk/plurnk-contracts\";\nexport { FileByteSource, GeneratedByteSource, type ByteSource } from \"./ByteSource.ts\";\nexport { WebMaterializationError } from \"./WebMaterialization.ts\";\nexport type {\n WebChannelFailure,\n WebChannelOutcome,\n WebFetchResult,\n WebMaterializationSource,\n WebMaterializedResult,\n WebMaterializer,\n WebResponseBody,\n} from \"./WebMaterialization.ts\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAKxD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC;AAEvD,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC7B;AAED,UAAU,kBAAkB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,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IACtB,QAAQ,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAG1C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAGhC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAI/B,QAAQ,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;IAGhC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAIlC,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAI/B,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAExC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAGhC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAGxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,CAC9C;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3B;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,GAChC;IAAE,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAAE,CACrC,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,sEAAsE;AACtE,4EAA4E;AAC5E,mCAAmC","sourcesContent":["// Framework-grade types shared by every `@plurnk/plurnk-schemes-*` sibling\n// and its consumer (plurnk-service).\n//\n// Notably absent from this surface: `PlurnkSchemeContext`. The full per-call\n// context shape (which includes the database handle, channel-write notifier,\n// wake-on-completion notifier, etc.) is plurnk-service-coupled and lives\n// in the consumer. Sister schemes consume the parts of ctx the engine\n// supplies them per dispatch; this repo ships only the manifest types every\n// sibling needs to declare itself.\n\nexport type WriterTier = \"model\" | \"client\" | \"_plurnk\";\n\n// URI-authority disposition for an addressed scheme. Namespace is the stable\n// default for ordinary entry trees: an authored authority folds into the\n// pathname. Resource preserves authority as a durable entry coordinate.\nexport type SchemeAuthority = \"namespace\" | \"resource\";\n\nexport interface EntryCoordinate {\n readonly authority: string;\n readonly pathname: string;\n}\n\ninterface SchemeManifestBase {\n readonly name: string; // addressing/routing identity (the URI prefix)\n readonly authority?: SchemeAuthority; // absent = namespace\n readonly channels: Record<string, string>; // channel name → declared mimetype; the default may be dynamic\n // The channel selected for an unqualified read. Dynamic-channel schemes may\n // name it without declaring a fixed mimetype; empty means no default.\n readonly defaultChannel: string;\n // data: entry-bearing content. logging: log:// rows. control: addresses\n // sister sessions and owns no entries (session://: spawn/fork/irc).\n readonly writableBy: ReadonlyArray<WriterTier>;\n readonly volatile: boolean;\n readonly modelVisible: boolean;\n // A trailing slash on FIND or READ denotes a collection scope only when declared.\n // Explicit globs and matcher bodies remain queries everywhere. Absent/false\n // means `/` is ordinary resource syntax and dispatches directly.\n readonly folderScopes?: boolean;\n // True only when EDIT accepts the shared textual <scope> contract. Core\n // then lowers rendered line anchors to numeric coordinates before dispatch.\n readonly textEditScopes?: boolean;\n // True when the scheme's stable textual representations publish and accept\n // shared line anchors without claiming EDIT support. textEditScopes implies\n // publication only where the addressed resource authorizes model writes.\n readonly lineAnchors?: boolean;\n // General policy facts consumed by CapabilitySelector.trait. The scheme\n // declares facts only; it never interprets policy or named modes.\n readonly traits?: ReadonlyArray<string>;\n // Discoverable reference material ({§manifest}).\n readonly documentation?: string;\n // Opaque client presentation metadata. It is deliberately absent from\n // model-facing scheme teaching; clients choose rendering and fallback.\n readonly glyph?: string;\n // Value persisted to `entries.scheme`, which may differ from the addressing\n // `name`. Absent defaults to `name`; identity components are never null.\n readonly storedScheme?: string;\n}\n\nexport type SchemeManifest = SchemeManifestBase & (\n { readonly category: \"data\" }\n | { readonly category: \"logging\" }\n | { readonly category: \"control\" }\n);\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,qCAAqC;AACrC,EAAE;AACF,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,sEAAsE;AACtE,4EAA4E;AAC5E,mCAAmC","sourcesContent":["// Framework-grade types shared by every `@plurnk/plurnk-schemes-*` sibling\n// and its consumer (plurnk-service).\n//\n// Notably absent from this surface: `PlurnkSchemeContext`. The full per-call\n// context shape (which includes the database handle, channel-write notifier,\n// wake-on-completion notifier, etc.) is plurnk-service-coupled and lives\n// in the consumer. Sister schemes consume the parts of ctx the engine\n// supplies them per dispatch; this repo ships only the manifest types every\n// sibling needs to declare itself.\n\nexport type WriterTier = \"model\" | \"client\" | \"_plurnk\";\n\n// URI-authority disposition for an addressed scheme. Namespace is the stable\n// default for ordinary entry trees: an authored authority folds into the\n// pathname. Resource preserves authority as a durable entry coordinate.\nexport type SchemeAuthority = \"namespace\" | \"resource\";\n\nexport interface EntryCoordinate {\n readonly authority: string;\n readonly pathname: string;\n}\n\ninterface SchemeManifestBase {\n readonly name: string; // addressing/routing identity (the URI prefix)\n readonly authority?: SchemeAuthority; // absent = namespace\n readonly channels: Record<string, string>; // channel name → declared mimetype; the default may be dynamic\n // The channel selected for an unqualified read. Dynamic-channel schemes may\n // name it without declaring a fixed mimetype; empty means no default.\n readonly defaultChannel: string;\n // data: entry-bearing content. logging: log:// rows. control: addresses\n // sister sessions and owns no entries (session://: spawn/fork/irc).\n readonly writableBy: ReadonlyArray<WriterTier>;\n readonly volatile: boolean;\n readonly modelVisible: boolean;\n // A trailing slash on FIND or READ denotes a collection scope only when declared.\n // Explicit globs and matcher bodies remain queries everywhere. Absent/false\n // means `/` is ordinary resource syntax and dispatches directly.\n readonly folderScopes?: boolean;\n // True only when EDIT accepts the shared textual <scope> contract. Core\n // then lowers rendered line anchors to numeric coordinates before dispatch.\n readonly textEditScopes?: boolean;\n // True when the scheme's stable textual representations publish and accept\n // shared line anchors without claiming EDIT support. textEditScopes implies\n // publication only where the addressed resource authorizes model writes.\n readonly lineAnchors?: boolean;\n // General capability facts consumed by session-owner interaction visibility\n // ({§question-tool}). The scheme declares facts only; it never interprets\n // owner visibility.\n readonly traits?: ReadonlyArray<string>;\n // Discoverable reference material ({§manifest}).\n readonly documentation?: string;\n // Opaque client presentation metadata. It is deliberately absent from\n // model-facing scheme teaching; clients choose rendering and fallback.\n readonly glyph?: string;\n // Value persisted to `entries.scheme`, which may differ from the addressing\n // `name`. Absent defaults to `name`; identity components are never null.\n readonly storedScheme?: string;\n}\n\nexport type SchemeManifest = SchemeManifestBase & (\n { readonly category: \"data\" }\n | { readonly category: \"logging\" }\n | { readonly category: \"control\" }\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plurnk/plurnk-schemes",
3
- "version": "3.3.5",
3
+ "version": "3.5.0",
4
4
  "description": "Framework + contract for the @plurnk/plurnk-schemes-* URI handler packages.",
5
5
  "keywords": [
6
6
  "plurnk",
@@ -51,11 +51,11 @@
51
51
  "@plurnk/plurnk-mimetypes": "^3.0.0"
52
52
  },
53
53
  "dependencies": {
54
- "@plurnk/plurnk-contracts": "^7.5.0",
55
- "@plurnk/plurnk-meta": "^2.2.0"
54
+ "@plurnk/plurnk-contracts": "^9.0.0",
55
+ "@plurnk/plurnk-meta": "^3.0.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@plurnk/plurnk-parser": "^4.6.0"
58
+ "@plurnk/plurnk-parser": "^5.1.0"
59
59
  },
60
- "gitHead": "9206fac0bc773bc1bdb4cc0a541f8bd58f45f87b"
60
+ "gitHead": "559adf644852d67450ff26a10df39b10f7cf90cc"
61
61
  }