fix(scout): widen repo tool schema types
This commit is contained in:
parent
343e68853c
commit
35a19df57d
2 changed files with 16 additions and 5 deletions
|
|
@ -8,7 +8,12 @@ import DESCRIPTION from "./repo_clone.txt"
|
||||||
import * as Tool from "./tool"
|
import * as Tool from "./tool"
|
||||||
import { parseRepositoryReference, repositoryCachePath, sameRepositoryReference } from "@/util/repository"
|
import { parseRepositoryReference, repositoryCachePath, sameRepositoryReference } from "@/util/repository"
|
||||||
|
|
||||||
const parameters = z.object({
|
type Parameters = {
|
||||||
|
repository: string
|
||||||
|
refresh?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const parameters: z.ZodType<Parameters> = z.object({
|
||||||
repository: z
|
repository: z
|
||||||
.string()
|
.string()
|
||||||
.describe("Repository to clone, as a git URL, host/path reference, or GitHub owner/repo shorthand"),
|
.describe("Repository to clone, as a git URL, host/path reference, or GitHub owner/repo shorthand"),
|
||||||
|
|
@ -53,7 +58,7 @@ export const RepoCloneTool = Tool.define<typeof parameters, Metadata, AppFileSys
|
||||||
return {
|
return {
|
||||||
description: DESCRIPTION,
|
description: DESCRIPTION,
|
||||||
parameters,
|
parameters,
|
||||||
execute: (params: z.infer<typeof parameters>, ctx: Tool.Context<Metadata>) =>
|
execute: (params: Parameters, ctx: Tool.Context<Metadata>) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const reference = parseRepositoryReference(params.repository)
|
const reference = parseRepositoryReference(params.repository)
|
||||||
if (!reference) throw new Error("Repository must be a git URL, host/path reference, or GitHub owner/repo shorthand")
|
if (!reference) throw new Error("Repository must be a git URL, host/path reference, or GitHub owner/repo shorthand")
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,13 @@ import * as Tool from "./tool"
|
||||||
import { parseRepositoryReference, repositoryCachePath } from "@/util/repository"
|
import { parseRepositoryReference, repositoryCachePath } from "@/util/repository"
|
||||||
import { Instance } from "@/project/instance"
|
import { Instance } from "@/project/instance"
|
||||||
|
|
||||||
const parameters = z
|
type Parameters = {
|
||||||
|
repository?: string
|
||||||
|
path?: string
|
||||||
|
depth?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const parameters: z.ZodType<Parameters> = z
|
||||||
.object({
|
.object({
|
||||||
repository: z
|
repository: z
|
||||||
.string()
|
.string()
|
||||||
|
|
@ -84,7 +90,7 @@ export const RepoOverviewTool = Tool.define<typeof parameters, Metadata, AppFile
|
||||||
const fs = yield* AppFileSystem.Service
|
const fs = yield* AppFileSystem.Service
|
||||||
const git = yield* Git.Service
|
const git = yield* Git.Service
|
||||||
|
|
||||||
const resolveTarget = Effect.fn("RepoOverviewTool.resolveTarget")(function* (params: z.infer<typeof parameters>) {
|
const resolveTarget = Effect.fn("RepoOverviewTool.resolveTarget")(function* (params: Parameters) {
|
||||||
if (params.path) {
|
if (params.path) {
|
||||||
const full = path.isAbsolute(params.path) ? params.path : path.resolve(Instance.directory, params.path)
|
const full = path.isAbsolute(params.path) ? params.path : path.resolve(Instance.directory, params.path)
|
||||||
return { path: full, repository: params.repository }
|
return { path: full, repository: params.repository }
|
||||||
|
|
@ -147,7 +153,7 @@ export const RepoOverviewTool = Tool.define<typeof parameters, Metadata, AppFile
|
||||||
return {
|
return {
|
||||||
description: DESCRIPTION,
|
description: DESCRIPTION,
|
||||||
parameters,
|
parameters,
|
||||||
execute: (params: z.infer<typeof parameters>, ctx: Tool.Context<Metadata>) =>
|
execute: (params: Parameters, ctx: Tool.Context<Metadata>) =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const target = yield* resolveTarget(params)
|
const target = yield* resolveTarget(params)
|
||||||
const depth = params.depth ?? 3
|
const depth = params.depth ?? 3
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue