Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion packages/app/src/components/prompt-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,19 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
const seen = new Set(open)
const pinned: AtOption[] = open.map((path) => ({ type: "file", path, display: path, recent: true }))
if (!query.trim()) return [...agents, ...pinned]
const paths = await files.searchFilesAndDirectories(query)
const pathy = /[./\\]/.test(query)
const seek = query.replaceAll("\\", "/")
const paths = await files.searchFiles(seek)
const fileOptions: AtOption[] = paths
.filter((path) => !seen.has(path))
.map((path) => ({ type: "file", path, display: path }))
if (pathy) return fileOptions
return [...agents, ...pinned, ...fileOptions]
},
key: atKey,
filterKeys: ["display"],
stale: false,
fuzzy: (query) => !/[./\\]/.test(query),
groupBy: (item) => {
if (item.type === "agent") return "agent"
if (item.recent) return "recent"
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"@aws-sdk/credential-providers": "3.993.0",
"@clack/prompts": "1.0.0-alpha.1",
"@effect/platform-node": "catalog:",
"@ff-labs/fff-node": "0.4.2",
"@hono/standard-validator": "0.1.5",
"@hono/zod-validator": "catalog:",
"@modelcontextprotocol/sdk": "1.27.1",
Expand All @@ -108,7 +109,6 @@
"@solid-primitives/event-bus": "1.1.2",
"@solid-primitives/scheduled": "1.5.2",
"@standard-schema/spec": "1.0.0",
"@zip.js/zip.js": "2.7.62",
"ai": "catalog:",
"ai-gateway-provider": "2.3.1",
"bonjour-service": "1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/cli/cmd/debug/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { EOL } from "os"
import { File } from "../../../file"
import { bootstrap } from "../../bootstrap"
import { cmd } from "../cmd"
import { Ripgrep } from "@/file/ripgrep"
import { Fff } from "@/file/fff"

const FileSearchCommand = cmd({
command: "search <query>",
Expand Down Expand Up @@ -77,7 +77,7 @@ const FileTreeCommand = cmd({
default: process.cwd(),
}),
async handler(args) {
const files = await Ripgrep.tree({ cwd: args.dir, limit: 200 })
const files = await Fff.tree({ cwd: args.dir, limit: 200 })
console.log(JSON.stringify(files, null, 2))
},
})
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode/src/cli/cmd/debug/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { cmd } from "../cmd"
import { ConfigCommand } from "./config"
import { FileCommand } from "./file"
import { LSPCommand } from "./lsp"
import { RipgrepCommand } from "./ripgrep"
import { SearchCommand } from "./search"
import { ScrapCommand } from "./scrap"
import { SkillCommand } from "./skill"
import { SnapshotCommand } from "./snapshot"
Expand All @@ -17,7 +17,7 @@ export const DebugCommand = cmd({
yargs
.command(ConfigCommand)
.command(LSPCommand)
.command(RipgrepCommand)
.command(SearchCommand)
.command(FileCommand)
.command(ScrapCommand)
.command(SkillCommand)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
import { EOL } from "os"
import { Ripgrep } from "../../../file/ripgrep"
import { Fff } from "../../../file/fff"
import { Instance } from "../../../project/instance"
import { bootstrap } from "../../bootstrap"
import { cmd } from "../cmd"
import { Glob } from "@/util/glob"

export const RipgrepCommand = cmd({
command: "rg",
describe: "ripgrep debugging utilities",
builder: (yargs) => yargs.command(TreeCommand).command(FilesCommand).command(SearchCommand).demandCommand(),
export const SearchCommand = cmd({
command: "search",
describe: "fff search debugging utilities",
builder: (yargs) => yargs.command(TreeCommand).command(FilesCommand).command(ContentCommand).demandCommand(),
async handler() {},
})

const TreeCommand = cmd({
command: "tree",
describe: "show file tree using ripgrep",
describe: "show file tree using fff",
builder: (yargs) =>
yargs.option("limit", {
type: "number",
}),
async handler(args) {
await bootstrap(process.cwd(), async () => {
process.stdout.write((await Ripgrep.tree({ cwd: Instance.directory, limit: args.limit })) + EOL)
process.stdout.write((await Fff.tree({ cwd: Instance.directory, limit: args.limit })) + EOL)
})
},
})

const FilesCommand = cmd({
command: "files",
describe: "list files using ripgrep",
describe: "list files using fff",
builder: (yargs) =>
yargs
.option("query", {
Expand All @@ -44,22 +45,24 @@ const FilesCommand = cmd({
}),
async handler(args) {
await bootstrap(process.cwd(), async () => {
const files: string[] = []
for await (const file of Ripgrep.files({
const limit = args.limit ?? 100
const files = (await Glob.scan("**/*", {
cwd: Instance.directory,
glob: args.glob ? [args.glob] : undefined,
})) {
files.push(file)
if (args.limit && files.length >= args.limit) break
}
include: "file",
dot: true,
}))
.map((x) => x.replaceAll("\\", "/"))
.filter((x) => Fff.allowed({ rel: x, hidden: true, glob: args.glob ? [args.glob] : undefined }))
.filter((x) => !args.query || x.includes(args.query))
.slice(0, limit)
process.stdout.write(files.join(EOL) + EOL)
})
},
})

const SearchCommand = cmd({
command: "search <pattern>",
describe: "search file contents using ripgrep",
const ContentCommand = cmd({
command: "content <pattern>",
describe: "search file contents using fff",
builder: (yargs) =>
yargs
.positional("pattern", {
Expand All @@ -76,12 +79,12 @@ const SearchCommand = cmd({
description: "Limit number of results",
}),
async handler(args) {
const results = await Ripgrep.search({
const rows = await Fff.search({
cwd: process.cwd(),
pattern: args.pattern,
glob: args.glob as string[] | undefined,
limit: args.limit,
})
process.stdout.write(JSON.stringify(results, null, 2) + EOL)
process.stdout.write(JSON.stringify(rows, null, 2) + EOL)
},
})
Loading
Loading