fix(scout): type repo tool definitions
This commit is contained in:
parent
0db04ef69f
commit
343e68853c
2 changed files with 15 additions and 5 deletions
|
|
@ -15,6 +15,16 @@ const parameters = z.object({
|
||||||
refresh: z.boolean().optional().describe("When true, fetches the latest remote state into the managed cache"),
|
refresh: z.boolean().optional().describe("When true, fetches the latest remote state into the managed cache"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
type Metadata = {
|
||||||
|
repository: string
|
||||||
|
host: string
|
||||||
|
remote: string
|
||||||
|
localPath: string
|
||||||
|
status: "cached" | "cloned" | "refreshed"
|
||||||
|
head?: string
|
||||||
|
branch?: string
|
||||||
|
}
|
||||||
|
|
||||||
function statusForRepository(input: { reuse: boolean; refresh?: boolean }) {
|
function statusForRepository(input: { reuse: boolean; refresh?: boolean }) {
|
||||||
if (!input.reuse) return "cloned" as const
|
if (!input.reuse) return "cloned" as const
|
||||||
if (input.refresh) return "refreshed" as const
|
if (input.refresh) return "refreshed" as const
|
||||||
|
|
@ -34,7 +44,7 @@ function resetTarget(input: {
|
||||||
return "HEAD"
|
return "HEAD"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RepoCloneTool = Tool.define(
|
export const RepoCloneTool = Tool.define<typeof parameters, Metadata, AppFileSystem.Service | Git.Service>(
|
||||||
"repo_clone",
|
"repo_clone",
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const fs = yield* AppFileSystem.Service
|
const fs = yield* AppFileSystem.Service
|
||||||
|
|
@ -43,7 +53,7 @@ export const RepoCloneTool = Tool.define(
|
||||||
return {
|
return {
|
||||||
description: DESCRIPTION,
|
description: DESCRIPTION,
|
||||||
parameters,
|
parameters,
|
||||||
execute: (params: z.infer<typeof parameters>, ctx: Tool.Context) =>
|
execute: (params: z.infer<typeof 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")
|
||||||
|
|
@ -137,6 +147,6 @@ export const RepoCloneTool = Tool.define(
|
||||||
(lock) => Effect.promise(() => lock.release()).pipe(Effect.ignore),
|
(lock) => Effect.promise(() => lock.release()).pipe(Effect.ignore),
|
||||||
)
|
)
|
||||||
}).pipe(Effect.orDie),
|
}).pipe(Effect.orDie),
|
||||||
}
|
} satisfies Tool.DefWithoutID<typeof parameters, Metadata>
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,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) =>
|
execute: (params: z.infer<typeof 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
|
||||||
|
|
@ -233,6 +233,6 @@ export const RepoOverviewTool = Tool.define<typeof parameters, Metadata, AppFile
|
||||||
].join("\n"),
|
].join("\n"),
|
||||||
}
|
}
|
||||||
}).pipe(Effect.orDie),
|
}).pipe(Effect.orDie),
|
||||||
}
|
} satisfies Tool.DefWithoutID<typeof parameters, Metadata>
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue