@warlock.js/ai-workspace 5.39.2 → 5.40.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.
Files changed (61) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +2 -2
  3. package/cjs/index.cjs +691 -114
  4. package/cjs/index.cjs.map +1 -1
  5. package/esm/contracts/index.d.mts +2 -2
  6. package/esm/contracts/tool-io.type.d.mts +32 -1
  7. package/esm/contracts/tool-io.type.d.mts.map +1 -1
  8. package/esm/contracts/workspace-ops.contract.d.mts +10 -1
  9. package/esm/contracts/workspace-ops.contract.d.mts.map +1 -1
  10. package/esm/contracts/workspace.contract.d.mts +7 -1
  11. package/esm/contracts/workspace.contract.d.mts.map +1 -1
  12. package/esm/errors.d.mts +17 -1
  13. package/esm/errors.d.mts.map +1 -1
  14. package/esm/errors.mjs +1 -0
  15. package/esm/errors.mjs.map +1 -1
  16. package/esm/index.d.mts +6 -2
  17. package/esm/index.mjs +5 -1
  18. package/esm/ops.d.mts.map +1 -1
  19. package/esm/ops.mjs +16 -0
  20. package/esm/ops.mjs.map +1 -1
  21. package/esm/patch/apply-hunks.d.mts +14 -0
  22. package/esm/patch/apply-hunks.d.mts.map +1 -0
  23. package/esm/patch/apply-hunks.mjs +89 -0
  24. package/esm/patch/apply-hunks.mjs.map +1 -0
  25. package/esm/patch/apply-patch-generic.d.mts +14 -0
  26. package/esm/patch/apply-patch-generic.d.mts.map +1 -0
  27. package/esm/patch/apply-patch-generic.mjs +68 -0
  28. package/esm/patch/apply-patch-generic.mjs.map +1 -0
  29. package/esm/patch/execute-patch.mjs +151 -0
  30. package/esm/patch/execute-patch.mjs.map +1 -0
  31. package/esm/patch/parse-patch.d.mts +45 -0
  32. package/esm/patch/parse-patch.d.mts.map +1 -0
  33. package/esm/patch/parse-patch.mjs +201 -0
  34. package/esm/patch/parse-patch.mjs.map +1 -0
  35. package/esm/tools/apply-patch.d.mts +27 -0
  36. package/esm/tools/apply-patch.d.mts.map +1 -0
  37. package/esm/tools/apply-patch.mjs +61 -0
  38. package/esm/tools/apply-patch.mjs.map +1 -0
  39. package/esm/tools/edit-file.mjs +1 -1
  40. package/esm/tools/glob.mjs +1 -1
  41. package/esm/tools/grep.mjs +1 -1
  42. package/esm/tools/json-schemas.mjs +10 -1
  43. package/esm/tools/json-schemas.mjs.map +1 -1
  44. package/esm/tools/list-dir.mjs +1 -1
  45. package/esm/tools/multi-edit.mjs +1 -1
  46. package/esm/tools/read-file.mjs +1 -1
  47. package/esm/tools/run-shell.mjs +1 -1
  48. package/esm/tools/run-tests.mjs +1 -1
  49. package/esm/tools/shell-kill.mjs +1 -1
  50. package/esm/tools/shell-output.mjs +1 -1
  51. package/esm/tools/todo.mjs +1 -1
  52. package/esm/tools/write-file.mjs +1 -1
  53. package/esm/workspace.d.mts.map +1 -1
  54. package/esm/workspace.mjs +9 -0
  55. package/esm/workspace.mjs.map +1 -1
  56. package/llms-full.txt +7 -6
  57. package/llms.txt +2 -2
  58. package/package.json +3 -3
  59. package/skills/build-loop-agent/SKILL.md +1 -1
  60. package/skills/index.md +1 -1
  61. package/skills/use-a-workspace/SKILL.md +5 -4
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All notable changes to `@warlock.js/ai-workspace` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.40.0 - 2026-10-29
8
+
9
+ ### Added
10
+
11
+ - `apply_patch` tool and `ws.applyPatch({ patch, dryRun? })`: apply a unified diff (plain or `git diff` style) that modifies, creates, deletes and renames several files in one call. The patch is atomic: every hunk is checked first and the files are written only if all apply, with a rollback if a write fails. Paths go through the workspace jail (`..`, absolute paths and symlinks out are refused), hunks are matched by context so small line drift is fine, CRLF and LF files keep their line endings, and binary patches or binary target files are refused with a clear error. `apply_patch` is part of `tools.all()` and is left out of `readonly()`.
12
+ - `WorkspaceEditError.type` gains `"patch-invalid"`, `"hunk-failed"` (with `hunkIndex`), `"binary-file"`, `"file-exists"` and `"file-missing"`.
13
+ - `parsePatch()` and `applyHunks()` are exported for applying a unified diff to a string without a workspace.
14
+ - `applyPatch` is optional on a custom `WorkspaceOps`: an implementation without it still gets `apply_patch` and `ws.applyPatch()`, built on its `exists`, `readFile`, `writeFile` and `remove` with the same all-or-nothing behaviour (also exported as `applyPatchWithOps`).
15
+ - `ApplyPatchInput`, `ApplyPatchResult` and `ApplyPatchFileResult` types; `"applyPatch"` joins `WorkspaceToolName`.
16
+
17
+ ### Changed
18
+
19
+ - The package skill description now names the read, write and test tools (`makeReadFileTool`, `makeWriteFileTool`, `makeRunTestsTool`) and the "apply a patch" phrasing, so agents find them from the skill listing alone.
20
+
7
21
  ## 5.34.3 - 2026-10-20
8
22
 
9
23
  ### Changed
package/README.md CHANGED
@@ -129,11 +129,11 @@ for (const file of await ws.glob("src/models/**/*.ts")) {
129
129
  and redirections kept inside the jail.
130
130
  - **Backends** — `local` (default; `@warlock.js/fs` + `node:child_process`) and
131
131
  `mock` (in-memory, for hermetic disk-free tests).
132
- - **Tools** under `ws.tools.*` — `read_file`, `edit_file`, `multi_edit`, `write_file`,
132
+ - **Tools** under `ws.tools.*` — `read_file`, `edit_file`, `multi_edit`, `apply_patch`, `write_file`,
133
133
  `list_dir`, `run_shell` (optionally in the background), `shell_output`,
134
134
  `shell_kill`, `run_tests`, `grep`, `glob`, `todo_write`, `todo_read` — each a
135
135
  `ToolContract` (with a JSON Schema of its input) ready for `ai.agent({ tools })`.
136
- - **Direct methods** — `readFile` / `writeFile` / `editFile` / `multiEdit` /
136
+ - **Direct methods** — `readFile` / `writeFile` / `editFile` / `multiEdit` / `applyPatch` /
137
137
  `listDir` / `exec` / `startShell` / `shellOutput` / `shellKill` / `listShells` /
138
138
  `grep` / `glob` / `exists` / `mkdir` / `remove` / `readTodos` / `writeTodos`,
139
139
  sharing the exact same policy seam, and `dispose()`.