@better-fs-tools/write 0.1.0 → 0.3.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 +122 -106
- package/dist/bundle/create-fs-tools.d.ts +83 -21
- package/dist/bundle/create-fs-tools.js +61 -22
- package/dist/bundle/definitions.d.ts +51 -0
- package/dist/bundle/definitions.js +42 -0
- package/dist/contract/deps.d.ts +13 -5
- package/dist/contract/messages.d.ts +0 -23
- package/dist/contract/preconditions.d.ts +5 -1
- package/dist/contract/preconditions.js +1 -1
- package/dist/core/commit.d.ts +0 -1
- package/dist/core/commit.js +1 -35
- package/dist/core/create-tools.d.ts +9 -9
- package/dist/core/create-tools.js +11 -11
- package/dist/core/deps.d.ts +4 -4
- package/dist/core/deps.js +10 -7
- package/dist/core/format.js +1 -15
- package/dist/core/hooks.js +1 -8
- package/dist/core/load.js +1 -1
- package/dist/core/messages.js +8 -11
- package/dist/core/patch-hunks.js +31 -3
- package/dist/core/patch-pipeline.js +1 -2
- package/dist/core/pipeline.js +2 -2
- package/dist/core/plan-edit.d.ts +2 -0
- package/dist/core/plan-edit.js +3 -3
- package/dist/core/precondition.js +2 -13
- package/dist/core/record.js +1 -0
- package/dist/formatters/default.d.ts +7 -1
- package/dist/formatters/default.js +23 -5
- package/dist/guards/index.d.ts +9 -3
- package/dist/guards/index.js +11 -3
- package/dist/guards/non-text.d.ts +5 -1
- package/dist/guards/non-text.js +5 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/matchers/index.d.ts +4 -1
- package/dist/matchers/index.js +5 -3
- package/dist/matchers/keep-bytes.d.ts +22 -0
- package/dist/matchers/keep-bytes.js +51 -0
- package/dist/matchers/line-trimmed.d.ts +4 -1
- package/dist/matchers/line-trimmed.js +9 -1
- package/dist/matchers/normalized.d.ts +2 -1
- package/dist/matchers/normalized.js +7 -1
- package/dist/signature/definition.d.ts +41 -0
- package/dist/signature/definition.js +66 -0
- package/dist/signature/edit.d.ts +4 -5
- package/dist/signature/edit.js +5 -13
- package/dist/signature/index.d.ts +6 -2
- package/dist/signature/index.js +4 -2
- package/dist/signature/patch.d.ts +4 -1
- package/dist/signature/patch.js +4 -1
- package/dist/signature/write.d.ts +1 -6
- package/dist/signature/write.js +1 -8
- package/docs/architecture.md +14 -11
- package/docs/hosts.md +134 -55
- package/docs/result-schema.md +20 -26
- package/package.json +4 -4
package/docs/result-schema.md
CHANGED
|
@@ -98,7 +98,7 @@ interface Snippet {
|
|
|
98
98
|
}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
`matches` is empty for `write`. An already applied pair has no entry. `snippets` is empty for `write` and for a delete. The model text shows the snippets
|
|
101
|
+
`matches` is empty for `write`. An already applied pair has no entry. `snippets` is empty for `write` and for a delete. The model text shows the snippets only when the formatter has `snippet: true`. The full diff is only in `diff`, unless the formatter has `diff: true`.
|
|
102
102
|
|
|
103
103
|
## `CommitReport`
|
|
104
104
|
|
|
@@ -162,23 +162,16 @@ Every error result has exactly one warning note whose `code` is the error code i
|
|
|
162
162
|
|
|
163
163
|
Notes on a successful call:
|
|
164
164
|
|
|
165
|
-
| `code` | Severity | From
|
|
166
|
-
| ---------------------------------- | -------- |
|
|
167
|
-
| `fuzzy-match` | info | a loose match
|
|
168
|
-
| `already-applied` | info | `edit`
|
|
169
|
-
| `stale-rematched` | info | `edit`, `apply_patch`
|
|
170
|
-
| `repeated-miss` | info | `edit`, with a `NO_MATCH`
|
|
171
|
-
| `
|
|
172
|
-
| `
|
|
173
|
-
| `
|
|
174
|
-
| `
|
|
175
|
-
| `no-compare-and-swap` | info | `writeCapabilities.compareAndSwap` false | none |
|
|
176
|
-
| `mode-not-kept` | info | `writeCapabilities.preserveMode` false, on a replace | none |
|
|
177
|
-
| `hook-failed` | warning | a hook threw after the commit | `{ hook }` |
|
|
178
|
-
| `extension-failed` | warning | the formatter failed; the default formatter ran | `{ extension: "formatter", id? }` |
|
|
179
|
-
| `hook-rewrote` | warning | a hook returned `rewrote: true` | `{ hook }` |
|
|
180
|
-
| `executable` | info | `executableShebang()` | `{ mode }` |
|
|
181
|
-
| `verify-mismatch`, `verify-failed` | warning | `verifyWrite()` | none |
|
|
165
|
+
| `code` | Severity | From | `data` |
|
|
166
|
+
| ---------------------------------- | -------- | ----------------------------------------------- | ------------------------------------------------------------------- |
|
|
167
|
+
| `fuzzy-match` | info | a loose match | edit: `{ index, matcher, lines }`. patch: `{ path, hunk, matcher }` |
|
|
168
|
+
| `already-applied` | info | `edit` with `recovery: true` | `{ index }` |
|
|
169
|
+
| `stale-rematched` | info | `edit`, `apply_patch` with `onStale: "rematch"` | none |
|
|
170
|
+
| `repeated-miss` | info | `edit` with `recovery: true`, with a `NO_MATCH` | `{ misses }` |
|
|
171
|
+
| `user-modified` | warning | an authorizer returned `content` | none |
|
|
172
|
+
| `hook-rewrote` | warning | a hook returned `rewrote: true` | `{ hook }` |
|
|
173
|
+
| `executable` | info | `executableShebang()` | `{ mode }` |
|
|
174
|
+
| `verify-mismatch`, `verify-failed` | warning | `verifyWrite()` | none |
|
|
182
175
|
|
|
183
176
|
Guards and authorizers may add allow notes of their own.
|
|
184
177
|
|
|
@@ -186,14 +179,14 @@ Guards and authorizers may add allow notes of their own.
|
|
|
186
179
|
|
|
187
180
|
The formatter makes `content` once, with `mode: "model"`. A formatter that returns a string gives one text part. `defaultWriteFormatter()` prints a header, a body, then a blank line and the note lines. An error prints the note lines only.
|
|
188
181
|
|
|
189
|
-
| Tool | Header | Body
|
|
190
|
-
| ------------- | ----------------------------------------------------------------------------- |
|
|
191
|
-
| `edit` | `Edited <path>: 1 replacement at line 4.` or `2 replacements at lines 3, 15.` |
|
|
192
|
-
| `write` | `Created <path> (3 lines).` or `Updated <path> (+2 -1 lines).` | none
|
|
193
|
-
| `apply_patch` | `Success. Updated the following files:` | One line for each file: `A`, `M`, or `D` and the path
|
|
194
|
-
| any | `No change to <path>.` for `no-change`. `write` adds the reason | none
|
|
182
|
+
| Tool | Header | Body |
|
|
183
|
+
| ------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
184
|
+
| `edit` | `Edited <path>: 1 replacement at line 4.` or `2 replacements at lines 3, 15.` | none. With `snippet: true`, the snippets, with the read tool's `12\|` gutter, `...` between |
|
|
185
|
+
| `write` | `Created <path> (3 lines).` or `Updated <path> (+2 -1 lines).` | none |
|
|
186
|
+
| `apply_patch` | `Success. Updated the following files:` | One line for each file: `A`, `M`, or `D` and the path |
|
|
187
|
+
| any | `No change to <path>.` for `no-change`. `write` adds the reason | none |
|
|
195
188
|
|
|
196
|
-
`defaultWriteFormatter({ diff: true })` adds each file's diff in a fenced block. `gutter` and `noteLine` change the snippet gutter and the note line.
|
|
189
|
+
`defaultWriteFormatter({ snippet: true })` adds the edit snippets. `defaultWriteFormatter({ diff: true })` adds each file's diff in a fenced block. `gutter` and `noteLine` change the snippet gutter and the note line. `notes(note, tool)` rewrites a note, or returns `null` to hide it from the model text. The read and bash formatters take the same `notes` option. The report keeps every note.
|
|
197
190
|
|
|
198
191
|
## The stored record
|
|
199
192
|
|
|
@@ -205,6 +198,7 @@ With a `state` store and a `digest`, each committed file gets a record under its
|
|
|
205
198
|
origin: "write",
|
|
206
199
|
observationId, resolvedPath, identity, version, digest,
|
|
207
200
|
contentId, viewId, observedAt, wholeFileVisible,
|
|
201
|
+
seenLines: [],
|
|
208
202
|
totalsExact: true,
|
|
209
203
|
request: null
|
|
210
204
|
}
|
|
@@ -265,4 +259,4 @@ Each cell is the `error.phase` values of that code, or "no" when the tool never
|
|
|
265
259
|
| `SPAWN_FAILED` | no | no | `run` |
|
|
266
260
|
| `OUTPUT_CAP` | no | no | `run` |
|
|
267
261
|
|
|
268
|
-
A formatter failure is never an error in any tool. The status stays, and
|
|
262
|
+
A formatter failure is never an error in any tool. The status stays, and no note is added.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@better-fs-tools/write",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Edit, write, and apply_patch tools for TypeScript agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@better-fs-tools/fs": "^0.
|
|
50
|
-
"@better-fs-tools/read": "^0.
|
|
51
|
-
"@better-fs-tools/shell": "^0.
|
|
49
|
+
"@better-fs-tools/fs": "^0.3.0",
|
|
50
|
+
"@better-fs-tools/read": "^0.3.0",
|
|
51
|
+
"@better-fs-tools/shell": "^0.3.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"typebox": "^1.3.16"
|