Skip to content

Commit 7739340

Browse files
feat(api): update via SDK Studio
1 parent 8ee813e commit 7739340

File tree

10 files changed

+283
-21
lines changed

10 files changed

+283
-21
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 16
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-384a94f70b48c84af9eddcac72bbe12952c3ae3bd7fededfa1c63b203d12d828.yml
3-
openapi_spec_hash: e47ad28d646736d5d79d2dd1086d517d
4-
config_hash: e2d21e779cfc4e26a99b9e4e75de3f50
1+
configured_endpoints: 20
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-e2f67adede4455c3fe4507ac6f0b2ed1a91ee951ab30e01179555c18765750d4.yml
3+
openapi_spec_hash: 6005bcfff58c025d61739be42030a339
4+
config_hash: 6c8822d278ba83456e5eed6d774ca230

api.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,31 @@ Methods:
2727
- <code title="get /app">client.app.<a href="./src/resources/app.ts">get</a>() -> App</code>
2828
- <code title="post /app/init">client.app.<a href="./src/resources/app.ts">init</a>() -> AppInitResponse</code>
2929

30+
# Find
31+
32+
Types:
33+
34+
- <code><a href="./src/resources/find.ts">FindFilesResponse</a></code>
35+
- <code><a href="./src/resources/find.ts">FindSymbolsResponse</a></code>
36+
- <code><a href="./src/resources/find.ts">FindTextResponse</a></code>
37+
38+
Methods:
39+
40+
- <code title="get /find/file">client.find.<a href="./src/resources/find.ts">files</a>({ ...params }) -> FindFilesResponse</code>
41+
- <code title="get /find/symbol">client.find.<a href="./src/resources/find.ts">symbols</a>({ ...params }) -> FindSymbolsResponse</code>
42+
- <code title="get /find">client.find.<a href="./src/resources/find.ts">text</a>({ ...params }) -> FindTextResponse</code>
43+
3044
# File
3145

3246
Types:
3347

34-
- <code><a href="./src/resources/file.ts">FileSearchResponse</a></code>
48+
- <code><a href="./src/resources/file.ts">FileReadResponse</a></code>
49+
- <code><a href="./src/resources/file.ts">FileStatusResponse</a></code>
3550

3651
Methods:
3752

38-
- <code title="get /file">client.file.<a href="./src/resources/file.ts">search</a>({ ...params }) -> FileSearchResponse</code>
53+
- <code title="get /file">client.file.<a href="./src/resources/file.ts">read</a>({ ...params }) -> FileReadResponse</code>
54+
- <code title="get /file/status">client.file.<a href="./src/resources/file.ts">status</a>() -> FileStatusResponse</code>
3955

4056
# Config
4157

src/client.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ import {
2828
Provider,
2929
} from './resources/config';
3030
import { Event, EventListResponse } from './resources/event';
31-
import { File, FileSearchParams, FileSearchResponse } from './resources/file';
31+
import { File, FileReadParams, FileReadResponse, FileStatusResponse } from './resources/file';
32+
import {
33+
Find,
34+
FindFilesParams,
35+
FindFilesResponse,
36+
FindSymbolsParams,
37+
FindSymbolsResponse,
38+
FindTextParams,
39+
FindTextResponse,
40+
} from './resources/find';
3241
import {
3342
FilePart,
3443
Message,
@@ -720,12 +729,14 @@ export class Opencode {
720729

721730
event: API.Event = new API.Event(this);
722731
app: API.AppResource = new API.AppResource(this);
732+
find: API.Find = new API.Find(this);
723733
file: API.File = new API.File(this);
724734
config: API.ConfigResource = new API.ConfigResource(this);
725735
session: API.SessionResource = new API.SessionResource(this);
726736
}
727737
Opencode.Event = Event;
728738
Opencode.AppResource = AppResource;
739+
Opencode.Find = Find;
729740
Opencode.File = File;
730741
Opencode.ConfigResource = ConfigResource;
731742
Opencode.SessionResource = SessionResource;
@@ -736,10 +747,21 @@ export declare namespace Opencode {
736747

737748
export { AppResource as AppResource, type App as App, type AppInitResponse as AppInitResponse };
738749

750+
export {
751+
Find as Find,
752+
type FindFilesResponse as FindFilesResponse,
753+
type FindSymbolsResponse as FindSymbolsResponse,
754+
type FindTextResponse as FindTextResponse,
755+
type FindFilesParams as FindFilesParams,
756+
type FindSymbolsParams as FindSymbolsParams,
757+
type FindTextParams as FindTextParams,
758+
};
759+
739760
export {
740761
File as File,
741-
type FileSearchResponse as FileSearchResponse,
742-
type FileSearchParams as FileSearchParams,
762+
type FileReadResponse as FileReadResponse,
763+
type FileStatusResponse as FileStatusResponse,
764+
type FileReadParams as FileReadParams,
743765
};
744766

745767
export {

src/resources/event.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export type EventListResponse =
2727
| EventListResponse.EventSessionUpdated
2828
| EventListResponse.EventSessionDeleted
2929
| EventListResponse.EventSessionIdle
30-
| EventListResponse.EventSessionError;
30+
| EventListResponse.EventSessionError
31+
| EventListResponse.EventFileWatcherUpdated;
3132

3233
export namespace EventListResponse {
3334
export interface EventLspClientDiagnostics {
@@ -191,6 +192,20 @@ export namespace EventListResponse {
191192
}
192193
}
193194
}
195+
196+
export interface EventFileWatcherUpdated {
197+
properties: EventFileWatcherUpdated.Properties;
198+
199+
type: 'file.watcher.updated';
200+
}
201+
202+
export namespace EventFileWatcherUpdated {
203+
export interface Properties {
204+
event: 'rename' | 'change';
205+
206+
file: string;
207+
}
208+
}
194209
}
195210

196211
export declare namespace Event {

src/resources/file.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,48 @@ import { RequestOptions } from '../internal/request-options';
66

77
export class File extends APIResource {
88
/**
9-
* Search for files
9+
* Read a file
1010
*/
11-
search(query: FileSearchParams, options?: RequestOptions): APIPromise<FileSearchResponse> {
11+
read(query: FileReadParams, options?: RequestOptions): APIPromise<FileReadResponse> {
1212
return this._client.get('/file', { query, ...options });
1313
}
14+
15+
/**
16+
* Get file status
17+
*/
18+
status(options?: RequestOptions): APIPromise<FileStatusResponse> {
19+
return this._client.get('/file/status', options);
20+
}
21+
}
22+
23+
export interface FileReadResponse {
24+
content: string;
25+
26+
type: 'raw' | 'patch';
1427
}
1528

16-
export type FileSearchResponse = Array<string>;
29+
export type FileStatusResponse = Array<FileStatusResponse.FileStatusResponseItem>;
30+
31+
export namespace FileStatusResponse {
32+
export interface FileStatusResponseItem {
33+
added: number;
34+
35+
file: string;
36+
37+
removed: number;
38+
39+
status: 'added' | 'deleted' | 'modified';
40+
}
41+
}
1742

18-
export interface FileSearchParams {
19-
query: string;
43+
export interface FileReadParams {
44+
path: string;
2045
}
2146

2247
export declare namespace File {
23-
export { type FileSearchResponse as FileSearchResponse, type FileSearchParams as FileSearchParams };
48+
export {
49+
type FileReadResponse as FileReadResponse,
50+
type FileStatusResponse as FileStatusResponse,
51+
type FileReadParams as FileReadParams,
52+
};
2453
}

src/resources/find.ts

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { APIResource } from '../core/resource';
4+
import { APIPromise } from '../core/api-promise';
5+
import { RequestOptions } from '../internal/request-options';
6+
7+
export class Find extends APIResource {
8+
/**
9+
* Find files
10+
*/
11+
files(query: FindFilesParams, options?: RequestOptions): APIPromise<FindFilesResponse> {
12+
return this._client.get('/find/file', { query, ...options });
13+
}
14+
15+
/**
16+
* Find workspace symbols
17+
*/
18+
symbols(query: FindSymbolsParams, options?: RequestOptions): APIPromise<FindSymbolsResponse> {
19+
return this._client.get('/find/symbol', { query, ...options });
20+
}
21+
22+
/**
23+
* Find text in files
24+
*/
25+
text(query: FindTextParams, options?: RequestOptions): APIPromise<FindTextResponse> {
26+
return this._client.get('/find', { query, ...options });
27+
}
28+
}
29+
30+
export type FindFilesResponse = Array<string>;
31+
32+
export type FindSymbolsResponse = Array<unknown>;
33+
34+
export type FindTextResponse = Array<FindTextResponse.FindTextResponseItem>;
35+
36+
export namespace FindTextResponse {
37+
export interface FindTextResponseItem {
38+
absolute_offset: number;
39+
40+
line_number: number;
41+
42+
lines: FindTextResponseItem.Lines;
43+
44+
path: FindTextResponseItem.Path;
45+
46+
submatches: Array<FindTextResponseItem.Submatch>;
47+
}
48+
49+
export namespace FindTextResponseItem {
50+
export interface Lines {
51+
text: string;
52+
}
53+
54+
export interface Path {
55+
text: string;
56+
}
57+
58+
export interface Submatch {
59+
end: number;
60+
61+
match: Submatch.Match;
62+
63+
start: number;
64+
}
65+
66+
export namespace Submatch {
67+
export interface Match {
68+
text: string;
69+
}
70+
}
71+
}
72+
}
73+
74+
export interface FindFilesParams {
75+
query: string;
76+
}
77+
78+
export interface FindSymbolsParams {
79+
query: string;
80+
}
81+
82+
export interface FindTextParams {
83+
pattern: string;
84+
}
85+
86+
export declare namespace Find {
87+
export {
88+
type FindFilesResponse as FindFilesResponse,
89+
type FindSymbolsResponse as FindSymbolsResponse,
90+
type FindTextResponse as FindTextResponse,
91+
type FindFilesParams as FindFilesParams,
92+
type FindSymbolsParams as FindSymbolsParams,
93+
type FindTextParams as FindTextParams,
94+
};
95+
}

src/resources/index.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ export {
1313
type ConfigProvidersResponse,
1414
} from './config';
1515
export { Event, type EventListResponse } from './event';
16-
export { File, type FileSearchResponse, type FileSearchParams } from './file';
16+
export { File, type FileReadResponse, type FileStatusResponse, type FileReadParams } from './file';
17+
export {
18+
Find,
19+
type FindFilesResponse,
20+
type FindSymbolsResponse,
21+
type FindTextResponse,
22+
type FindFilesParams,
23+
type FindSymbolsParams,
24+
type FindTextParams,
25+
} from './find';
1726
export {
1827
SessionResource,
1928
type FilePart,

src/resources/session.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export namespace Message {
113113
assistant?: Metadata.Assistant;
114114

115115
error?: Shared.ProviderAuthError | Shared.UnknownError | Metadata.MessageOutputLengthError;
116+
117+
user?: Metadata.User;
116118
}
117119

118120
export namespace Metadata {
@@ -185,6 +187,10 @@ export namespace Message {
185187

186188
name: 'MessageOutputLengthError';
187189
}
190+
191+
export interface User {
192+
snapshot?: string;
193+
}
188194
}
189195
}
190196

tests/api-resources/file.test.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const client = new Opencode({ baseURL: process.env['TEST_API_BASE_URL'] ?? 'http
66

77
describe('resource file', () => {
88
// skipped: tests are disabled for the time being
9-
test.skip('search: only required params', async () => {
10-
const responsePromise = client.file.search({ query: 'query' });
9+
test.skip('read: only required params', async () => {
10+
const responsePromise = client.file.read({ path: 'path' });
1111
const rawResponse = await responsePromise.asResponse();
1212
expect(rawResponse).toBeInstanceOf(Response);
1313
const response = await responsePromise;
@@ -18,7 +18,19 @@ describe('resource file', () => {
1818
});
1919

2020
// skipped: tests are disabled for the time being
21-
test.skip('search: required and optional params', async () => {
22-
const response = await client.file.search({ query: 'query' });
21+
test.skip('read: required and optional params', async () => {
22+
const response = await client.file.read({ path: 'path' });
23+
});
24+
25+
// skipped: tests are disabled for the time being
26+
test.skip('status', async () => {
27+
const responsePromise = client.file.status();
28+
const rawResponse = await responsePromise.asResponse();
29+
expect(rawResponse).toBeInstanceOf(Response);
30+
const response = await responsePromise;
31+
expect(response).not.toBeInstanceOf(Response);
32+
const dataAndResponse = await responsePromise.withResponse();
33+
expect(dataAndResponse.data).toBe(response);
34+
expect(dataAndResponse.response).toBe(rawResponse);
2335
});
2436
});

0 commit comments

Comments
 (0)