@pieceful/ravel-core 0.1.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/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 James Taylor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@pieceful/ravel-core",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Ravel chunk syntax, resolution, graph evaluation, and diagnostics.",
6
+ "license": "MIT",
7
+ "author": "James Taylor",
8
+ "repository": { "type": "git", "url": "git+https://github.com/jostylr/ravel.git", "directory": "packages/core" },
9
+ "bugs": { "url": "https://github.com/jostylr/ravel/issues" },
10
+ "homepage": "https://github.com/jostylr/ravel#readme",
11
+ "engines": { "node": ">=22" },
12
+ "keywords": ["ravel", "literate-programming", "graph", "composition"],
13
+ "publishConfig": { "access": "public" },
14
+ "exports": {
15
+ ".": "./src/index.js",
16
+ "./directives": "./src/directives.js"
17
+ },
18
+ "types": "./src/index.d.ts",
19
+ "files": ["src", "LICENSE"]
20
+ }
package/src/.gitkeep ADDED
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,9 @@
1
+ import type { SourceLocation } from "./index.js";
2
+ export const directiveKinds: Set<string>;
3
+ export function compose(steps: unknown[], source: SourceLocation): unknown;
4
+ export function append(reference: string, source: SourceLocation): unknown;
5
+ export function newline(count: number, source: SourceLocation): unknown;
6
+ export function pipe(steps: unknown[], source: SourceLocation): unknown;
7
+ export function pass(steps: unknown[], source: SourceLocation): unknown;
8
+ export function createDirective(name: string, value: unknown, source: SourceLocation): unknown;
9
+ export function aliasDirective(name: string, reference: string, source: SourceLocation): unknown;
@@ -0,0 +1,16 @@
1
+ // Portable directive IR. Adapters only construct these values; core owns their meaning.
2
+ export const directiveKinds = new Set(["create", "alias", "in", "out"]);
3
+
4
+ export const compose = (steps, source) => ({ kind: "compose", steps, source });
5
+ export const append = (reference, source) => ({ kind: "append", reference, source });
6
+ export const newline = (count, source) => ({ kind: "newline", count, source });
7
+ export const pipe = (steps, source) => ({ kind: "pipe", steps, source });
8
+ export const pass = (steps, source) => ({ kind: "pass", steps, source });
9
+
10
+ /**
11
+ * A create name is document-local: `program:cool.js` becomes the surrounding
12
+ * document's canonical chunk identity. Alias is intentionally the only
13
+ * directive that may introduce an alternate graph name for an existing node.
14
+ */
15
+ export const createDirective = (name, value, source) => ({ kind: "create", name, value, source });
16
+ export const aliasDirective = (name, reference, source) => ({ kind: "alias", name, reference, source });
package/src/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ export interface SourcePosition { line: number; column: number; offset: number; }
2
+ export interface SourceRange { start: SourcePosition; end: SourcePosition; }
3
+ export interface SourceLocation { uri: string; range: SourceRange; }
4
+ export interface Diagnostic { code: string; severity: "error" | "warning" | "info"; message: string; source: SourceLocation; related?: SourceLocation[]; }
5
+ export interface ChunkIdentity { document: string | null; chunk: string | null; minor: string | null; type: string | null; explicitDocument?: boolean; }
6
+ export interface RavelMap { version: 1; document: { id: string; uri: string; format: string }; chunks: Array<Record<string, unknown>>; directives?: Array<Record<string, unknown>>; diagnostics?: Diagnostic[]; }
7
+ export interface PretransformGraph { version: 1; documents: Array<{ id: string; uri: string; format: string }>; chunks: Array<Record<string, unknown>>; directives: Array<Record<string, unknown>>; diagnostics: Diagnostic[]; }
8
+ export interface ProvenanceStep { kind: string; source?: SourceLocation; from?: string; to?: string; name?: string; phase?: number; value?: string; owner?: string; target?: string; }
9
+ export interface ProvenanceOrigin { source: SourceLocation | null; chunk: string; kind: string; precision: "exact" | "coarse"; via: ProvenanceStep[]; }
10
+ export interface ProvenanceSegment { generated: { start: number; end: number }; source: SourceLocation | null; chunk: string; kind: string; precision: "exact" | "coarse"; via: ProvenanceStep[]; origins?: ProvenanceOrigin[]; }
11
+ export interface DeliverableProvenanceMap { version: 1; kind: "ravel-provenance-map"; generated: { uri: string; length: number; offsetEncoding: "utf-16" }; from: string; segments: ProvenanceSegment[]; }
12
+ export interface BuildProvenanceMap { version: 1; kind: "ravel-provenance-bundle"; maps: DeliverableProvenanceMap[]; }
13
+ export interface ProgramChunk { id: string; identity: ChunkIdentity; value: string; segments: ProvenanceSegment[]; source: SourceLocation; dependencies: string[]; references: Array<{ chunk: string; requested: string; source: SourceLocation }>; provenance: unknown[]; generated?: boolean; }
14
+ export interface Deliverable { name: string; from: string; value: string; segments: ProvenanceSegment[]; source: SourceLocation; dependencies: string[]; }
15
+ export interface RavelProgram { version: 1; documents: PretransformGraph["documents"]; chunks: Record<string, ProgramChunk>; deliverables: Record<string, Deliverable>; diagnostics: Diagnostic[]; trace: { chunks: Record<string, unknown[]> }; }
16
+ export interface TransformCall { type?: "transform"; name: string; arguments?: unknown[]; source?: SourceLocation; }
17
+ export function formatChunkId(identity: ChunkIdentity): string;
18
+ export function parseChunkId(input: string, options?: { reference?: boolean }): ChunkIdentity | null;
19
+ export function parseChunk(body: string, source: SourceLocation): { nodes: unknown[]; diagnostics: Diagnostic[] };
20
+ export function combineMaps(maps: RavelMap[]): PretransformGraph;
21
+ export function transformGraph(graph: PretransformGraph, options?: { transforms?: Record<string, (value: string, ...argumentsValue: unknown[]) => string> | Map<string, Function> }): RavelProgram;
22
+ export const provenanceMapVersion: 1;
23
+ export function createDeliverableProvenanceMap(deliverable: Deliverable): DeliverableProvenanceMap;
24
+ export function createBuildProvenanceMap(program: RavelProgram): BuildProvenanceMap;
25
+ export function sourceAtGeneratedOffset(map: DeliverableProvenanceMap, offset: number): (ProvenanceSegment & { sourceOffset?: number }) | null;
26
+ export interface GeneratedSourceMatch { generated: { start: number; end: number }; generatedOffset?: number; source?: { start: number; end: number }; precision: "exact" | "coarse"; chunk: string; kind: string; via: ProvenanceStep[]; through?: "transform-origin"; }
27
+ export function generatedRangesForSource(map: DeliverableProvenanceMap, uri: string, offset: number): GeneratedSourceMatch[];
28
+ export function generatedRangesForSourceRange(map: DeliverableProvenanceMap, uri: string, range: { start: number | SourcePosition; end: number | SourcePosition }): GeneratedSourceMatch[];
29
+ export function explainGeneratedOffset(program: RavelProgram, deliverableName: string, offset: number): { deliverable: { name: string; from: string }; generatedOffset: number; segment: ProvenanceSegment & { sourceOffset?: number }; definition: { id: string; identity: ChunkIdentity; metadata: unknown; generated?: boolean } | null; references: ProvenanceStep[]; dependencyPath: string[] } | null;
30
+ export const directiveKinds: Set<string>;
31
+ export function compose(steps: unknown[], source: SourceLocation): unknown;
32
+ export function append(reference: string, source: SourceLocation): unknown;
33
+ export function newline(count: number, source: SourceLocation): unknown;
34
+ export function pipe(steps: unknown[], source: SourceLocation): unknown;
35
+ export function pass(steps: unknown[], source: SourceLocation): unknown;
36
+ export function createDirective(name: string, value: unknown, source: SourceLocation): unknown;
37
+ export function aliasDirective(name: string, reference: string, source: SourceLocation): unknown;