@@ -146,7 +146,11 @@ function normalizeRepositoryCloneUrls(
146146function decodeGitHubJson < S extends Schema . Top > (
147147 raw : string ,
148148 schema : S ,
149- operation : "listOpenPullRequests" | "getPullRequest" | "getRepositoryCloneUrls" ,
149+ operation :
150+ | "listOpenPullRequests"
151+ | "getPullRequest"
152+ | "getRepositoryCloneUrls"
153+ | "listAllPullRequests" ,
150154 invalidDetail : string ,
151155) : Effect . Effect < S [ "Type" ] , GitHubCliError , S [ "DecodingServices" ] > {
152156 return Schema . decodeEffect ( Schema . fromJsonString ( schema ) ) ( raw ) . pipe (
@@ -203,6 +207,48 @@ const makeGitHubCli = Effect.sync(() => {
203207 ) ,
204208 Effect . map ( ( pullRequests ) => pullRequests . map ( normalizePullRequestSummary ) ) ,
205209 ) ,
210+ listAllPullRequests : ( input ) =>
211+ execute ( {
212+ cwd : input . cwd ,
213+ args : [
214+ "pr" ,
215+ "list" ,
216+ "--state" ,
217+ input . state ?? "open" ,
218+ "--limit" ,
219+ String ( input . limit ?? 50 ) ,
220+ ...( input . label ? [ "--label" , input . label ] : [ ] ) ,
221+ "--json" ,
222+ "number,title,url,baseRefName,headRefName,state,labels,updatedAt,author" ,
223+ ] ,
224+ } ) . pipe (
225+ Effect . map ( ( result ) => result . stdout . trim ( ) ) ,
226+ Effect . flatMap ( ( raw ) => {
227+ if ( raw . length === 0 ) return Effect . succeed ( [ ] ) ;
228+ return Effect . try ( {
229+ try : ( ) => {
230+ const parsed = JSON . parse ( raw ) as Array < any > ;
231+ return parsed . map ( ( pr : any ) => ( {
232+ number : pr . number ,
233+ title : pr . title ,
234+ url : pr . url ,
235+ baseRefName : pr . baseRefName ,
236+ headRefName : pr . headRefName ,
237+ state : pr . state === "MERGED" ? "merged" : pr . state === "CLOSED" ? "closed" : "open" ,
238+ labels : ( pr . labels ?? [ ] ) . map ( ( l : any ) => ( { name : l . name , color : l . color ?? "" } ) ) ,
239+ updatedAt : pr . updatedAt ?? "" ,
240+ author : pr . author ?. login ?? "" ,
241+ } ) ) ;
242+ } ,
243+ catch : ( cause ) =>
244+ new GitHubCliError ( {
245+ operation : "listAllPullRequests" ,
246+ detail : "GitHub CLI returned invalid PR list JSON." ,
247+ cause,
248+ } ) ,
249+ } ) ;
250+ } ) ,
251+ ) ,
206252 getPullRequest : ( input ) =>
207253 execute ( {
208254 cwd : input . cwd ,
0 commit comments