Skip to content

Commit bf0f85e

Browse files
committed
playing with sdk docs
1 parent 7b52160 commit bf0f85e

9 files changed

Lines changed: 3203 additions & 760 deletions

File tree

packages/docs/docs.json

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,20 @@
88
"dark": "#15803D"
99
},
1010
"favicon": "/favicon.svg",
11-
"servers": [
12-
{
13-
"url": "https://opencode.ai/openapi.json"
14-
}
15-
],
1611
"navigation": {
1712
"tabs": [
1813
{
19-
"tab": "Guides",
14+
"tab": "SDK",
2015
"groups": [
2116
{
2217
"group": "Getting started",
23-
"pages": ["index", "quickstart", "development"]
24-
},
25-
{
26-
"group": "Customization",
27-
"pages": ["essentials/settings", "essentials/navigation"]
28-
},
29-
{
30-
"group": "Writing content",
31-
"pages": ["essentials/markdown", "essentials/code", "essentials/images", "essentials/reusable-snippets"]
32-
},
33-
{
34-
"group": "AI tools",
35-
"pages": ["ai-tools/cursor", "ai-tools/claude-code", "ai-tools/windsurf"]
18+
"pages": ["index", "quickstart", "development"],
19+
"openapi": "./openapi.json"
3620
}
3721
]
38-
},
39-
{
40-
"tab": "API Reference",
41-
"openapi": "https://opencode.ai/openapi.json"
4222
}
4323
],
44-
"global": {
45-
"anchors": [
46-
{
47-
"anchor": "Documentation",
48-
"href": "https://mintlify.com/docs",
49-
"icon": "book-open-cover"
50-
},
51-
{
52-
"anchor": "Blog",
53-
"href": "https://mintlify.com/blog",
54-
"icon": "newspaper"
55-
}
56-
]
57-
}
24+
"global": {}
5825
},
5926
"logo": {
6027
"light": "/logo/light.svg",

packages/docs/openapi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../sdk/openapi.json

packages/opencode/src/cli/cmd/generate.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ export const GenerateCommand = {
55
command: "generate",
66
handler: async () => {
77
const specs = await Server.openapi()
8+
for (const item of Object.values(specs.paths)) {
9+
for (const method of ["get", "post", "put", "delete", "patch"] as const) {
10+
const operation = item[method]
11+
if (!operation?.operationId) continue
12+
// @ts-expect-error
13+
operation["x-codeSamples"] = [
14+
{
15+
lang: "js",
16+
source: [
17+
`import { createOpencodeClient } from "@opencode-ai/sdk`,
18+
``,
19+
`const client = createOpencodeClient()`,
20+
`await client.${operation.operationId}({`,
21+
` ...`,
22+
`})`,
23+
].join("\n"),
24+
},
25+
]
26+
}
27+
}
828
const json = JSON.stringify(specs, null, 2)
929

1030
// Wait for stdout to finish writing before process.exit() is called

packages/opencode/src/server/project.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ export const ProjectRoute = new Hono()
88
.get(
99
"/",
1010
describeRoute({
11-
description: "List all projects",
11+
summary: "List all projects",
12+
description: "Get a list of projects that have been opened with OpenCode.",
1213
operationId: "project.list",
1314
responses: {
1415
200: {
@@ -29,11 +30,12 @@ export const ProjectRoute = new Hono()
2930
.get(
3031
"/current",
3132
describeRoute({
32-
description: "Get the current project",
33+
summary: "Get current project",
34+
description: "Retrieve the currently active project that OpenCode is working with.",
3335
operationId: "project.current",
3436
responses: {
3537
200: {
36-
description: "Current project",
38+
description: "Current project information",
3739
content: {
3840
"application/json": {
3941
schema: resolver(Project.Info),

0 commit comments

Comments
 (0)