sync
This commit is contained in:
@@ -12,6 +12,8 @@ export async function bootstrap<T>(directory: string, cb: () => Promise<T>) {
|
||||
Format.init()
|
||||
LSP.init()
|
||||
Snapshot.init()
|
||||
return cb()
|
||||
const result = await cb()
|
||||
await Instance.dispose()
|
||||
return result
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Ide } from "../../ide"
|
||||
|
||||
import { Flag } from "../../flag/flag"
|
||||
import { Session } from "../../session"
|
||||
import { Instance } from "../../project/instance"
|
||||
|
||||
declare global {
|
||||
const OPENCODE_TUI_PATH: string
|
||||
@@ -146,6 +147,7 @@ export const TuiCommand = cmd({
|
||||
...process.env,
|
||||
CGO_ENABLED: "0",
|
||||
OPENCODE_SERVER: server.url.toString(),
|
||||
OPENCODE_PROJECT: JSON.stringify(Instance.project),
|
||||
},
|
||||
onExit: () => {
|
||||
server.stop()
|
||||
|
||||
@@ -157,6 +157,8 @@ export namespace Config {
|
||||
result.permission = mergeDeep(result.permission ?? {}, JSON.parse(Flag.OPENCODE_PERMISSION))
|
||||
}
|
||||
|
||||
if (!result.username) result.username = os.userInfo().username
|
||||
|
||||
// Handle migration from autoshare to share field
|
||||
if (result.autoshare === true && !result.share) {
|
||||
result.share = "auto"
|
||||
|
||||
@@ -22,6 +22,8 @@ import { Agent } from "../agent/agent"
|
||||
import { Auth } from "../auth"
|
||||
import { Command } from "../command"
|
||||
import { ProjectRoute } from "./project"
|
||||
import { Project } from "../project/project"
|
||||
import { Global } from "../global"
|
||||
|
||||
const ERRORS = {
|
||||
400: {
|
||||
@@ -83,7 +85,27 @@ export namespace Server {
|
||||
return next()
|
||||
})
|
||||
})
|
||||
.route("/project", ProjectRoute)
|
||||
.get(
|
||||
"/project",
|
||||
describeRoute({
|
||||
description: "List all projects",
|
||||
operationId: "project.list",
|
||||
responses: {
|
||||
200: {
|
||||
description: "List of projects",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: resolver(Project.Info.array()),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
const projects = await Project.list()
|
||||
return c.json(projects)
|
||||
},
|
||||
)
|
||||
.get(
|
||||
"/doc",
|
||||
openAPISpecs(app, {
|
||||
@@ -161,6 +183,38 @@ export namespace Server {
|
||||
return c.json(await Config.get())
|
||||
},
|
||||
)
|
||||
.get(
|
||||
"/path",
|
||||
describeRoute({
|
||||
description: "Get the current path",
|
||||
operationId: "path.get",
|
||||
responses: {
|
||||
200: {
|
||||
description: "Path",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: resolver(
|
||||
z
|
||||
.object({
|
||||
state: z.string(),
|
||||
config: z.string(),
|
||||
})
|
||||
.openapi({
|
||||
ref: "Path",
|
||||
}),
|
||||
),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
return c.json({
|
||||
state: Global.Path.state,
|
||||
config: Global.Path.config,
|
||||
})
|
||||
},
|
||||
)
|
||||
.get(
|
||||
"/session",
|
||||
describeRoute({
|
||||
|
||||
Reference in New Issue
Block a user