mirror of
https://github.com/sst/opencode.git
synced 2025-12-23 10:11:41 +00:00
Merge branch 'dev' into opentui
This commit is contained in:
commit
0d36150f19
2 changed files with 11 additions and 3 deletions
|
|
@ -132,7 +132,7 @@ export default function Home() {
|
|||
<button data-copy data-slot="command" onClick={handleCopyClick}>
|
||||
<span>
|
||||
<span data-slot="protocol">npm i -g </span>
|
||||
<span data-slot="highlight">opencode</span>
|
||||
<span data-slot="highlight">opencode-ai</span>
|
||||
</span>
|
||||
<CopyStatus />
|
||||
</button>
|
||||
|
|
@ -141,7 +141,7 @@ export default function Home() {
|
|||
<button data-copy data-slot="command" onClick={handleCopyClick}>
|
||||
<span>
|
||||
<span data-slot="protocol">bun add -g </span>
|
||||
<span data-slot="highlight">opencode</span>
|
||||
<span data-slot="highlight">opencode-ai</span>
|
||||
</span>
|
||||
<CopyStatus />
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ export namespace File {
|
|||
let current = file
|
||||
while (true) {
|
||||
const dir = path.dirname(current)
|
||||
if (dir === ".") break
|
||||
if (dir === current) break
|
||||
current = dir
|
||||
if (set.has(dir)) continue
|
||||
|
|
@ -113,6 +114,10 @@ export namespace File {
|
|||
}
|
||||
})
|
||||
|
||||
export function init() {
|
||||
state()
|
||||
}
|
||||
|
||||
export async function status() {
|
||||
const project = Instance.project
|
||||
if (project.vcs !== "git") return []
|
||||
|
|
@ -244,10 +249,13 @@ export namespace File {
|
|||
}
|
||||
|
||||
export async function search(input: { query: string; limit?: number }) {
|
||||
log.info("search", { query: input.query })
|
||||
const limit = input.limit ?? 100
|
||||
const result = await state().then((x) => x.files())
|
||||
const items = input.query ? [...result.files, ...result.dirs] : [...result.dirs]
|
||||
if (!input.query) return result.dirs.toSorted()
|
||||
const items = [...result.files, ...result.dirs]
|
||||
const sorted = fuzzysort.go(input.query, items, { limit: limit }).map((r) => r.target)
|
||||
log.info("search", { query: input.query, results: sorted.length })
|
||||
return sorted
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue