@theokit/sdk-tools 0.19.0 → 0.20.1

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/dist/index.d.cts CHANGED
@@ -6,17 +6,27 @@ import { InteractiveProvider } from '@theokit/sdk/interactive';
6
6
  /**
7
7
  * `apply_patch` — built-in tool for coding agents.
8
8
  *
9
- * Parses a unified diff string and applies it to the project files.
10
- * Creates `.bak` backups before modifying each file.
9
+ * Codex's V4A patch grammar (`*** Begin Patch` `*** End Patch`): `*** Add/Update/Delete File:`, an
10
+ * optional `*** Move to:`, and `@@`-anchored `+`/`-`/context hunks matched with a context-tolerant ladder
11
+ * (exact → rstrip → trim → unicode). See `internal/v4a-patch.ts` for the parser + matcher.
11
12
  *
12
- * Return shape (always a JSON string):
13
+ * Applied STRICTLY atomically: the whole patch is planned (every file read + new content computed + path
14
+ * security-checked) before ANY write. A parse error, context mismatch, or path violation anywhere ⇒ typed
15
+ * error and ZERO writes (stronger than Codex, which writes file-by-file and can leave partial writes).
16
+ *
17
+ * Return shape (always a JSON string — never throws on a bad patch):
13
18
  * - `{ ok: true, files_patched: string[] }`
14
- * - `{ ok: false, error: 'parse_error' | 'path_traversal' |
15
- * 'forbidden_path' | 'patch_failed' }`
19
+ * - `{ ok: false, error: 'parse_error' | 'path_traversal' | 'forbidden_path' | 'not_found' |
20
+ * 'patch_failed' | 'duplicate_target' | 'file_exists' | 'io_error' }`
21
+ *
22
+ * Security/robustness (M18 review): forbidden secrets (`.env`/`.git`/`node_modules`/`.theo`) are blocked
23
+ * at ANY path depth and against absolute-path spelling; a file touched by two hunks is rejected
24
+ * (`duplicate_target`); Add over an existing file is rejected (`file_exists`); Delete of a missing file
25
+ * is `not_found`; any unexpected fs error maps to `io_error` (the handler never throws).
16
26
  */
17
27
 
18
28
  interface CreateApplyPatchToolOptions {
19
- /** Absolute path to the project root. */
29
+ /** Absolute path to the project root. Every hunk path is gated against this boundary. */
20
30
  projectRoot: string;
21
31
  }
22
32
  declare function createApplyPatchTool(opts: CreateApplyPatchToolOptions): CustomTool;
package/dist/index.d.ts CHANGED
@@ -6,17 +6,27 @@ import { InteractiveProvider } from '@theokit/sdk/interactive';
6
6
  /**
7
7
  * `apply_patch` — built-in tool for coding agents.
8
8
  *
9
- * Parses a unified diff string and applies it to the project files.
10
- * Creates `.bak` backups before modifying each file.
9
+ * Codex's V4A patch grammar (`*** Begin Patch` `*** End Patch`): `*** Add/Update/Delete File:`, an
10
+ * optional `*** Move to:`, and `@@`-anchored `+`/`-`/context hunks matched with a context-tolerant ladder
11
+ * (exact → rstrip → trim → unicode). See `internal/v4a-patch.ts` for the parser + matcher.
11
12
  *
12
- * Return shape (always a JSON string):
13
+ * Applied STRICTLY atomically: the whole patch is planned (every file read + new content computed + path
14
+ * security-checked) before ANY write. A parse error, context mismatch, or path violation anywhere ⇒ typed
15
+ * error and ZERO writes (stronger than Codex, which writes file-by-file and can leave partial writes).
16
+ *
17
+ * Return shape (always a JSON string — never throws on a bad patch):
13
18
  * - `{ ok: true, files_patched: string[] }`
14
- * - `{ ok: false, error: 'parse_error' | 'path_traversal' |
15
- * 'forbidden_path' | 'patch_failed' }`
19
+ * - `{ ok: false, error: 'parse_error' | 'path_traversal' | 'forbidden_path' | 'not_found' |
20
+ * 'patch_failed' | 'duplicate_target' | 'file_exists' | 'io_error' }`
21
+ *
22
+ * Security/robustness (M18 review): forbidden secrets (`.env`/`.git`/`node_modules`/`.theo`) are blocked
23
+ * at ANY path depth and against absolute-path spelling; a file touched by two hunks is rejected
24
+ * (`duplicate_target`); Add over an existing file is rejected (`file_exists`); Delete of a missing file
25
+ * is `not_found`; any unexpected fs error maps to `io_error` (the handler never throws).
16
26
  */
17
27
 
18
28
  interface CreateApplyPatchToolOptions {
19
- /** Absolute path to the project root. */
29
+ /** Absolute path to the project root. Every hunk path is gated against this boundary. */
20
30
  projectRoot: string;
21
31
  }
22
32
  declare function createApplyPatchTool(opts: CreateApplyPatchToolOptions): CustomTool;