Skip to content
Closed
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
149 changes: 0 additions & 149 deletions packages/console/app/.opencode/agent/css.md

This file was deleted.

8 changes: 7 additions & 1 deletion packages/opencode/src/cli/cmd/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ export const SessionListCommand = cmd({
describe: "limit to N most recent sessions",
type: "number",
})
.option("all", {
alias: "a",
describe: "show sessions from all directories in the project",
type: "boolean",
default: false,
})
.option("format", {
describe: "output format",
type: "string",
Expand All @@ -62,7 +68,7 @@ export const SessionListCommand = cmd({
handler: async (args) => {
await bootstrap(process.cwd(), async () => {
const sessions = []
for await (const session of Session.list()) {
for await (const session of Session.list({ all: args.all })) {
if (!session.parentID) {
sessions.push(session)
}
Expand Down
16 changes: 9 additions & 7 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,15 @@ export namespace Config {
})
export type Permission = z.infer<typeof Permission>

export const Command = z.object({
template: z.string(),
description: z.string().optional(),
agent: z.string().optional(),
model: z.string().optional(),
subtask: z.boolean().optional(),
})
export const Command = z
.object({
template: z.string(),
description: z.string().optional(),
agent: z.string().optional(),
model: z.string().optional(),
subtask: z.boolean().optional(),
})
.passthrough()
export type Command = z.infer<typeof Command>

export const Agent = z
Expand Down
8 changes: 5 additions & 3 deletions packages/opencode/src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ export namespace Server {
"/session",
describeRoute({
summary: "List sessions",
description: "Get a list of all OpenCode sessions, sorted by most recently updated.",
description:
"Get a list of OpenCode sessions. By default, returns sessions from the current directory. Use ?all=true to get all sessions in the project.",
operationId: "session.list",
responses: {
200: {
Expand All @@ -702,9 +703,10 @@ export namespace Server {
},
}),
async (c) => {
const sessions = await Array.fromAsync(Session.list())
const all = c.req.query("all") === "true"
const sessions = await Array.fromAsync(Session.list({ all }))
pipe(
await Array.fromAsync(Session.list()),
sessions,
filter((s) => !s.time.archived),
sortBy((s) => s.time.updated),
)
Expand Down
17 changes: 15 additions & 2 deletions packages/opencode/src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,23 @@ export namespace Session {
},
)

export async function* list() {
export interface ListOptions {
/**
* When true, returns all sessions for the project regardless of directory.
* When false (default), only returns sessions created in the current directory.
*/
all?: boolean
}

export async function* list(options?: ListOptions) {
const project = Instance.project
const currentDirectory = Instance.directory
for (const item of await Storage.list(["session", project.id])) {
yield Storage.read<Info>(item)
const session = await Storage.read<Info>(item)
if (options?.all !== true && session.directory !== currentDirectory) {
continue
}
yield session
}
}

Expand Down