|
1 | | -import z from "zod" |
| 1 | +import { Schema } from "effect" |
2 | 2 | import os from "os" |
3 | 3 | import { createWriteStream } from "node:fs" |
4 | 4 | import * as Tool from "./tool" |
@@ -50,20 +50,16 @@ const FILES = new Set([ |
50 | 50 | const FLAGS = new Set(["-destination", "-literalpath", "-path"]) |
51 | 51 | const SWITCHES = new Set(["-confirm", "-debug", "-force", "-nonewline", "-recurse", "-verbose", "-whatif"]) |
52 | 52 |
|
53 | | -const Parameters = z.object({ |
54 | | - command: z.string().describe("The command to execute"), |
55 | | - timeout: z.number().describe("Optional timeout in milliseconds").optional(), |
56 | | - workdir: z |
57 | | - .string() |
58 | | - .describe( |
59 | | - `The working directory to run the command in. Defaults to the current directory. Use this instead of 'cd' commands.`, |
60 | | - ) |
61 | | - .optional(), |
62 | | - description: z |
63 | | - .string() |
64 | | - .describe( |
| 53 | +export const Parameters = Schema.Struct({ |
| 54 | + command: Schema.String.annotate({ description: "The command to execute" }), |
| 55 | + timeout: Schema.optional(Schema.Number).annotate({ description: "Optional timeout in milliseconds" }), |
| 56 | + workdir: Schema.optional(Schema.String).annotate({ |
| 57 | + description: `The working directory to run the command in. Defaults to the current directory. Use this instead of 'cd' commands.`, |
| 58 | + }), |
| 59 | + description: Schema.String.annotate({ |
| 60 | + description: |
65 | 61 | "Clear, concise description of what this command does in 5-10 words. Examples:\nInput: ls\nOutput: Lists files in current directory\n\nInput: git status\nOutput: Shows working tree status\n\nInput: npm install\nOutput: Installs package dependencies\n\nInput: mkdir foo\nOutput: Creates directory 'foo'", |
66 | | - ), |
| 62 | + }), |
67 | 63 | }) |
68 | 64 |
|
69 | 65 | type Part = { |
@@ -587,7 +583,7 @@ export const BashTool = Tool.define( |
587 | 583 | .replaceAll("${maxLines}", String(Truncate.MAX_LINES)) |
588 | 584 | .replaceAll("${maxBytes}", String(Truncate.MAX_BYTES)), |
589 | 585 | parameters: Parameters, |
590 | | - execute: (params: z.infer<typeof Parameters>, ctx: Tool.Context) => |
| 586 | + execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context) => |
591 | 587 | Effect.gen(function* () { |
592 | 588 | const cwd = params.workdir |
593 | 589 | ? yield* resolvePath(params.workdir, Instance.directory, shell) |
|
0 commit comments