@@ -5,6 +5,10 @@ import { ModelID, ProviderID } from "../../src/provider/schema"
55import { Instance } from "../../src/project/instance"
66import { Server } from "../../src/server/server"
77import { ExperimentalPaths } from "../../src/server/routes/instance/httpapi/groups/experimental"
8+ import { FilePaths } from "../../src/server/routes/instance/httpapi/groups/file"
9+ import { GlobalPaths } from "../../src/server/routes/instance/httpapi/groups/global"
10+ import { InstancePaths } from "../../src/server/routes/instance/httpapi/groups/instance"
11+ import { McpPaths } from "../../src/server/routes/instance/httpapi/groups/mcp"
812import { SessionPaths } from "../../src/server/routes/instance/httpapi/groups/session"
913import { MessageID , PartID } from "../../src/session/schema"
1014import { Session } from "@/session/session"
@@ -89,6 +93,83 @@ afterEach(async () => {
8993} )
9094
9195describe ( "HttpApi JSON parity" , ( ) => {
96+ it . live (
97+ "matches legacy JSON shape for safe GET endpoints" ,
98+ withTmp (
99+ {
100+ git : true ,
101+ config : {
102+ formatter : false ,
103+ lsp : false ,
104+ mcp : {
105+ demo : {
106+ type : "local" ,
107+ command : [ "echo" , "demo" ] ,
108+ enabled : false ,
109+ } ,
110+ } ,
111+ } ,
112+ } ,
113+ ( tmp ) =>
114+ Effect . gen ( function * ( ) {
115+ yield * Effect . promise ( ( ) => Bun . write ( `${ tmp . path } /hello.txt` , "hello\n" ) )
116+
117+ const headers = { "x-opencode-directory" : tmp . path }
118+ const legacy = app ( false )
119+ const httpapi = app ( true )
120+
121+ yield * Effect . forEach (
122+ [
123+ { label : "global.health" , path : GlobalPaths . health , headers : { } } ,
124+ { label : "instance.path" , path : InstancePaths . path , headers } ,
125+ { label : "instance.vcs" , path : InstancePaths . vcs , headers } ,
126+ { label : "instance.vcsDiff" , path : `${ InstancePaths . vcsDiff } ?mode=git` , headers } ,
127+ { label : "instance.command" , path : InstancePaths . command , headers } ,
128+ { label : "instance.agent" , path : InstancePaths . agent , headers } ,
129+ { label : "instance.skill" , path : InstancePaths . skill , headers } ,
130+ { label : "instance.lsp" , path : InstancePaths . lsp , headers } ,
131+ { label : "instance.formatter" , path : InstancePaths . formatter , headers } ,
132+ { label : "config.get" , path : "/config" , headers } ,
133+ { label : "config.providers" , path : "/config/providers" , headers } ,
134+ { label : "project.list" , path : "/project" , headers } ,
135+ { label : "project.current" , path : "/project/current" , headers } ,
136+ { label : "provider.list" , path : "/provider" , headers } ,
137+ { label : "provider.auth" , path : "/provider/auth" , headers } ,
138+ { label : "mcp.status" , path : McpPaths . status , headers } ,
139+ { label : "file.list" , path : `${ FilePaths . list } ?${ new URLSearchParams ( { path : "." } ) } ` , headers } ,
140+ {
141+ label : "file.content" ,
142+ path : `${ FilePaths . content } ?${ new URLSearchParams ( { path : "hello.txt" } ) } ` ,
143+ headers,
144+ } ,
145+ { label : "file.status" , path : FilePaths . status , headers } ,
146+ {
147+ label : "find.file" ,
148+ path : `${ FilePaths . findFile } ?${ new URLSearchParams ( { query : "hello" , dirs : "false" } ) } ` ,
149+ headers,
150+ } ,
151+ {
152+ label : "find.text" ,
153+ path : `${ FilePaths . findText } ?${ new URLSearchParams ( { pattern : "hello" } ) } ` ,
154+ headers,
155+ } ,
156+ {
157+ label : "find.symbol" ,
158+ path : `${ FilePaths . findSymbol } ?${ new URLSearchParams ( { query : "hello" } ) } ` ,
159+ headers,
160+ } ,
161+ { label : "experimental.console" , path : ExperimentalPaths . console , headers } ,
162+ { label : "experimental.consoleOrgs" , path : ExperimentalPaths . consoleOrgs , headers } ,
163+ { label : "experimental.toolIDs" , path : ExperimentalPaths . toolIDs , headers } ,
164+ { label : "experimental.worktree" , path : ExperimentalPaths . worktree , headers } ,
165+ ] ,
166+ ( input ) => expectJsonParity ( { ...input , legacy, httpapi } ) ,
167+ { concurrency : 1 } ,
168+ )
169+ } ) ,
170+ ) ,
171+ )
172+
92173 it . live (
93174 "matches legacy JSON shape for session read endpoints" ,
94175 withTmp ( { git : true , config : { formatter : false , lsp : false } } , ( tmp ) =>
0 commit comments