FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
opencode/script/duplicate-pr.ts at openwork-dev · different-ai/opencode · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
different-ai
/
opencode
Public
forked from
anomalyco/opencode
Notifications
You must be signed in to change notification settings
Fork
2
Star
12
Code
Pull requests
1
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
opencode
/
script
/
duplicate-pr.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
79 lines (66 loc) · 1.97 KB
Breadcrumbs
opencode
/
script
/
duplicate-pr.ts
Copy path
File metadata and controls
executable file
·
79 lines (66 loc) · 1.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bun
import
path
from
"path"
import
{
pathToFileURL
}
from
"bun"
import
{
createOpencode
}
from
"@opencode-ai/sdk"
import
{
parseArgs
}
from
"util"
async
function
main
(
)
{
const
{
values
,
positionals
}
=
parseArgs
(
{
args
:
Bun
.
argv
.
slice
(
2
)
,
options
:
{
file
:
{
type
:
"string"
,
short
:
"f"
}
,
help
:
{
type
:
"boolean"
,
short
:
"h"
,
default
:
false
}
,
}
,
allowPositionals
:
true
,
}
)
if
(
values
.
help
)
{
console
.
log
(
`
Usage: bun script/duplicate-pr.ts [options] <message>
Options:
-f, --file <path> File to attach to the prompt
-h, --help Show this help message
Examples:
bun script/duplicate-pr.ts -f pr_info.txt "Check the attached file for PR details"
`
)
process
.
exit
(
0
)
}
const
message
=
positionals
.
join
(
" "
)
if
(
!
message
)
{
console
.
error
(
"Error: message is required"
)
process
.
exit
(
1
)
}
const
opencode
=
await
createOpencode
(
{
port
:
0
}
)
try
{
const
parts
:
Array
<
{
type
:
"text"
;
text
:
string
}
|
{
type
:
"file"
;
url
:
string
;
filename
:
string
;
mime
:
string
}
>
=
[
]
if
(
values
.
file
)
{
const
resolved
=
path
.
resolve
(
process
.
cwd
(
)
,
values
.
file
)
const
file
=
Bun
.
file
(
resolved
)
if
(
!
(
await
file
.
exists
(
)
)
)
{
console
.
error
(
`Error: file not found:
${
values
.
file
}
`
)
process
.
exit
(
1
)
}
parts
.
push
(
{
type
:
"file"
,
url
:
pathToFileURL
(
resolved
)
.
href
,
filename
:
path
.
basename
(
resolved
)
,
mime
:
"text/plain"
,
}
)
}
parts
.
push
(
{
type
:
"text"
,
text
:
message
}
)
const
session
=
await
opencode
.
client
.
session
.
create
(
)
const
result
=
await
opencode
.
client
.
session
.
prompt
(
{
path
:
{
id
:
session
.
data
!
.
id
}
,
body
:
{
agent
:
"duplicate-pr"
,
parts
,
}
,
signal
:
AbortSignal
.
timeout
(
120_000
)
,
}
)
.
then
(
(
x
)
=>
x
.
data
?.
parts
?.
find
(
(
y
)
=>
y
.
type
===
"text"
)
?.
text
??
""
)
console
.
log
(
result
.
trim
(
)
)
}
finally
{
opencode
.
server
.
close
(
)
}
}
void
main
(
)
Back
|
FazBrowse Home
|
New Git URL