Skip to content

Commit d7c589a

Browse files
committed
docs(readme): add CRUD modes, delete, move, and API warning
- Add CRUD modes feature bullet to main README - Add delete and move file usage examples with code blocks - Add warning callout about pure text-to-text API with no filesystem I/O - Update schema README parameter table with four mode values
1 parent ca167b9 commit d7c589a

2 files changed

Lines changed: 55 additions & 10 deletions

File tree

‎README.md‎

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ V4A is a context-anchored diff format designed for LLM tool calling. Instead of
1818

1919
## Features
2020

21+
- **CRUD modes** - Update, create, delete, and move files in a single API.
2122
- **Token efficient** - Returns only changed lines, not the entire file.
2223
- **Instant rollback** - Original source included in result, no manual tracking.
2324
- **Structured diff** - Line-by-line add/delete/equal metadata with line numbers.
@@ -55,6 +56,9 @@ Or via [esm.sh](https://esm.sh):
5556

5657
## Usage
5758

59+
> [!WARNING]
60+
> This is a pure text-to-text API with no filesystem I/O, designed to run in any environment including browsers, CLI, and terminal applications. Filesystem operations such as reading, writing, and deleting files are left to the consumer.
61+
5862
```ts
5963
import V4A from '@neabyte/v4a-diff'
6064

@@ -104,6 +108,37 @@ const result = V4A.apply(
104108
// result.text === 'export const PORT = 8080\nexport const HOST = "localhost"'
105109
```
106110

111+
### Delete a file
112+
113+
> [!NOTE]
114+
> Source is needed to produce the structured diff output.
115+
116+
```ts
117+
const result = V4A.apply('const x = 1\nconst y = 2', '*** Delete File: /src/config.ts', 'delete')
118+
// result.text === ''
119+
// result.source === 'const x = 1\nconst y = 2'
120+
```
121+
122+
### Move a file (apply diff at new path)
123+
124+
> [!NOTE]
125+
> Source is needed to produce the structured diff output.
126+
127+
```ts
128+
// Move with edits
129+
const result = V4A.apply(
130+
'const x = 1',
131+
'*** Move to: /src/new-path.ts\n@@\n-const x = 1\n+const x = 2',
132+
'move'
133+
)
134+
// result.text === 'const x = 2'
135+
136+
// Move without edits (pure rename)
137+
const renamed = V4A.apply('const x = 1\nconst y = 2', '*** Move to: /src/new-path.ts', 'move')
138+
// renamed.text === 'const x = 1\nconst y = 2'
139+
// renamed.diff lines are all { type: 'equal' }
140+
```
141+
107142
### Multi-hunk edits
108143

109144
```ts
@@ -117,11 +152,11 @@ const result = V4A.apply(
117152

118153
### `V4A.apply(sourceText, diffText, mode?)`
119154

120-
| Parameter | Type | Description |
121-
| ------------ | ----------------------- | -------------------------------------------------------------------- |
122-
| `sourceText` | `string` | Original file content |
123-
| `diffText` | `string` | V4A format diff string |
124-
| `mode` | `'default' \| 'create'` | `default` updates existing text, `create` builds from `+` lines only |
155+
| Parameter | Type | Description |
156+
| ------------ | --------------- | --------------------------------------------------------- |
157+
| `sourceText` | `string` | Original file content |
158+
| `diffText` | `string` | V4A format diff string |
159+
| `mode` | `ApplyDiffMode` | `'update'` (default), `'create'`, `'delete'`, or `'move'` |
125160

126161
**Returns:** `ApplyDiffResult`
127162

@@ -152,10 +187,20 @@ type DiffLine = {
152187
*** End Patch
153188
```
154189
190+
Other file operation headers:
191+
192+
```
193+
*** Add File: {path}
194+
*** Delete File: {path}
195+
*** Move to: {new_path}
196+
```
197+
155198
- `@@` followed by text anchors to a matching line in the source file.
156199
- A bare `@@` alone means "start of file."
157200
- Every line in a hunk must start with ``(space),`-`, or `+`.
158201
- `*** Add File:` with `+` prefixed lines creates new files.
202+
- `*** Delete File:` marks a file for deletion.
203+
- `*** Move to:` renames/moves a file while applying edits.
159204
160205
## LLM Tool Schemas
161206

‎schema/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ Tool calling schemas for the `apply_patch` function across different LLM provide
1111

1212
## Parameters
1313

14-
| Parameter | Type | Required | Description |
15-
| --------- | ----------------------- | -------- | --------------------------------------------------------- |
16-
| `path` | `string` | Yes | Absolute path to the file |
17-
| `diff` | `string` | Yes | V4A diff with `@@` anchors and `space/+/-` prefixed lines |
18-
| `mode` | `"default" \| "create"` | Yes | `default` updates existing file, `create` writes new file |
14+
| Parameter | Type | Required | Description |
15+
| --------- | -------------------------------------------- | -------- | ------------------------------------------------------------------------ |
16+
| `path` | `string` | Yes | Absolute path to the file |
17+
| `diff` | `string` | Yes | V4A diff with `@@` anchors and `space/+/-` prefixed lines |
18+
| `mode` | `"update" \| "create" \| "delete" \| "move"` | Yes | `update` modifies, `create` writes new, `delete` removes, `move` renames |
1919

2020
## Notes
2121

0 commit comments

Comments
 (0)