mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-25 11:44:22 +01:00
feat: add desktop/web app package (#2606)
Co-authored-by: adamdotdevin <2363879+adamdottv@users.noreply.github.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com> Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
@@ -105,7 +105,7 @@ export namespace File {
|
||||
const untrackedFiles = untrackedOutput.trim().split("\n")
|
||||
for (const filepath of untrackedFiles) {
|
||||
try {
|
||||
const content = await Bun.file(path.join(Instance.worktree, filepath)).text()
|
||||
const content = await Bun.file(path.join(Instance.directory, filepath)).text()
|
||||
const lines = content.split("\n").length
|
||||
changedFiles.push({
|
||||
path: filepath,
|
||||
@@ -140,7 +140,7 @@ export namespace File {
|
||||
|
||||
return changedFiles.map((x) => ({
|
||||
...x,
|
||||
path: path.relative(Instance.directory, path.join(Instance.worktree, x.path)),
|
||||
path: path.relative(Instance.directory, x.path),
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -153,11 +153,13 @@ export namespace File {
|
||||
.catch(() => "")
|
||||
.then((x) => x.trim())
|
||||
if (project.vcs === "git") {
|
||||
const diff = await $`git diff ${file}`.cwd(Instance.directory).quiet().nothrow().text()
|
||||
let diff = await $`git diff ${file}`.cwd(Instance.directory).quiet().nothrow().text()
|
||||
if (!diff.trim()) diff = await $`git diff --staged ${file}`.cwd(Instance.directory).quiet().nothrow().text()
|
||||
if (diff.trim()) {
|
||||
const original = await $`git show HEAD:${file}`.cwd(Instance.directory).quiet().nothrow().text()
|
||||
const patch = structuredPatch(file, file, original, content, "old", "new", {
|
||||
context: Infinity,
|
||||
ignoreWhitespace: true,
|
||||
})
|
||||
const diff = formatPatch(patch)
|
||||
return { content, patch, diff }
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Log } from "../util/log"
|
||||
import { Bus } from "../bus"
|
||||
import { describeRoute, generateSpecs, validator, resolver, openAPIRouteHandler } from "hono-openapi"
|
||||
import { Hono } from "hono"
|
||||
import { cors } from "hono/cors"
|
||||
import { streamSSE } from "hono/streaming"
|
||||
import { Session } from "../session"
|
||||
import z from "zod/v4"
|
||||
@@ -114,6 +115,7 @@ export namespace Server {
|
||||
return next()
|
||||
})
|
||||
})
|
||||
.use(cors())
|
||||
.get(
|
||||
"/doc",
|
||||
openAPIRouteHandler(app, {
|
||||
|
||||
Reference in New Issue
Block a user