API reference
patch
Import
Section titled “Import”import * as api from "@fungi.computer/knapsack/patch";Exports
Section titled “Exports”| 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”type CodexPatchLine = Readonly<{ kind: "add" | "context" | "remove"; text: string;}>;One body line of an update or add hunk.
CodexPatchHunktype alias
Section titled “CodexPatchHunk”type CodexPatchHunk = Readonly<{ context?: string; lines: readonly CodexPatchLine[];}>;One @@ change block; context is the text after @@, when present.
CodexPatchFiletype alias
Section titled “CodexPatchFile”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()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
patch |
string |
Returns
Section titled “Returns”readonly Readonly<{ operation: "update" | "delete" | "add";
path: string; moveTo?: string; hunks: readonly Readonly<{
context?: string; lines: readonly Readonly<{ kind: "context" |
"add" | "remove"; text: string; }>[]; }>[]; }>[]