Skip to content
API reference

patch

Import
import * as api from "@fungi.computer/knapsack/patch";
Kind Export Description
type alias CodexPatchLine One body line of an update or add hunk.
type alias CodexPatchHunk One @@ change block; context is the text after @@, when present.
type alias CodexPatchFile One file operation in a patch, in patch order.
function parseCodexPatch() Read the file operations of one Codex patch, in order.

CodexPatchLinetype alias

Section titled “CodexPatchLine”
Signature
type CodexPatchLine = Readonly<{
kind: "add" | "context" | "remove";
text: string;
}>;

One body line of an update or add hunk.


CodexPatchHunktype alias

Section titled “CodexPatchHunk”
Signature
type CodexPatchHunk = Readonly<{
context?: string;
lines: readonly CodexPatchLine[];
}>;

One @@ change block; context is the text after @@, when present.


CodexPatchFiletype alias

Section titled “CodexPatchFile”
Signature
type CodexPatchFile = Readonly<{
operation: "add" | "delete" | "update";
path: string;
moveTo?: string;
hunks: readonly CodexPatchHunk[];
}>;

One file operation in a patch, in patch order.

parseCodexPatch()function

Section titled “parseCodexPatch()”
Signature
function parseCodexPatch(patch): readonly Readonly<{
operation: "update" | "delete" | "add";
path: string;
moveTo?: string;
hunks: readonly Readonly<{
context?: string;
lines: readonly Readonly<{
kind: "context" | "add" | "remove";
text: string;
}>[];
}>[];
}>[];

Read the file operations of one Codex patch, in order.

Parameter Type
patch string

readonly Readonly<{ operation: "update" | "delete" | "add"; path: string; moveTo?: string; hunks: readonly Readonly<{ context?: string; lines: readonly Readonly<{ kind: "context" | "add" | "remove"; text: string; }>[]; }>[]; }>[]