chore: generate
This commit is contained in:
@@ -279,6 +279,4 @@ export const layer = Layer.effect(
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const defaultLayer = layer.pipe(
|
export const defaultLayer = layer.pipe(Layer.provide(Layer.merge(RipgrepBinary.defaultLayer, AppProcess.defaultLayer)))
|
||||||
Layer.provide(Layer.merge(RipgrepBinary.defaultLayer, AppProcess.defaultLayer)),
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -61,12 +61,18 @@ export namespace RipgrepBinary {
|
|||||||
"-Command",
|
"-Command",
|
||||||
`$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -LiteralPath '${archive.replaceAll("'", "''")}' -DestinationPath '${dir.replaceAll("'", "''")}' -Force`,
|
`$global:ProgressPreference = 'SilentlyContinue'; Expand-Archive -LiteralPath '${archive.replaceAll("'", "''")}' -DestinationPath '${dir.replaceAll("'", "''")}' -Force`,
|
||||||
])
|
])
|
||||||
if (result.code !== 0) throw new Error(result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`)
|
if (result.code !== 0)
|
||||||
|
throw new Error(
|
||||||
|
result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.extension === "tar.gz") {
|
if (config.extension === "tar.gz") {
|
||||||
const result = yield* run("tar", ["-xzf", archive, "-C", dir])
|
const result = yield* run("tar", ["-xzf", archive, "-C", dir])
|
||||||
if (result.code !== 0) throw new Error(result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`)
|
if (result.code !== 0)
|
||||||
|
throw new Error(
|
||||||
|
result.stderr.trim() || result.stdout.trim() || `ripgrep extraction failed with code ${result.code}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const extracted = path.join(
|
const extracted = path.join(
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ export const layer = Layer.effectDiscard(
|
|||||||
toModelOutput: ({ output }) => [
|
toModelOutput: ({ output }) => [
|
||||||
{
|
{
|
||||||
type: "text",
|
type: "text",
|
||||||
text: toModelOutput(output.map((entry) => ({ ...entry, path: path.resolve(location.directory, entry.path) }))),
|
text: toModelOutput(
|
||||||
|
output.map((entry) => ({ ...entry, path: path.resolve(location.directory, entry.path) })),
|
||||||
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
execute: (input, context) =>
|
execute: (input, context) =>
|
||||||
@@ -69,21 +71,23 @@ export const layer = Layer.effectDiscard(
|
|||||||
source: { type: "tool", messageID: context.assistantMessageID, callID: context.toolCallID },
|
source: { type: "tool", messageID: context.assistantMessageID, callID: context.toolCallID },
|
||||||
})
|
})
|
||||||
const cwd = path.resolve(location.directory, input.path ?? ".")
|
const cwd = path.resolve(location.directory, input.path ?? ".")
|
||||||
return yield* ripgrep.glob({
|
return yield* ripgrep
|
||||||
cwd,
|
.glob({
|
||||||
pattern: input.pattern,
|
cwd,
|
||||||
limit: input.limit ?? Number.MAX_SAFE_INTEGER,
|
pattern: input.pattern,
|
||||||
}).pipe(
|
limit: input.limit ?? Number.MAX_SAFE_INTEGER,
|
||||||
Effect.map((result) =>
|
})
|
||||||
result.map(
|
.pipe(
|
||||||
(entry) =>
|
Effect.map((result) =>
|
||||||
new FileSystem.Entry({
|
result.map(
|
||||||
...entry,
|
(entry) =>
|
||||||
path: RelativePath.make(path.relative(location.directory, path.resolve(cwd, entry.path))),
|
new FileSystem.Entry({
|
||||||
}),
|
...entry,
|
||||||
|
path: RelativePath.make(path.relative(location.directory, path.resolve(cwd, entry.path))),
|
||||||
|
}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Effect.mapError(() => new ToolFailure({ message: `Unable to find files matching ${input.pattern}` })),
|
Effect.mapError(() => new ToolFailure({ message: `Unable to find files matching ${input.pattern}` })),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -92,34 +92,37 @@ export const layer = Layer.effectDiscard(
|
|||||||
})
|
})
|
||||||
const target = path.resolve(location.directory, input.path ?? ".")
|
const target = path.resolve(location.directory, input.path ?? ".")
|
||||||
const info = yield* fs.stat(target).pipe(Effect.catch(() => Effect.succeed(undefined)))
|
const info = yield* fs.stat(target).pipe(Effect.catch(() => Effect.succeed(undefined)))
|
||||||
return yield* ripgrep.grep({
|
return yield* ripgrep
|
||||||
cwd: info?.type === "Directory" ? target : path.dirname(target),
|
.grep({
|
||||||
pattern: input.pattern,
|
cwd: info?.type === "Directory" ? target : path.dirname(target),
|
||||||
file: info?.type === "File" ? path.basename(target) : undefined,
|
pattern: input.pattern,
|
||||||
include: input.include,
|
file: info?.type === "File" ? path.basename(target) : undefined,
|
||||||
limit: input.limit ?? Number.MAX_SAFE_INTEGER,
|
include: input.include,
|
||||||
}).pipe(
|
limit: input.limit ?? Number.MAX_SAFE_INTEGER,
|
||||||
Effect.map((result) =>
|
})
|
||||||
result.map(
|
.pipe(
|
||||||
(match) =>
|
Effect.map((result) =>
|
||||||
new FileSystem.Match({
|
result.map(
|
||||||
...match,
|
(match) =>
|
||||||
entry: new FileSystem.Entry({
|
new FileSystem.Match({
|
||||||
...match.entry,
|
...match,
|
||||||
path: RelativePath.make(
|
entry: new FileSystem.Entry({
|
||||||
path.relative(
|
...match.entry,
|
||||||
location.directory,
|
path: RelativePath.make(
|
||||||
path.resolve(info?.type === "Directory" ? target : path.dirname(target), match.entry.path),
|
path.relative(
|
||||||
|
location.directory,
|
||||||
|
path.resolve(
|
||||||
|
info?.type === "Directory" ? target : path.dirname(target),
|
||||||
|
match.entry.path,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
}),
|
||||||
}),
|
}),
|
||||||
}),
|
),
|
||||||
),
|
),
|
||||||
),
|
)
|
||||||
)
|
}).pipe(Effect.mapError(() => new ToolFailure({ message: `Unable to grep for ${input.pattern}` }))),
|
||||||
}).pipe(
|
|
||||||
Effect.mapError(() => new ToolFailure({ message: `Unable to grep for ${input.pattern}` })),
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
.pipe(Effect.orDie)
|
.pipe(Effect.orDie)
|
||||||
|
|||||||
@@ -40,5 +40,4 @@ describe("Ripgrep", () => {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,12 +26,8 @@ describe("Ripgrep", () => {
|
|||||||
expect(files.map((item) => item.path)).toContain(RelativePath.make(".git/config"))
|
expect(files.map((item) => item.path)).toContain(RelativePath.make(".git/config"))
|
||||||
|
|
||||||
const matches = yield* ripgrep.grep({ cwd: tmp.path, pattern: "needle", include: "config", limit: 10 })
|
const matches = yield* ripgrep.grep({ cwd: tmp.path, pattern: "needle", include: "config", limit: 10 })
|
||||||
expect(matches.map((item) => item.entry.path)).toContain(
|
expect(matches.map((item) => item.entry.path)).toContain(RelativePath.make(".opencode/config"))
|
||||||
RelativePath.make(".opencode/config"),
|
expect(matches.map((item) => item.entry.path)).toContain(RelativePath.make(".git/config"))
|
||||||
)
|
|
||||||
expect(matches.map((item) => item.entry.path)).toContain(
|
|
||||||
RelativePath.make(".git/config"),
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
|
(tmp) => Effect.promise(() => tmp[Symbol.asyncDispose]()),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -22,11 +22,7 @@ const FileSearchCommand = effectCmd({
|
|||||||
description: "Search query",
|
description: "Search query",
|
||||||
}),
|
}),
|
||||||
handler: Effect.fn("Cli.debug.file.search")(function* (args) {
|
handler: Effect.fn("Cli.debug.file.search")(function* (args) {
|
||||||
const results = yield* Effect.orDie(
|
const results = yield* Effect.orDie(filesystem(FileSystem.Service.use((svc) => svc.find({ query: args.query }))))
|
||||||
filesystem(
|
|
||||||
FileSystem.Service.use((svc) => svc.find({ query: args.query })),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
process.stdout.write(results.map((item) => item.path).join(EOL) + EOL)
|
process.stdout.write(results.map((item) => item.path).join(EOL) + EOL)
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -65,10 +61,6 @@ export const FileCommand = cmd({
|
|||||||
command: "file",
|
command: "file",
|
||||||
describe: "file system debugging utilities",
|
describe: "file system debugging utilities",
|
||||||
builder: (yargs) =>
|
builder: (yargs) =>
|
||||||
yargs
|
yargs.command(FileReadCommand).command(FileListCommand).command(FileSearchCommand).demandCommand(),
|
||||||
.command(FileReadCommand)
|
|
||||||
.command(FileListCommand)
|
|
||||||
.command(FileSearchCommand)
|
|
||||||
.demandCommand(),
|
|
||||||
async handler() {},
|
async handler() {},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4129,7 +4129,6 @@ export type FileSystemContent = {
|
|||||||
|
|
||||||
export type FileSystemEntry = {
|
export type FileSystemEntry = {
|
||||||
path: string
|
path: string
|
||||||
uri: string
|
|
||||||
type: "file" | "directory"
|
type: "file" | "directory"
|
||||||
mime: string
|
mime: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25071,9 +25071,6 @@
|
|||||||
"path": {
|
"path": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"uri": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"type": {
|
"type": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["file", "directory"]
|
"enum": ["file", "directory"]
|
||||||
@@ -25082,7 +25079,7 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["path", "uri", "type", "mime"],
|
"required": ["path", "type", "mime"],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"CommandV2Info": {
|
"CommandV2Info": {
|
||||||
|
|||||||
Reference in New Issue
Block a user