Skip to content

Commit 61160dc

Browse files
committed
docs: readme
1 parent 98734ff commit 61160dc

5 files changed

Lines changed: 48 additions & 24 deletions

File tree

README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,6 @@ $ bun run packages/opencode/src/index.ts
5252

5353
### FAQ
5454

55-
#### How do I use this with OpenRouter?
56-
57-
OpenRouter is not in the Models.dev database yet, but you can configure it manually.
58-
59-
```json title="opencode.json"
60-
{
61-
"$schema": "https://opencode.ai/config.json",
62-
"provider": {
63-
"openrouter": {
64-
"npm": "@openrouter/ai-sdk-provider",
65-
"name": "OpenRouter",
66-
"options": {},
67-
"models": {
68-
"anthropic/claude-3.5-sonnet": {
69-
"name": "Claude 3.5 Sonnet"
70-
}
71-
}
72-
}
73-
}
74-
}
75-
```
76-
77-
And then to configure an api key you can do `opencode auth login` and select "Other -> 'openrouter'"
78-
7955
#### How is this different than Claude Code?
8056

8157
It's very similar to Claude Code in terms of capability. Here are the key differences:

packages/opencode/src/server/server.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,34 @@ export namespace Server {
290290
return c.json(session)
291291
},
292292
)
293+
.post(
294+
"/session_unshare",
295+
describeRoute({
296+
description: "Unshare the session",
297+
responses: {
298+
200: {
299+
description: "Successfully unshared session",
300+
content: {
301+
"application/json": {
302+
schema: resolver(Session.Info),
303+
},
304+
},
305+
},
306+
},
307+
}),
308+
zValidator(
309+
"json",
310+
z.object({
311+
sessionID: z.string(),
312+
}),
313+
),
314+
async (c) => {
315+
const body = c.req.valid("json")
316+
await Session.unshare(body.sessionID)
317+
const session = await Session.get(body.sessionID)
318+
return c.json(session)
319+
},
320+
)
293321
.post(
294322
"/session_messages",
295323
describeRoute({

packages/opencode/src/session/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,14 @@ export namespace Session {
159159
return share
160160
}
161161

162+
export async function unshare(id: string) {
163+
await Storage.remove("session/share/" + id)
164+
await update(id, (draft) => {
165+
draft.share = undefined
166+
})
167+
await Share.remove(id)
168+
}
169+
162170
export async function update(id: string, editor: (session: Info) => void) {
163171
const { sessions } = state()
164172
const session = await get(id)

packages/opencode/src/share/share.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,11 @@ export namespace Share {
7070
.then((x) => x.json())
7171
.then((x) => x as { url: string; secret: string })
7272
}
73+
74+
export async function remove(id: string) {
75+
return fetch(`${URL}/share_delete`, {
76+
method: "POST",
77+
body: JSON.stringify({ id }),
78+
}).then((x) => x.json())
79+
}
7380
}

packages/opencode/src/storage/storage.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export namespace Storage {
2424
}
2525
})
2626

27+
export async function remove(key: string) {
28+
const target = path.join(state().dir, key + ".json")
29+
await fs.unlink(target).catch(() => {})
30+
}
31+
2732
export async function readJSON<T>(key: string) {
2833
return Bun.file(path.join(state().dir, key + ".json")).json() as Promise<T>
2934
}

0 commit comments

Comments
 (0)