core: sync updates across opencode, sdk, tui, and plugin components
This commit is contained in:
@@ -7,7 +7,6 @@ import fs from "fs"
|
||||
import ignore from "ignore"
|
||||
import { Log } from "../util/log"
|
||||
import { Instance } from "../project/instance"
|
||||
import { Project } from "../project/project"
|
||||
|
||||
export namespace File {
|
||||
const log = Log.create({ service: "file" })
|
||||
|
||||
@@ -1,26 +1,48 @@
|
||||
import { Hono } from "hono"
|
||||
import { describeRoute } from "hono-openapi"
|
||||
import { resolver, validator as zValidator } from "hono-openapi/zod"
|
||||
import { resolver } from "hono-openapi/zod"
|
||||
import { Instance } from "../project/instance"
|
||||
import { Project } from "../project/project"
|
||||
|
||||
export const ProjectRoute = new Hono().get(
|
||||
"/",
|
||||
describeRoute({
|
||||
description: "List all projects",
|
||||
operationId: "project.list",
|
||||
responses: {
|
||||
200: {
|
||||
description: "List of projects",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: resolver(Project.Info.array()),
|
||||
export const ProjectRoute = new Hono()
|
||||
.get(
|
||||
"/",
|
||||
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)
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
const projects = await Project.list()
|
||||
return c.json(projects)
|
||||
},
|
||||
)
|
||||
)
|
||||
.get(
|
||||
"/current",
|
||||
describeRoute({
|
||||
description: "Get the current project",
|
||||
operationId: "butt.current",
|
||||
responses: {
|
||||
200: {
|
||||
description: "Current project",
|
||||
content: {
|
||||
"application/json": {
|
||||
schema: resolver(Project.Info),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
async (c) => {
|
||||
return c.json(Instance.project)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -21,8 +21,8 @@ import { Instance } from "../project/instance"
|
||||
import { Agent } from "../agent/agent"
|
||||
import { Auth } from "../auth"
|
||||
import { Command } from "../command"
|
||||
import { Project } from "../project/project"
|
||||
import { Global } from "../global"
|
||||
import { ProjectRoute } from "./project"
|
||||
|
||||
const ERRORS = {
|
||||
400: {
|
||||
@@ -85,27 +85,6 @@ export namespace Server {
|
||||
})
|
||||
})
|
||||
.use(zValidator("query", z.object({ directory: z.string().optional() })))
|
||||
.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, {
|
||||
@@ -119,6 +98,7 @@ export namespace Server {
|
||||
},
|
||||
}),
|
||||
)
|
||||
.route("/project", ProjectRoute)
|
||||
.get(
|
||||
"/event",
|
||||
describeRoute({
|
||||
@@ -198,6 +178,8 @@ export namespace Server {
|
||||
.object({
|
||||
state: z.string(),
|
||||
config: z.string(),
|
||||
worktree: z.string(),
|
||||
directory: z.string(),
|
||||
})
|
||||
.openapi({
|
||||
ref: "Path",
|
||||
@@ -212,6 +194,8 @@ export namespace Server {
|
||||
return c.json({
|
||||
state: Global.Path.state,
|
||||
config: Global.Path.config,
|
||||
worktree: Instance.worktree,
|
||||
directory: Instance.directory,
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1257,7 +1257,7 @@ export namespace Session {
|
||||
const filename = match[1]
|
||||
const filepath = filename.startsWith("~/")
|
||||
? path.join(os.homedir(), filename.slice(2))
|
||||
: path.join(app.path.cwd, filename)
|
||||
: path.join(Instance.worktree, filename)
|
||||
|
||||
parts.push({
|
||||
type: "file",
|
||||
@@ -1777,6 +1777,6 @@ export namespace Session {
|
||||
},
|
||||
],
|
||||
})
|
||||
await Project.setInitialized()
|
||||
await Project.setInitialized(Instance.project.id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Ripgrep } from "../file/ripgrep"
|
||||
import { Global } from "../global"
|
||||
import { Filesystem } from "../util/filesystem"
|
||||
import { Config } from "../config/config"
|
||||
import { Project } from "../project/project"
|
||||
|
||||
import { Instance } from "../project/instance"
|
||||
import path from "path"
|
||||
import os from "os"
|
||||
|
||||
Reference in New Issue
Block a user