Compare commits
476
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2662a4f955 | ||
|
|
7a012cac08 | ||
|
|
af06e52708 | ||
|
|
f807152724 | ||
|
|
b0ea7a5aa7 | ||
|
|
34b1be5bcd | ||
|
|
16639eee76 | ||
|
|
10c8493940 | ||
|
|
a50ff72f3f | ||
|
|
5f4e5e6896 | ||
|
|
f39cf911d7 | ||
|
|
f179dcbf02 | ||
|
|
fd6a8520b8 | ||
|
|
e11e089e42 | ||
|
|
73cdba959b | ||
|
|
4e7a60dac6 | ||
|
|
e62ebd8fec | ||
|
|
195f592640 | ||
|
|
78769010a1 | ||
|
|
4e143e3a3e | ||
|
|
dab567aa2d | ||
|
|
9d35b04e13 | ||
|
|
273ab56949 | ||
|
|
302ba0ca0b | ||
|
|
d35e09f1fc | ||
|
|
fc34c74567 | ||
|
|
cb4f5cdea9 | ||
|
|
d34a0194ec | ||
|
|
43310f4d8c | ||
|
|
e22cfa435a | ||
|
|
93b1ccc029 | ||
|
|
faca2b90c1 | ||
|
|
76ff18afde | ||
|
|
9914c9af17 | ||
|
|
f202226bbc | ||
|
|
34198f422c | ||
|
|
cccdeef294 | ||
|
|
83c145f889 | ||
|
|
d353a6bc24 | ||
|
|
d25cc42d21 | ||
|
|
6039b894c5 | ||
|
|
b4fc5ef071 | ||
|
|
f6c8e35383 | ||
|
|
94564f3588 | ||
|
|
855bda8384 | ||
|
|
756488d534 | ||
|
|
22de34c4de | ||
|
|
bdb0c16a93 | ||
|
|
7f7eb2e7f8 | ||
|
|
e15fd0bb93 | ||
|
|
8f90697df8 | ||
|
|
17af25d1c1 | ||
|
|
3c81326a5e | ||
|
|
9f8d8f5b0e | ||
|
|
337993d53e | ||
|
|
e26abd8da9 | ||
|
|
8c1ce0b80c | ||
|
|
f8c3f560d4 | ||
|
|
7e43d3e3f5 | ||
|
|
52db7a76e2 | ||
|
|
be6e7b309e | ||
|
|
0af242974c | ||
|
|
27ac53aaac | ||
|
|
78015571bf | ||
|
|
e76cf967e6 | ||
|
|
c2723b5ea0 | ||
|
|
9675579796 | ||
|
|
4d8368970a | ||
|
|
2a7af6acd8 | ||
|
|
bfd707abc9 | ||
|
|
981e00971a | ||
|
|
c50d2b3656 | ||
|
|
ddad0988e7 | ||
|
|
cda8cc7285 | ||
|
|
b928a1fff9 | ||
|
|
04286d0415 | ||
|
|
33bb33ba90 | ||
|
|
b0ade40265 | ||
|
|
681594b551 | ||
|
|
edf7649400 | ||
|
|
3fc7486d15 | ||
|
|
8e353584c7 | ||
|
|
5c35ea2181 | ||
|
|
faf8713053 | ||
|
|
16c457e712 | ||
|
|
9818c9e8d0 | ||
|
|
5e41dbbcbf | ||
|
|
ba5c8d3822 | ||
|
|
10c90eb445 | ||
|
|
aa8a41d1b8 | ||
|
|
3f33be1928 | ||
|
|
42e6b7d541 | ||
|
|
ccb207f946 | ||
|
|
de1e0b5d6d | ||
|
|
df3895d74f | ||
|
|
55e0af1405 | ||
|
|
5182a3698d | ||
|
|
73e1de4513 | ||
|
|
44b432c3fd | ||
|
|
0d8c9f3437 | ||
|
|
0d074492df | ||
|
|
3b7a5e783d | ||
|
|
c197fd92b7 | ||
|
|
9ee1f6ceba | ||
|
|
20cec91550 | ||
|
|
22a5e6cc50 | ||
|
|
52f9bcbb82 | ||
|
|
a4ebb07c25 | ||
|
|
7cc968b05d | ||
|
|
fa077b92b1 | ||
|
|
8ad3a4b217 | ||
|
|
533495ae20 | ||
|
|
f0635e365f | ||
|
|
25de3e407b | ||
|
|
655b25bccf | ||
|
|
e5d13d9519 | ||
|
|
5cdbb7505e | ||
|
|
e5319846ad | ||
|
|
832aa94977 | ||
|
|
6c7f35b49e | ||
|
|
6e25720307 | ||
|
|
ca723f1cbc | ||
|
|
650f67a05a | ||
|
|
50dccac915 | ||
|
|
02b8b0ff93 | ||
|
|
76c91c6e33 | ||
|
|
ca17ca85cd | ||
|
|
e7aed64949 | ||
|
|
d43124abe0 | ||
|
|
7404664827 | ||
|
|
0b112e5bcf | ||
|
|
268d758130 | ||
|
|
72acdf0505 | ||
|
|
e28ef7b57c | ||
|
|
5b5376a3fa | ||
|
|
766318a4cf | ||
|
|
8d5aa584b4 | ||
|
|
eed0eddc63 | ||
|
|
8345152319 | ||
|
|
bebe5442a5 | ||
|
|
bc25342f34 | ||
|
|
762020f63a | ||
|
|
f13fc5a8a8 | ||
|
|
098bdd8ae2 | ||
|
|
4d205027ca | ||
|
|
5975547c84 | ||
|
|
5b2b300602 | ||
|
|
d488e3fd2a | ||
|
|
809af5c590 | ||
|
|
733bd3c74e | ||
|
|
374951bf60 | ||
|
|
2e94f505a4 | ||
|
|
4498fc983d | ||
|
|
2e7cf92c8b | ||
|
|
ccf93f3523 | ||
|
|
4b041716fc | ||
|
|
b0dc8e4638 | ||
|
|
596f241db5 | ||
|
|
3a810fcb9a | ||
|
|
e5af7ab99a | ||
|
|
f01c6b3e37 | ||
|
|
fed043a1ad | ||
|
|
e9a29e4908 | ||
|
|
d93a06431e | ||
|
|
9fe912439b | ||
|
|
dd46fddf22 | ||
|
|
d3d7b44e73 | ||
|
|
367665dba2 | ||
|
|
4aaece29d9 | ||
|
|
bed88ce50e | ||
|
|
28204720dc | ||
|
|
10b99b2f5a | ||
|
|
90c13d93f3 | ||
|
|
67e6408cef | ||
|
|
3be65dff46 | ||
|
|
c5961205ef | ||
|
|
ad6a8a1850 | ||
|
|
46daede10c | ||
|
|
8249baeb4e | ||
|
|
77e51b0a32 | ||
|
|
784796e27a | ||
|
|
913ea36ae6 | ||
|
|
68c4951318 | ||
|
|
6d3b2fe08b | ||
|
|
d88cef6ada | ||
|
|
8370d0cef4 | ||
|
|
0b67e1a046 | ||
|
|
485ecbde18 | ||
|
|
03cf833236 | ||
|
|
e3684f36f9 | ||
|
|
13fbc9acfc | ||
|
|
588b5240d0 | ||
|
|
80543fb5dc | ||
|
|
ff16eb8dea | ||
|
|
91a9514ed0 | ||
|
|
2f4dce789f | ||
|
|
b43147440c | ||
|
|
c96a77c60b | ||
|
|
6cd2a743b5 | ||
|
|
0f8517208b | ||
|
|
0879f5e22d | ||
|
|
16333b5222 | ||
|
|
e16f4b6b99 | ||
|
|
6fbb08b724 | ||
|
|
a26a2a95bd | ||
|
|
7f9268f147 | ||
|
|
5c7af682b9 | ||
|
|
911b2ac088 | ||
|
|
da689d77c4 | ||
|
|
c9df833d2c | ||
|
|
c2b1ebd9dc | ||
|
|
d1356f509e | ||
|
|
69feb224ba | ||
|
|
7d9ac713a9 | ||
|
|
4d9c675b00 | ||
|
|
604de70689 | ||
|
|
673226d214 | ||
|
|
2447f42294 | ||
|
|
005e64e7d8 | ||
|
|
8310e7df70 | ||
|
|
c4e676b8a0 | ||
|
|
c2c40b5b61 | ||
|
|
456495289e | ||
|
|
d6367853ae | ||
|
|
adccab5970 | ||
|
|
b6d3fa09bc | ||
|
|
31e2d72bf7 | ||
|
|
b7c6fa611f | ||
|
|
d0b8ff0f22 | ||
|
|
59b976b954 | ||
|
|
d1640c075b | ||
|
|
17d4c366e6 | ||
|
|
d0844c600b | ||
|
|
1d243ce25a | ||
|
|
d8c8322ddf | ||
|
|
1b6599f411 | ||
|
|
937a3c10b3 | ||
|
|
72ce24c200 | ||
|
|
3301fad8cd | ||
|
|
9c54255aeb | ||
|
|
b0674b473f | ||
|
|
ded4da735b | ||
|
|
2c334d9242 | ||
|
|
81dd46abec | ||
|
|
baef5cd43b | ||
|
|
65368f609d | ||
|
|
2cb697b720 | ||
|
|
cb511f78ff | ||
|
|
159964b172 | ||
|
|
d9f9f1553b | ||
|
|
0fb55b4f1a | ||
|
|
3c34f6704b | ||
|
|
4cf088ae84 | ||
|
|
ca28dd02ec | ||
|
|
2017dc165c | ||
|
|
dc9d6a08cb | ||
|
|
af4ab017cb | ||
|
|
dd14413a64 | ||
|
|
b9e7cbf13c | ||
|
|
3f74abc6cd | ||
|
|
e0d0fe1ff7 | ||
|
|
f7dbb4dac4 | ||
|
|
c5849e56cc | ||
|
|
e46ab34d27 | ||
|
|
1d4613006a | ||
|
|
71040c54aa | ||
|
|
fec78154b5 | ||
|
|
3e2ec192cf | ||
|
|
ec960da42a | ||
|
|
45de4975de | ||
|
|
e540daabc4 | ||
|
|
f3c91c5f96 | ||
|
|
549b146ea6 | ||
|
|
3c7569d852 | ||
|
|
8f1ded9e08 | ||
|
|
b668af29dd | ||
|
|
ec30ff9120 | ||
|
|
a3714d4399 | ||
|
|
822eec0d62 | ||
|
|
3974520742 | ||
|
|
fda37b3609 | ||
|
|
6b950b666a | ||
|
|
bc4fdb8370 | ||
|
|
2b9af91568 | ||
|
|
53a3f95088 | ||
|
|
5a4596c879 | ||
|
|
0ce614a280 | ||
|
|
e8125e9b42 | ||
|
|
a7b5041674 | ||
|
|
a16789dfdd | ||
|
|
8115004c73 | ||
|
|
ec4fdaf8e9 | ||
|
|
3dc2c1d81c | ||
|
|
d658e1e350 | ||
|
|
30e3fa1de9 | ||
|
|
23f8b3eb3e | ||
|
|
c7d8b0d565 | ||
|
|
257fcafc83 | ||
|
|
04aafe2bfc | ||
|
|
0fd0facc44 | ||
|
|
0de3b67cc0 | ||
|
|
28f38fc871 | ||
|
|
8feb4a31c7 | ||
|
|
8f05bbfaa6 | ||
|
|
d276d96cdf | ||
|
|
caf1151cb5 | ||
|
|
ff38bbeeeb | ||
|
|
2481dde36d | ||
|
|
61174b7878 | ||
|
|
907281a80a | ||
|
|
3992e2a76b | ||
|
|
ea6eabe1d9 | ||
|
|
36d40fee4d | ||
|
|
e36bc20f84 | ||
|
|
487575773d | ||
|
|
5cc84800dc | ||
|
|
2b432d9e03 | ||
|
|
591eb667d5 | ||
|
|
ddce776225 | ||
|
|
1a28924ed8 | ||
|
|
871374804f | ||
|
|
78a2639e5e | ||
|
|
cc1835e0db | ||
|
|
0f5d4ae648 | ||
|
|
ce72020750 | ||
|
|
c43d606f8e | ||
|
|
1007630347 | ||
|
|
9e8274d2da | ||
|
|
74aa735e6a | ||
|
|
8030a6c187 | ||
|
|
e5aa5161f2 | ||
|
|
abb1ee6278 | ||
|
|
c4003579bb | ||
|
|
0d9c534184 | ||
|
|
5773d43cbf | ||
|
|
e0e9414cbd | ||
|
|
44edb639c2 | ||
|
|
fbd52ca2f4 | ||
|
|
8015ff7ca5 | ||
|
|
ec9584177f | ||
|
|
061efc6cf2 | ||
|
|
fe374aea46 | ||
|
|
46edc98f10 | ||
|
|
fdeb2748e1 | ||
|
|
59e6967b8f | ||
|
|
0c619cb59c | ||
|
|
0cf90109dc | ||
|
|
812668ae2f | ||
|
|
a5c35bf182 | ||
|
|
bdd5a80886 | ||
|
|
fd65d29dcc | ||
|
|
d3caac5270 | ||
|
|
fe7ca3421e | ||
|
|
cc95197d72 | ||
|
|
9067218b74 | ||
|
|
42a0453945 | ||
|
|
4d9eb6c320 | ||
|
|
c060c436b6 | ||
|
|
45adfedd64 | ||
|
|
0bced8ec96 | ||
|
|
8d9b9719be | ||
|
|
c7e084c32c | ||
|
|
6f2f759fbb | ||
|
|
cddab63808 | ||
|
|
12583b18f0 | ||
|
|
df386bd651 | ||
|
|
25b12ed754 | ||
|
|
023e1c711e | ||
|
|
52f7ba7d4d | ||
|
|
19fce2bc6f | ||
|
|
4bae84c8b0 | ||
|
|
f240bba8e7 | ||
|
|
bcee247988 | ||
|
|
64c504212a | ||
|
|
6592d80460 | ||
|
|
d821650b48 | ||
|
|
6c9f12bb2d | ||
|
|
fca89e5e4d | ||
|
|
1eff01b6a5 | ||
|
|
e93b1f3a7f | ||
|
|
8874d4a42f | ||
|
|
c933504d9c | ||
|
|
2d0d3d596e | ||
|
|
3bd98ea055 | ||
|
|
7e997cfba4 | ||
|
|
5d6f2a1524 | ||
|
|
b1cb71856e | ||
|
|
518264fcd9 | ||
|
|
7235c9c9b8 | ||
|
|
274033cd52 | ||
|
|
9b369ee815 | ||
|
|
721ff5121e | ||
|
|
cfbf5d1c6f | ||
|
|
02cb7e7b71 | ||
|
|
942630eb4a | ||
|
|
ce66b191d1 | ||
|
|
6f1f5944ce | ||
|
|
1c49b2ed67 | ||
|
|
3c6be604ec | ||
|
|
ddc02c2893 | ||
|
|
2703eff2e2 | ||
|
|
38e4540119 | ||
|
|
4100fcbd17 | ||
|
|
83cb0f60ec | ||
|
|
effd96755e | ||
|
|
5801cce1b5 | ||
|
|
77e6c0d329 | ||
|
|
fed716ada5 | ||
|
|
426d92e352 | ||
|
|
d0412a213b | ||
|
|
16aa67086b | ||
|
|
7cea32ee08 | ||
|
|
128d10d9e9 | ||
|
|
5ef72e1101 | ||
|
|
d8060dc9ad | ||
|
|
f71fb18d3d | ||
|
|
5654dd2aad | ||
|
|
64dde0cb15 | ||
|
|
a658e43eeb | ||
|
|
ca8a42c973 | ||
|
|
8f5f75db12 | ||
|
|
4ff0d07b1d | ||
|
|
2a571b3cee | ||
|
|
0fffcdfe46 | ||
|
|
2ba2ee52e8 | ||
|
|
56d818fc34 | ||
|
|
9c8da69196 | ||
|
|
a78018697c | ||
|
|
e45b6ef1de | ||
|
|
b616543ac2 | ||
|
|
2bd3d9a696 | ||
|
|
fa15dbc5ec | ||
|
|
312e5c7a7c | ||
|
|
049502fac6 | ||
|
|
cc2915be16 | ||
|
|
ce061bf661 | ||
|
|
3b8790e034 | ||
|
|
a4f3cedcdf | ||
|
|
1c9a2eb239 | ||
|
|
4fb417d3b5 | ||
|
|
11030c627b | ||
|
|
c104098a66 | ||
|
|
49ee3ba85a | ||
|
|
4fc538378d | ||
|
|
d28b5ad2f4 | ||
|
|
6589a66822 | ||
|
|
5cf9abe743 | ||
|
|
903d81819d | ||
|
|
472f9e64a6 | ||
|
|
c04fa9e253 | ||
|
|
3a78fb1f42 | ||
|
|
85ce6a5f95 | ||
|
|
5217e6c1af | ||
|
|
3a7f617098 | ||
|
|
d9150413cb | ||
|
|
bcbc1dba22 | ||
|
|
ce3235e115 | ||
|
|
a9a2a597d5 | ||
|
|
3753601f87 | ||
|
|
fb4bab8a66 | ||
|
|
b3526f6ce9 | ||
|
|
f220f02a2f | ||
|
|
235a86fb60 | ||
|
|
67b9c9c027 | ||
|
|
2f11c9f7ed | ||
|
|
e1c1193f3e | ||
|
|
29250a0efb | ||
|
|
c6e6bdf59f | ||
|
|
d80e1199ca | ||
|
|
10ea59066f | ||
|
|
79d6b10d7c | ||
|
|
6e78f36a0f | ||
|
|
16866e1180 | ||
|
|
6d130e5deb | ||
|
|
e30d8173c1 | ||
|
|
7a79f3a5ea |
@@ -23,7 +23,7 @@ runs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: oven-sh/setup-bun@v2
|
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||||
with:
|
with:
|
||||||
bun-version-file: ${{ !steps.bun-url.outputs.url && 'package.json' || '' }}
|
bun-version-file: ${{ !steps.bun-url.outputs.url && 'package.json' || '' }}
|
||||||
bun-download-url: ${{ steps.bun-url.outputs.url }}
|
bun-download-url: ${{ steps.bun-url.outputs.url }}
|
||||||
@@ -33,8 +33,9 @@ runs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: echo "dir=$(bun pm cache)" >> "$GITHUB_OUTPUT"
|
run: echo "dir=$(bun pm cache)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Cache Bun dependencies
|
- name: Restore Bun dependencies
|
||||||
uses: actions/cache@v4
|
id: bun-cache
|
||||||
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: ${{ steps.cache.outputs.dir }}
|
path: ${{ steps.cache.outputs.dir }}
|
||||||
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
|
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
|
||||||
@@ -56,3 +57,10 @@ runs:
|
|||||||
bun install ${{ inputs.install-flags }}
|
bun install ${{ inputs.install-flags }}
|
||||||
fi
|
fi
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
|
- name: Save Bun dependencies
|
||||||
|
if: steps.bun-cache.outputs.cache-hit != 'true' && github.event_name != 'pull_request' && github.event_name != 'pull_request_target'
|
||||||
|
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
|
with:
|
||||||
|
path: ${{ steps.cache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ runs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Create app token
|
- name: Create app token
|
||||||
id: apptoken
|
id: apptoken
|
||||||
uses: actions/create-github-app-token@v2
|
uses: actions/create-github-app-token@fee1f7d63c2ff003460e3d139729b119787bc349 # v2.2.2
|
||||||
with:
|
with:
|
||||||
app-id: ${{ inputs.opencode-app-id }}
|
app-id: ${{ inputs.opencode-app-id }}
|
||||||
private-key: ${{ inputs.opencode-app-secret }}
|
private-key: ${{ inputs.opencode-app-secret }}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- uses: oven-sh/setup-bun@v2
|
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||||
with:
|
with:
|
||||||
bun-version: latest
|
bun-version: latest
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ jobs:
|
|||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: Close inactive PRs
|
- name: Close inactive PRs
|
||||||
uses: actions/github-script@v8
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Close non-compliant issues and PRs after 2 hours
|
- name: Close non-compliant issues and PRs after 2 hours
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const { data: items } = await github.rest.issues.listForRepo({
|
const { data: items } = await github.rest.issues.listForRepo({
|
||||||
|
|||||||
@@ -21,18 +21,18 @@ jobs:
|
|||||||
REGISTRY: ghcr.io/${{ github.repository_owner }}
|
REGISTRY: ghcr.io/${{ github.repository_owner }}
|
||||||
TAG: "24.04"
|
TAG: "24.04"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- uses: ./.github/actions/setup-bun
|
- uses: ./.github/actions/setup-bun
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||||
|
|
||||||
- name: Login to GHCR
|
- name: Login to GHCR
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
|
|||||||
@@ -13,11 +13,11 @@ jobs:
|
|||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
|
|
||||||
- uses: ./.github/actions/setup-bun
|
- uses: ./.github/actions/setup-bun
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
contents: write
|
contents: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Fetch full history to access commits
|
fetch-depth: 0 # Fetch full history to access commits
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run opencode
|
- name: Run opencode
|
||||||
if: steps.commits.outputs.has_commits == 'true'
|
if: steps.commits.outputs.has_commits == 'true'
|
||||||
uses: sst/opencode/github@latest
|
uses: sst/opencode/github@2c14fc5586fe0b88e5c04732d2e846769cc35671 # latest
|
||||||
env:
|
env:
|
||||||
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: ./.github/actions/setup-bun
|
uses: ./.github/actions/setup-bun
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ jobs:
|
|||||||
timeout-minutes: 15
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
|
||||||
- name: Setup Nix
|
- name: Setup Nix
|
||||||
uses: nixbuild/nix-quick-install-action@v34
|
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
|
||||||
|
|
||||||
- name: Evaluate flake outputs (all systems)
|
- name: Evaluate flake outputs (all systems)
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -41,10 +41,10 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||||
|
|
||||||
- name: Setup Nix
|
- name: Setup Nix
|
||||||
uses: nixbuild/nix-quick-install-action@v34
|
uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
|
||||||
|
|
||||||
- name: Compute node_modules hash
|
- name: Compute node_modules hash
|
||||||
id: hash
|
id: hash
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
echo "Computed hash for ${SYSTEM}: $HASH"
|
echo "Computed hash for ${SYSTEM}: $HASH"
|
||||||
|
|
||||||
- name: Upload hash
|
- name: Upload hash
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: hash-${{ matrix.system }}
|
name: hash-${{ matrix.system }}
|
||||||
path: hash.txt
|
path: hash.txt
|
||||||
@@ -85,7 +85,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -102,7 +102,7 @@ jobs:
|
|||||||
git pull --rebase --autostash origin "$GITHUB_REF_NAME"
|
git pull --rebase --autostash origin "$GITHUB_REF_NAME"
|
||||||
|
|
||||||
- name: Download hash artifacts
|
- name: Download hash artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: hashes
|
path: hashes
|
||||||
pattern: hash-*
|
pattern: hash-*
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- name: Send nicely-formatted embed to Discord
|
- name: Send nicely-formatted embed to Discord
|
||||||
uses: SethCohen/github-releases-to-discord@v1
|
uses: SethCohen/github-releases-to-discord@24d166886aee4646d448c8a389ff9e1ebcab3682 # v1.20.0
|
||||||
with:
|
with:
|
||||||
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK }}
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ jobs:
|
|||||||
issues: read
|
issues: read
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- uses: ./.github/actions/setup-bun
|
- uses: ./.github/actions/setup-bun
|
||||||
|
|
||||||
- name: Run opencode
|
- name: Run opencode
|
||||||
uses: anomalyco/opencode/github@latest
|
uses: anomalyco/opencode/github@2c14fc5586fe0b88e5c04732d2e846769cc35671 # latest
|
||||||
env:
|
env:
|
||||||
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
|
||||||
OPENCODE_PERMISSION: '{"bash": "deny"}'
|
OPENCODE_PERMISSION: '{"bash": "deny"}'
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- name: Add Contributor Label
|
- name: Add Contributor Label
|
||||||
uses: actions/github-script@v8
|
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const isPR = !!context.payload.pull_request;
|
const isPR = !!context.payload.pull_request;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Check PR standards
|
- name: Check PR standards
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const pr = context.payload.pull_request;
|
const pr = context.payload.pull_request;
|
||||||
@@ -159,7 +159,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
steps:
|
steps:
|
||||||
- name: Check PR template compliance
|
- name: Check PR template compliance
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const pr = context.payload.pull_request;
|
const pr = context.payload.pull_request;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
publish:
|
publish:
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
if: github.repository == 'anomalyco/opencode'
|
if: github.repository == 'anomalyco/opencode'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
if: github.repository == 'anomalyco/opencode'
|
if: github.repository == 'anomalyco/opencode'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
with:
|
with:
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
@@ -95,14 +95,14 @@ jobs:
|
|||||||
GH_REPO: ${{ needs.version.outputs.repo }}
|
GH_REPO: ${{ needs.version.outputs.repo }}
|
||||||
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
GH_TOKEN: ${{ steps.committer.outputs.token }}
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: opencode-cli
|
name: opencode-cli
|
||||||
path: |
|
path: |
|
||||||
packages/opencode/dist/opencode-darwin*
|
packages/opencode/dist/opencode-darwin*
|
||||||
packages/opencode/dist/opencode-linux*
|
packages/opencode/dist/opencode-linux*
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: opencode-cli-windows
|
name: opencode-cli-windows
|
||||||
path: packages/opencode/dist/opencode-windows*
|
path: packages/opencode/dist/opencode-windows*
|
||||||
@@ -123,9 +123,9 @@ jobs:
|
|||||||
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
|
||||||
AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
with:
|
with:
|
||||||
name: opencode-cli-windows
|
name: opencode-cli-windows
|
||||||
path: packages/opencode/dist
|
path: packages/opencode/dist
|
||||||
@@ -138,13 +138,13 @@ jobs:
|
|||||||
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||||
|
|
||||||
- name: Azure login
|
- name: Azure login
|
||||||
uses: azure/login@v2
|
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
||||||
with:
|
with:
|
||||||
client-id: ${{ env.AZURE_CLIENT_ID }}
|
client-id: ${{ env.AZURE_CLIENT_ID }}
|
||||||
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
||||||
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
||||||
|
|
||||||
- uses: azure/artifact-signing-action@v1
|
- uses: azure/artifact-signing-action@b443cf8ea4124818d2ea9f043cba29fc3ec47b16 # v1.2.0
|
||||||
with:
|
with:
|
||||||
endpoint: ${{ env.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
endpoint: ${{ env.AZURE_TRUSTED_SIGNING_ENDPOINT }}
|
||||||
signing-account-name: ${{ env.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
signing-account-name: ${{ env.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
|
||||||
@@ -201,7 +201,7 @@ jobs:
|
|||||||
--clobber `
|
--clobber `
|
||||||
--repo "${{ needs.version.outputs.repo }}"
|
--repo "${{ needs.version.outputs.repo }}"
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: opencode-cli-signed-windows
|
name: opencode-cli-signed-windows
|
||||||
path: |
|
path: |
|
||||||
@@ -244,14 +244,14 @@ jobs:
|
|||||||
- host: "blacksmith-4vcpu-ubuntu-2404"
|
- host: "blacksmith-4vcpu-ubuntu-2404"
|
||||||
target: x86_64-unknown-linux-gnu
|
target: x86_64-unknown-linux-gnu
|
||||||
platform_flag: --linux
|
platform_flag: --linux
|
||||||
- host: "blacksmith-4vcpu-ubuntu-2404"
|
- host: "blacksmith-4vcpu-ubuntu-2404-arm"
|
||||||
target: aarch64-unknown-linux-gnu
|
target: aarch64-unknown-linux-gnu
|
||||||
platform_flag: --linux
|
platform_flag: --linux --arm64
|
||||||
runs-on: ${{ matrix.settings.host }}
|
runs-on: ${{ matrix.settings.host }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
|
|
||||||
- uses: apple-actions/import-codesign-certs@v2
|
- uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0
|
||||||
if: runner.os == 'macOS'
|
if: runner.os == 'macOS'
|
||||||
with:
|
with:
|
||||||
keychain: build
|
keychain: build
|
||||||
@@ -268,19 +268,19 @@ jobs:
|
|||||||
|
|
||||||
- name: Azure login
|
- name: Azure login
|
||||||
if: runner.os == 'Windows'
|
if: runner.os == 'Windows'
|
||||||
uses: azure/login@v2
|
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
|
||||||
with:
|
with:
|
||||||
client-id: ${{ env.AZURE_CLIENT_ID }}
|
client-id: ${{ env.AZURE_CLIENT_ID }}
|
||||||
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
tenant-id: ${{ env.AZURE_TENANT_ID }}
|
||||||
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
- name: Cache apt packages
|
- name: Cache apt packages
|
||||||
if: contains(matrix.settings.host, 'ubuntu')
|
if: contains(matrix.settings.host, 'ubuntu')
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: ~/apt-cache
|
path: ~/apt-cache
|
||||||
key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-${{ hashFiles('.github/workflows/publish.yml') }}
|
key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-${{ hashFiles('.github/workflows/publish.yml') }}
|
||||||
@@ -388,12 +388,12 @@ jobs:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: opencode-desktop-${{ matrix.settings.target }}
|
name: opencode-desktop-${{ matrix.settings.target }}
|
||||||
path: packages/desktop/dist/*
|
path: packages/desktop/dist/*
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
if: needs.version.outputs.release
|
if: needs.version.outputs.release
|
||||||
with:
|
with:
|
||||||
name: latest-yml-${{ matrix.settings.target }}
|
name: latest-yml-${{ matrix.settings.target }}
|
||||||
@@ -408,44 +408,44 @@ jobs:
|
|||||||
if: always() && !failure() && !cancelled()
|
if: always() && !failure() && !cancelled()
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
|
||||||
|
|
||||||
- uses: ./.github/actions/setup-bun
|
- uses: ./.github/actions/setup-bun
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
- name: Login to GitHub Container Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
|
||||||
|
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
registry-url: "https://registry.npmjs.org"
|
registry-url: "https://registry.npmjs.org"
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
with:
|
with:
|
||||||
name: opencode-cli
|
name: opencode-cli
|
||||||
path: packages/opencode/dist
|
path: packages/opencode/dist
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
with:
|
with:
|
||||||
name: opencode-cli-windows
|
name: opencode-cli-windows
|
||||||
path: packages/opencode/dist
|
path: packages/opencode/dist
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
with:
|
with:
|
||||||
name: opencode-cli-signed-windows
|
name: opencode-cli-signed-windows
|
||||||
path: packages/opencode/dist
|
path: packages/opencode/dist
|
||||||
|
|
||||||
- uses: actions/download-artifact@v4
|
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||||
if: needs.version.outputs.release
|
if: needs.version.outputs.release
|
||||||
with:
|
with:
|
||||||
pattern: latest-yml-*
|
pattern: latest-yml-*
|
||||||
@@ -459,7 +459,7 @@ jobs:
|
|||||||
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
|
||||||
|
|
||||||
- name: Cache apt packages (AUR)
|
- name: Cache apt packages (AUR)
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: /var/cache/apt/archives
|
path: /var/cache/apt/archives
|
||||||
key: ${{ runner.os }}-apt-aur-${{ hashFiles('.github/workflows/publish.yml') }}
|
key: ${{ runner.os }}-apt-aur-${{ hashFiles('.github/workflows/publish.yml') }}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: ./.github/actions/setup-bun
|
uses: ./.github/actions/setup-bun
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: ./.github/actions/setup-bun
|
uses: ./.github/actions/setup-bun
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ jobs:
|
|||||||
name: Release Zed Extension
|
name: Release Zed Extension
|
||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,12 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ jobs:
|
|||||||
git config --global user.name "opencode"
|
git config --global user.name "opencode"
|
||||||
|
|
||||||
- name: Cache Turbo
|
- name: Cache Turbo
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: node_modules/.cache/turbo
|
path: node_modules/.cache/turbo
|
||||||
key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json', '**/package.json') }}-${{ github.sha }}
|
key: turbo-${{ runner.os }}-${{ hashFiles('turbo.json', '**/package.json') }}-${{ github.sha }}
|
||||||
@@ -75,7 +75,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Publish unit reports
|
- name: Publish unit reports
|
||||||
if: always()
|
if: always()
|
||||||
uses: mikepenz/action-junit-report@v6
|
uses: mikepenz/action-junit-report@bccf2e31636835cf0874589931c4116687171386 # v6.4.0
|
||||||
with:
|
with:
|
||||||
report_paths: packages/*/.artifacts/unit/junit.xml
|
report_paths: packages/*/.artifacts/unit/junit.xml
|
||||||
check_name: "unit results (${{ matrix.settings.name }})"
|
check_name: "unit results (${{ matrix.settings.name }})"
|
||||||
@@ -85,7 +85,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload unit artifacts
|
- name: Upload unit artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: unit-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
name: unit-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
||||||
include-hidden-files: true
|
include-hidden-files: true
|
||||||
@@ -111,12 +111,12 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Setup Node
|
- name: Setup Node
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
|
||||||
with:
|
with:
|
||||||
node-version: "24"
|
node-version: "24"
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Cache Playwright browsers
|
- name: Cache Playwright browsers
|
||||||
id: playwright-cache
|
id: playwright-cache
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
|
||||||
with:
|
with:
|
||||||
path: ${{ github.workspace }}/.playwright-browsers
|
path: ${{ github.workspace }}/.playwright-browsers
|
||||||
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ steps.playwright-version.outputs.version }}-chromium
|
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ steps.playwright-version.outputs.version }}-chromium
|
||||||
@@ -155,7 +155,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Upload Playwright artifacts
|
- name: Upload Playwright artifacts
|
||||||
if: always()
|
if: always()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||||
with:
|
with:
|
||||||
name: playwright-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
name: playwright-${{ matrix.settings.name }}-${{ github.run_attempt }}
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
issues: write
|
issues: write
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ jobs:
|
|||||||
runs-on: blacksmith-4vcpu-ubuntu-2404
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
|
||||||
|
|
||||||
- name: Setup Bun
|
- name: Setup Bun
|
||||||
uses: ./.github/actions/setup-bun
|
uses: ./.github/actions/setup-bun
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://opencode.ai/config.json",
|
"$schema": "https://opencode.ai/config.json",
|
||||||
"provider": {},
|
"provider": {},
|
||||||
"permission": {
|
"permission": {},
|
||||||
"edit": {
|
|
||||||
"packages/opencode/migration/*": "ask",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"mcp": {},
|
"mcp": {},
|
||||||
"tools": {
|
"tools": {
|
||||||
"github-triage": false,
|
"github-triage": false,
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Deepening
|
||||||
|
|
||||||
|
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**.
|
||||||
|
|
||||||
|
## Dependency categories
|
||||||
|
|
||||||
|
When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
|
||||||
|
|
||||||
|
### 1. In-process
|
||||||
|
|
||||||
|
Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
|
||||||
|
|
||||||
|
### 2. Local-substitutable
|
||||||
|
|
||||||
|
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
|
||||||
|
|
||||||
|
### 3. Remote but owned (Ports & Adapters)
|
||||||
|
|
||||||
|
Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
|
||||||
|
|
||||||
|
Recommendation shape: _"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."_
|
||||||
|
|
||||||
|
### 4. True external (Mock)
|
||||||
|
|
||||||
|
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
|
||||||
|
|
||||||
|
## Seam discipline
|
||||||
|
|
||||||
|
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
|
||||||
|
- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
|
||||||
|
|
||||||
|
## Testing strategy: replace, don't layer
|
||||||
|
|
||||||
|
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
|
||||||
|
- Write new tests at the deepened module's interface. The **interface is the test surface**.
|
||||||
|
- Tests assert on observable outcomes through the interface, not internal state.
|
||||||
|
- Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Interface Design
|
||||||
|
|
||||||
|
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
|
||||||
|
|
||||||
|
Uses the vocabulary in [LANGUAGE.md](LANGUAGE.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Frame the problem space
|
||||||
|
|
||||||
|
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
|
||||||
|
|
||||||
|
- The constraints any new interface would need to satisfy
|
||||||
|
- The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
|
||||||
|
- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
|
||||||
|
|
||||||
|
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
|
||||||
|
|
||||||
|
### 2. Spawn sub-agents
|
||||||
|
|
||||||
|
Spawn 3+ sub-agents in parallel using the Agent tool. Each must produce a **radically different** interface for the deepened module.
|
||||||
|
|
||||||
|
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
|
||||||
|
|
||||||
|
- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
|
||||||
|
- Agent 2: "Maximise flexibility — support many use cases and extension."
|
||||||
|
- Agent 3: "Optimise for the most common caller — make the default case trivial."
|
||||||
|
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
|
||||||
|
|
||||||
|
Include both [LANGUAGE.md](LANGUAGE.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
|
||||||
|
|
||||||
|
Each sub-agent outputs:
|
||||||
|
|
||||||
|
1. Interface (types, methods, params — plus invariants, ordering, error modes)
|
||||||
|
2. Usage example showing how callers use it
|
||||||
|
3. What the implementation hides behind the seam
|
||||||
|
4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
|
||||||
|
5. Trade-offs — where leverage is high, where it's thin
|
||||||
|
|
||||||
|
### 3. Present and compare
|
||||||
|
|
||||||
|
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
|
||||||
|
|
||||||
|
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# Language
|
||||||
|
|
||||||
|
Shared vocabulary for every suggestion this skill makes. Use these terms exactly — don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
|
||||||
|
|
||||||
|
## Terms
|
||||||
|
|
||||||
|
**Module**
|
||||||
|
Anything with an interface and an implementation. Deliberately scale-agnostic — applies equally to a function, class, package, or tier-spanning slice.
|
||||||
|
_Avoid_: unit, component, service.
|
||||||
|
|
||||||
|
**Interface**
|
||||||
|
Everything a caller must know to use the module correctly. Includes the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics.
|
||||||
|
_Avoid_: API, signature (too narrow — those refer only to the type-level surface).
|
||||||
|
|
||||||
|
**Implementation**
|
||||||
|
What's inside a module — its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
|
||||||
|
|
||||||
|
**Depth**
|
||||||
|
Leverage at the interface — the amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface. A module is **shallow** when the interface is nearly as complex as the implementation.
|
||||||
|
|
||||||
|
**Seam** _(from Michael Feathers)_
|
||||||
|
A place where you can alter behaviour without editing in that place. The _location_ at which a module's interface lives. Choosing where to put the seam is its own design decision, distinct from what goes behind it.
|
||||||
|
_Avoid_: boundary (overloaded with DDD's bounded context).
|
||||||
|
|
||||||
|
**Adapter**
|
||||||
|
A concrete thing that satisfies an interface at a seam. Describes _role_ (what slot it fills), not substance (what's inside).
|
||||||
|
|
||||||
|
**Leverage**
|
||||||
|
What callers get from depth. More capability per unit of interface they have to learn. One implementation pays back across N call sites and M tests.
|
||||||
|
|
||||||
|
**Locality**
|
||||||
|
What maintainers get from depth. Change, bugs, knowledge, and verification concentrate at one place rather than spreading across callers. Fix once, fixed everywhere.
|
||||||
|
|
||||||
|
## Principles
|
||||||
|
|
||||||
|
- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts — they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
|
||||||
|
- **The deletion test.** Imagine deleting the module. If complexity vanishes, the module wasn't hiding anything (it was a pass-through). If complexity reappears across N callers, the module was earning its keep.
|
||||||
|
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test _past_ the interface, the module is probably the wrong shape.
|
||||||
|
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
||||||
|
|
||||||
|
## Relationships
|
||||||
|
|
||||||
|
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
||||||
|
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
||||||
|
- A **Seam** is where a **Module**'s **Interface** lives.
|
||||||
|
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
||||||
|
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
||||||
|
|
||||||
|
## Rejected framings
|
||||||
|
|
||||||
|
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
||||||
|
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow — interface here includes every fact a caller must know.
|
||||||
|
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
name: improve-codebase-architecture
|
||||||
|
description: Find deepening opportunities in a codebase, informed by the domain language in CONTEXT.md and the decisions in docs/adr/. Use when the user wants to improve architecture, find refactoring opportunities, consolidate tightly-coupled modules, or make a codebase more testable and AI-navigable.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Improve Codebase Architecture
|
||||||
|
|
||||||
|
Surface architectural friction and propose **deepening opportunities** — refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
||||||
|
|
||||||
|
## Glossary
|
||||||
|
|
||||||
|
Use these terms exactly in every suggestion. Consistent language is the point — don't drift into "component," "service," "API," or "boundary." Full definitions in [LANGUAGE.md](LANGUAGE.md).
|
||||||
|
|
||||||
|
- **Module** — anything with an interface and an implementation (function, class, package, slice).
|
||||||
|
- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
|
||||||
|
- **Implementation** — the code inside.
|
||||||
|
- **Depth** — leverage at the interface: a lot of behaviour behind a small interface. **Deep** = high leverage. **Shallow** = interface nearly as complex as the implementation.
|
||||||
|
- **Seam** — where an interface lives; a place behaviour can be altered without editing in place. (Use this, not "boundary.")
|
||||||
|
- **Adapter** — a concrete thing satisfying an interface at a seam.
|
||||||
|
- **Leverage** — what callers get from depth.
|
||||||
|
- **Locality** — what maintainers get from depth: change, bugs, knowledge concentrated in one place.
|
||||||
|
|
||||||
|
Key principles (see [LANGUAGE.md](LANGUAGE.md) for the full list):
|
||||||
|
|
||||||
|
- **Deletion test**: imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
||||||
|
- **The interface is the test surface.**
|
||||||
|
- **One adapter = hypothetical seam. Two adapters = real seam.**
|
||||||
|
|
||||||
|
This skill is _informed_ by the project's domain model. The domain language gives names to good seams; ADRs record decisions the skill should not re-litigate.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Explore
|
||||||
|
|
||||||
|
Read the project's domain glossary and any ADRs in the area you're touching first.
|
||||||
|
|
||||||
|
Then use the Agent tool with `subagent_type=Explore` to walk the codebase. Don't follow rigid heuristics — explore organically and note where you experience friction:
|
||||||
|
|
||||||
|
- Where does understanding one concept require bouncing between many small modules?
|
||||||
|
- Where are modules **shallow** — interface nearly as complex as the implementation?
|
||||||
|
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
|
||||||
|
- Where do tightly-coupled modules leak across their seams?
|
||||||
|
- Which parts of the codebase are untested, or hard to test through their current interface?
|
||||||
|
|
||||||
|
Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
|
||||||
|
|
||||||
|
### 2. Present candidates
|
||||||
|
|
||||||
|
Present a numbered list of deepening opportunities. For each candidate:
|
||||||
|
|
||||||
|
- **Files** — which files/modules are involved
|
||||||
|
- **Problem** — why the current architecture is causing friction
|
||||||
|
- **Solution** — plain English description of what would change
|
||||||
|
- **Benefits** — explained in terms of locality and leverage, and also in how tests would improve
|
||||||
|
|
||||||
|
**Use CONTEXT.md vocabulary for the domain, and [LANGUAGE.md](LANGUAGE.md) vocabulary for the architecture.** If `CONTEXT.md` defines "Order," talk about "the Order intake module" — not "the FooBarHandler," and not "the Order service."
|
||||||
|
|
||||||
|
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly (e.g. _"contradicts ADR-0007 — but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
||||||
|
|
||||||
|
Do NOT propose interfaces yet. Ask the user: "Which of these would you like to explore?"
|
||||||
|
|
||||||
|
### 3. Grilling loop
|
||||||
|
|
||||||
|
Once the user picks a candidate, drop into a grilling conversation. Walk the design tree with them — constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
|
||||||
|
|
||||||
|
Side effects happen inline as decisions crystallize:
|
||||||
|
|
||||||
|
- **Naming a deepened module after a concept not in `CONTEXT.md`?** Add the term to `CONTEXT.md` — same discipline as `/grill-with-docs` (see [CONTEXT-FORMAT.md](../grill-with-docs/CONTEXT-FORMAT.md)). Create the file lazily if it doesn't exist.
|
||||||
|
- **Sharpening a fuzzy term during the conversation?** Update `CONTEXT.md` right there.
|
||||||
|
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing — skip ephemeral reasons ("not worth it right now") and self-evident ones. See [ADR-FORMAT.md](../grill-with-docs/ADR-FORMAT.md).
|
||||||
|
- **Want to explore alternative interfaces for the deepened module?** See [INTERFACE-DESIGN.md](INTERFACE-DESIGN.md).
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
### General Principles
|
### General Principles
|
||||||
|
|
||||||
- Keep things in one function unless composable or reusable
|
- Keep things in one function unless composable or reusable
|
||||||
|
- Do not extract single-use helpers preemptively. Inline the logic at the call site unless the helper is reused, hides a genuinely complex boundary, or has a clear independent name that improves the caller.
|
||||||
- Avoid `try`/`catch` where possible
|
- Avoid `try`/`catch` where possible
|
||||||
- Avoid using the `any` type
|
- Avoid using the `any` type
|
||||||
- Use Bun APIs when possible, like `Bun.file()`
|
- Use Bun APIs when possible, like `Bun.file()`
|
||||||
@@ -72,6 +73,29 @@ function foo() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Complex Logic
|
||||||
|
|
||||||
|
When a function has several validation branches or supporting details, make the main function read as the happy path and move supporting details into small helpers below it.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// Good
|
||||||
|
export function loadThing(input: unknown) {
|
||||||
|
const config = requireConfig(input)
|
||||||
|
const metadata = readMetadata(input)
|
||||||
|
return createThing({ config, metadata })
|
||||||
|
}
|
||||||
|
|
||||||
|
function requireConfig(input: unknown) {
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- Keep helpers close to the code they support, below the main export when that improves readability.
|
||||||
|
- Do not over-abstract simple expressions into many single-use helpers; extract only when it names a real concept like `requireConfig` or `readMetadata`.
|
||||||
|
- Do not return `Effect` from helpers unless they actually perform effectful work. Synchronous parsing, validation, and option building should stay synchronous.
|
||||||
|
- Prefer Effect schema helpers such as `Schema.UnknownFromJsonString` and `Schema.decodeUnknownOption` over manual `JSON.parse` wrapped in `Effect.try` when parsing untrusted JSON strings.
|
||||||
|
- Add comments for non-obvious constraints and surprising behavior, not for obvious assignments or control flow.
|
||||||
|
|
||||||
### Schema Definitions (Drizzle)
|
### Schema Definitions (Drizzle)
|
||||||
|
|
||||||
Use snake_case for field names so column names don't need to be redefined as strings.
|
Use snake_case for field names so column names don't need to be redefined as strings.
|
||||||
|
|||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
[install]
|
[install]
|
||||||
exact = true
|
exact = true
|
||||||
|
# Only install newly resolved package versions published at least 3 days ago.
|
||||||
|
minimumReleaseAge = 259200
|
||||||
|
minimumReleaseAgeExcludes = ["@opentui/core", "@opentui/core-darwin-arm64", "@opentui/core-darwin-x64", "@opentui/core-linux-arm64", "@opentui/core-linux-x64", "@opentui/core-win32-arm64", "@opentui/core-win32-x64", "@opentui/keymap", "@opentui/solid"]
|
||||||
|
|
||||||
[test]
|
[test]
|
||||||
root = "./do-not-run-tests-from-root"
|
root = "./do-not-run-tests-from-root"
|
||||||
|
|
||||||
|
|||||||
@@ -293,3 +293,13 @@ new sst.cloudflare.x.SolidStart("Console", {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
////////////////
|
||||||
|
// HELPERS
|
||||||
|
////////////////
|
||||||
|
|
||||||
|
export const stat = new sst.cloudflare.Worker("Stat", {
|
||||||
|
handler: "packages/console/function/src/stat.ts",
|
||||||
|
link: [database],
|
||||||
|
url: true,
|
||||||
|
})
|
||||||
|
|||||||
+103
-23
@@ -1,6 +1,8 @@
|
|||||||
import { SECRET } from "./secret"
|
import { SECRET } from "./secret"
|
||||||
import { domain } from "./stage"
|
import { domain } from "./stage"
|
||||||
|
|
||||||
|
const description = "Managed by SST (Don't edit in Honeycomb UI)"
|
||||||
|
|
||||||
const webhookRecipient = new honeycomb.WebhookRecipient("DiscordAlerts", {
|
const webhookRecipient = new honeycomb.WebhookRecipient("DiscordAlerts", {
|
||||||
name: $app.stage === "production" ? "Discord Alerts" : `Discord Alerts (${$app.stage})`,
|
name: $app.stage === "production" ? "Discord Alerts" : `Discord Alerts (${$app.stage})`,
|
||||||
url: `https://${domain}/honeycomb/webhook`,
|
url: `https://${domain}/honeycomb/webhook`,
|
||||||
@@ -25,6 +27,16 @@ const webhookRecipient = new honeycomb.WebhookRecipient("DiscordAlerts", {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Honeycomb can keep stale query-local calculated fields when the name is unchanged,
|
||||||
|
// so tie the field name to the expression while avoiding deploy-to-deploy churn.
|
||||||
|
// https://github.com/honeycombio/terraform-provider-honeycombio/issues/852
|
||||||
|
const calculatedField = (field: { name: string; expression: string }) => ({
|
||||||
|
...field,
|
||||||
|
name: `${field.name}_${(
|
||||||
|
Array.from(field.expression).reduce((result, char) => Math.imul(31, result) + char.charCodeAt(0), 0) >>> 0
|
||||||
|
).toString(36)}`,
|
||||||
|
})
|
||||||
|
|
||||||
const modelHttpErrorsQuery = (product: "go" | "zen") => {
|
const modelHttpErrorsQuery = (product: "go" | "zen") => {
|
||||||
const filters = [
|
const filters = [
|
||||||
{ column: "model", op: "exists" },
|
{ column: "model", op: "exists" },
|
||||||
@@ -32,21 +44,26 @@ const modelHttpErrorsQuery = (product: "go" | "zen") => {
|
|||||||
{ column: "user_agent", op: "contains", value: "opencode" },
|
{ column: "user_agent", op: "contains", value: "opencode" },
|
||||||
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
|
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
|
||||||
]
|
]
|
||||||
|
const failedHttpStatus = calculatedField({
|
||||||
|
name: "is_failed_http_status",
|
||||||
|
expression:
|
||||||
|
product === "go"
|
||||||
|
? `IF(AND(GTE($status, "400"), NOT(EQUALS($status, "401")), NOT(EQUALS($status, "429"))), 1, 0)`
|
||||||
|
: `IF(AND(EQUALS($status, "429"), $isFreeTier), 0, AND(GTE($status, "400"), NOT(EQUALS($status, "401"))), 1, 0)`,
|
||||||
|
})
|
||||||
|
|
||||||
return honeycomb.getQuerySpecificationOutput({
|
return honeycomb.getQuerySpecificationOutput({
|
||||||
breakdowns: ["model"],
|
breakdowns: ["model"],
|
||||||
calculatedFields: [
|
calculatedFields: [failedHttpStatus],
|
||||||
{
|
|
||||||
name: "is_failed_http_status",
|
|
||||||
expression:
|
|
||||||
product === "go"
|
|
||||||
? `IF(AND(GTE($status, "400"), NOT(EQUALS($status, "401")), NOT(EQUALS($status, "429"))), 1, 0)`
|
|
||||||
: `IF(AND(GTE($status, "400"), NOT(EQUALS($status, "401"))), 1, 0)`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
calculations: [
|
calculations: [
|
||||||
{ op: "COUNT", name: "TOTAL", filterCombination: "AND", filters },
|
{ op: "COUNT", name: "TOTAL", filterCombination: "AND", filters },
|
||||||
{ op: "SUM", name: "FAILED", column: "is_failed_http_status", filterCombination: "AND", filters },
|
{
|
||||||
|
op: "SUM",
|
||||||
|
name: "FAILED",
|
||||||
|
column: failedHttpStatus.name,
|
||||||
|
filterCombination: "AND",
|
||||||
|
filters,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
formulas: [{ name: "ERROR", expression: "IF(GTE($TOTAL, 100), DIV($FAILED, $TOTAL), 0)" }],
|
formulas: [{ name: "ERROR", expression: "IF(GTE($TOTAL, 100), DIV($FAILED, $TOTAL), 0)" }],
|
||||||
timeRange: 900,
|
timeRange: 900,
|
||||||
@@ -59,31 +76,30 @@ const providerHttpErrorsQuery = (product: "go" | "zen") => {
|
|||||||
{ column: "user_agent", op: "contains", value: "opencode" },
|
{ column: "user_agent", op: "contains", value: "opencode" },
|
||||||
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
|
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
|
||||||
]
|
]
|
||||||
|
const successHttpStatus = calculatedField({
|
||||||
|
name: "is_success_http_status",
|
||||||
|
expression: `IF(AND(GTE($status, "200"), LT($status, "400")), 1, 0)`,
|
||||||
|
})
|
||||||
|
const failedProviderHttpStatus = calculatedField({
|
||||||
|
name: "is_failed_provider_http_status",
|
||||||
|
expression: `IF(GT($llm.error.code, "400"), 1, 0)`,
|
||||||
|
})
|
||||||
|
|
||||||
return honeycomb.getQuerySpecificationOutput({
|
return honeycomb.getQuerySpecificationOutput({
|
||||||
breakdowns: ["provider"],
|
breakdowns: ["provider"],
|
||||||
calculatedFields: [
|
calculatedFields: [successHttpStatus, failedProviderHttpStatus],
|
||||||
{
|
|
||||||
name: "is_success_http_status",
|
|
||||||
expression: `IF(AND(GTE($status, "200"), LT($status, "400")), 1, 0)`,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "is_failed_provider_http_status",
|
|
||||||
expression: `IF(GT($llm.error.code, "400"), 1, 0)`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
calculations: [
|
calculations: [
|
||||||
{
|
{
|
||||||
op: "SUM",
|
op: "SUM",
|
||||||
name: "SUCCESS",
|
name: "SUCCESS",
|
||||||
column: "is_success_http_status",
|
column: successHttpStatus.name,
|
||||||
filterCombination: "AND",
|
filterCombination: "AND",
|
||||||
filters: [...filters, { column: "event_type", op: "=", value: "completions" }],
|
filters: [...filters, { column: "event_type", op: "=", value: "completions" }],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
op: "SUM",
|
op: "SUM",
|
||||||
name: "FAILED",
|
name: "FAILED",
|
||||||
column: "is_failed_provider_http_status",
|
column: failedProviderHttpStatus.name,
|
||||||
filterCombination: "AND",
|
filterCombination: "AND",
|
||||||
filters: [...filters, { column: "event_type", op: "=", value: "llm.error" }],
|
filters: [...filters, { column: "event_type", op: "=", value: "llm.error" }],
|
||||||
},
|
},
|
||||||
@@ -95,7 +111,33 @@ const providerHttpErrorsQuery = (product: "go" | "zen") => {
|
|||||||
}).json
|
}).json
|
||||||
}
|
}
|
||||||
|
|
||||||
const description = "Managed by SST (Don't edit in Honeycomb UI)"
|
const modelLowTpsQuery = (product: "go" | "zen") => {
|
||||||
|
const filters = [
|
||||||
|
{ column: "model", op: "exists" },
|
||||||
|
{ column: "event_type", op: "=", value: "completions" },
|
||||||
|
{ column: "user_agent", op: "contains", value: "opencode" },
|
||||||
|
{ column: "isGoTier", op: "=", value: product === "go" ? "true" : "false" },
|
||||||
|
{ column: "status", op: ">=", value: "200" },
|
||||||
|
{ column: "status", op: "<", value: "400" },
|
||||||
|
{ column: "tps.output", op: "exists" },
|
||||||
|
]
|
||||||
|
|
||||||
|
return honeycomb.getQuerySpecificationOutput({
|
||||||
|
breakdowns: ["model"],
|
||||||
|
calculations: [
|
||||||
|
{ op: "COUNT", name: "TOTAL", filterCombination: "AND", filters },
|
||||||
|
{
|
||||||
|
op: "P50",
|
||||||
|
name: "TPS",
|
||||||
|
column: "tps.output",
|
||||||
|
filterCombination: "AND",
|
||||||
|
filters,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
formulas: [{ name: "LOW_TPS", expression: "IF(GTE($TOTAL, 100), $TPS, 999)" }],
|
||||||
|
timeRange: 1800,
|
||||||
|
}).json
|
||||||
|
}
|
||||||
|
|
||||||
new honeycomb.Trigger("IncreasedModelHttpErrorsGo", {
|
new honeycomb.Trigger("IncreasedModelHttpErrorsGo", {
|
||||||
name: "Increased Model HTTP Errors [Go]",
|
name: "Increased Model HTTP Errors [Go]",
|
||||||
@@ -135,6 +177,44 @@ new honeycomb.Trigger("IncreasedModelHttpErrorsZen", {
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
new honeycomb.Trigger("LowModelTpsGo", {
|
||||||
|
name: "Low Model TPS [Go]",
|
||||||
|
description,
|
||||||
|
queryJson: modelLowTpsQuery("go"),
|
||||||
|
alertType: "on_change",
|
||||||
|
frequency: 600,
|
||||||
|
thresholds: [{ op: "<=", value: 10, exceededLimit: 1 }],
|
||||||
|
recipients: [
|
||||||
|
{
|
||||||
|
id: webhookRecipient.id,
|
||||||
|
notificationDetails: [
|
||||||
|
{
|
||||||
|
variables: [{ name: "type", value: "model_low_tps" }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
new honeycomb.Trigger("LowModelTpsZen", {
|
||||||
|
name: "Low Model TPS [Zen]",
|
||||||
|
description,
|
||||||
|
queryJson: modelLowTpsQuery("zen"),
|
||||||
|
alertType: "on_change",
|
||||||
|
frequency: 600,
|
||||||
|
thresholds: [{ op: "<=", value: 10, exceededLimit: 1 }],
|
||||||
|
recipients: [
|
||||||
|
{
|
||||||
|
id: webhookRecipient.id,
|
||||||
|
notificationDetails: [
|
||||||
|
{
|
||||||
|
variables: [{ name: "type", value: "model_low_tps" }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
new honeycomb.Trigger("IncreasedProviderHttpErrorsGo", {
|
new honeycomb.Trigger("IncreasedProviderHttpErrorsGo", {
|
||||||
name: "Increased Provider HTTP Errors [Go]",
|
name: "Increased Provider HTTP Errors [Go]",
|
||||||
description,
|
description,
|
||||||
|
|||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"nodeModules": {
|
"nodeModules": {
|
||||||
"x86_64-linux": "sha256-LTo0ohJN5hBOubqFLVL45unVEIwBDkACNVv64k2nkq4=",
|
"x86_64-linux": "sha256-Hw7sVV9rTm6qBMtdwfLIV2QvxvLQY5qrywXzuyYbhcs=",
|
||||||
"aarch64-linux": "sha256-oYKY2UJRWG2fhufW4aGujX/Poou93023ZF2Fu7oyYOw=",
|
"aarch64-linux": "sha256-++oXnY7YqrYt0Qv7ZISmoHliARM9qEP8FacqLxGZH1c=",
|
||||||
"aarch64-darwin": "sha256-618c9vqKN5I+no1nzylctAiWvqw7Bsa+bzSTNwXmSQA=",
|
"aarch64-darwin": "sha256-kZVa0R1YbuvtTzpETqK6ddj4ISje5jBFHBdlynkhW7Q=",
|
||||||
"x86_64-darwin": "sha256-1ro3/gH0FC0TWXwWT+k675xR396GE98HpnBEeuD4t6k="
|
"x86_64-darwin": "sha256-94eagNDa8GGJxF8BsMX2BF5Pa+QTl48lXL1+6HgEn0I="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-6
@@ -28,16 +28,16 @@
|
|||||||
"packages/slack"
|
"packages/slack"
|
||||||
],
|
],
|
||||||
"catalog": {
|
"catalog": {
|
||||||
"@effect/opentelemetry": "4.0.0-beta.57",
|
"@effect/opentelemetry": "4.0.0-beta.65",
|
||||||
"@effect/platform-node": "4.0.0-beta.57",
|
"@effect/platform-node": "4.0.0-beta.65",
|
||||||
"@npmcli/arborist": "9.4.0",
|
"@npmcli/arborist": "9.4.0",
|
||||||
"@types/bun": "1.3.12",
|
"@types/bun": "1.3.12",
|
||||||
"@types/cross-spawn": "6.0.6",
|
"@types/cross-spawn": "6.0.6",
|
||||||
"@octokit/rest": "22.0.0",
|
"@octokit/rest": "22.0.0",
|
||||||
"@hono/zod-validator": "0.4.2",
|
"@hono/zod-validator": "0.4.2",
|
||||||
"@opentui/core": "0.2.6",
|
"@opentui/core": "0.2.10",
|
||||||
"@opentui/keymap": "0.2.6",
|
"@opentui/keymap": "0.2.10",
|
||||||
"@opentui/solid": "0.2.6",
|
"@opentui/solid": "0.2.10",
|
||||||
"ulid": "3.0.1",
|
"ulid": "3.0.1",
|
||||||
"@kobalte/core": "0.13.11",
|
"@kobalte/core": "0.13.11",
|
||||||
"@types/luxon": "3.7.1",
|
"@types/luxon": "3.7.1",
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
"dompurify": "3.3.1",
|
"dompurify": "3.3.1",
|
||||||
"drizzle-kit": "1.0.0-beta.19-d95b7a4",
|
"drizzle-kit": "1.0.0-beta.19-d95b7a4",
|
||||||
"drizzle-orm": "1.0.0-beta.19-d95b7a4",
|
"drizzle-orm": "1.0.0-beta.19-d95b7a4",
|
||||||
"effect": "4.0.0-beta.59",
|
"effect": "4.0.0-beta.65",
|
||||||
"ai": "6.0.168",
|
"ai": "6.0.168",
|
||||||
"cross-spawn": "7.0.6",
|
"cross-spawn": "7.0.6",
|
||||||
"hono": "4.10.7",
|
"hono": "4.10.7",
|
||||||
@@ -128,11 +128,15 @@
|
|||||||
"electron"
|
"electron"
|
||||||
],
|
],
|
||||||
"overrides": {
|
"overrides": {
|
||||||
|
"@opentui/core": "catalog:",
|
||||||
|
"@opentui/keymap": "catalog:",
|
||||||
|
"@opentui/solid": "catalog:",
|
||||||
"@types/bun": "catalog:",
|
"@types/bun": "catalog:",
|
||||||
"@types/node": "catalog:"
|
"@types/node": "catalog:"
|
||||||
},
|
},
|
||||||
"patchedDependencies": {
|
"patchedDependencies": {
|
||||||
"@npmcli/agent@4.0.0": "patches/@npmcli%2Fagent@4.0.0.patch",
|
"@npmcli/agent@4.0.0": "patches/@npmcli%2Fagent@4.0.0.patch",
|
||||||
|
"@silvia-odwyer/photon-node@0.3.4": "patches/@silvia-odwyer%2Fphoton-node@0.3.4.patch",
|
||||||
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
"@standard-community/standard-openapi@0.2.9": "patches/@standard-community%2Fstandard-openapi@0.2.9.patch",
|
||||||
"solid-js@1.9.10": "patches/solid-js@1.9.10.patch"
|
"solid-js@1.9.10": "patches/solid-js@1.9.10.patch"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/app",
|
"name": "@opencode-ai/app",
|
||||||
"version": "1.14.44",
|
"version": "1.15.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
@@ -73,7 +73,6 @@
|
|||||||
"solid-js": "catalog:",
|
"solid-js": "catalog:",
|
||||||
"solid-list": "catalog:",
|
"solid-list": "catalog:",
|
||||||
"tailwindcss": "catalog:",
|
"tailwindcss": "catalog:",
|
||||||
"virtua": "catalog:",
|
"virtua": "catalog:"
|
||||||
"zod": "catalog:"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,8 @@ function createCommandEntries(props: {
|
|||||||
const allowed = createMemo(() => {
|
const allowed = createMemo(() => {
|
||||||
if (props.filesOnly()) return []
|
if (props.filesOnly()) return []
|
||||||
return props.command.options.filter(
|
return props.command.options.filter(
|
||||||
(option) => !option.disabled && !option.id.startsWith("suggested.") && option.id !== "file.open",
|
(option) =>
|
||||||
|
!option.disabled && !option.hidden && !option.id.startsWith("suggested.") && option.id !== "file.open",
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import { Dialog } from "@opencode-ai/ui/dialog"
|
|||||||
import { List } from "@opencode-ai/ui/list"
|
import { List } from "@opencode-ai/ui/list"
|
||||||
import { Switch } from "@opencode-ai/ui/switch"
|
import { Switch } from "@opencode-ai/ui/switch"
|
||||||
import { useLanguage } from "@/context/language"
|
import { useLanguage } from "@/context/language"
|
||||||
import { mcpQueryKey } from "@/context/global-sync"
|
import { useQueryOptions } from "@/context/global-sync"
|
||||||
|
import { pathKey } from "@/utils/path-key"
|
||||||
|
|
||||||
const statusLabels = {
|
const statusLabels = {
|
||||||
connected: "mcp.status.connected",
|
connected: "mcp.status.connected",
|
||||||
failed: "mcp.status.failed",
|
failed: "mcp.status.failed",
|
||||||
needs_auth: "mcp.status.needs_auth",
|
needs_auth: "mcp.status.needs_auth",
|
||||||
|
needs_client_registration: "mcp.status.needs_client_registration",
|
||||||
disabled: "mcp.status.disabled",
|
disabled: "mcp.status.disabled",
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ export const DialogSelectMcp: Component = () => {
|
|||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const queryOptions = useQueryOptions()
|
||||||
|
|
||||||
const items = createMemo(() =>
|
const items = createMemo(() =>
|
||||||
Object.entries(sync.data.mcp ?? {})
|
Object.entries(sync.data.mcp ?? {})
|
||||||
@@ -29,10 +32,18 @@ export const DialogSelectMcp: Component = () => {
|
|||||||
|
|
||||||
const toggle = useMutation(() => ({
|
const toggle = useMutation(() => ({
|
||||||
mutationFn: async (name: string) => {
|
mutationFn: async (name: string) => {
|
||||||
if (sync.data.mcp[name]?.status === "connected") await sdk.client.mcp.disconnect({ name })
|
const status = sync.data.mcp[name]
|
||||||
else await sdk.client.mcp.connect({ name })
|
if (status?.status === "connected") {
|
||||||
|
await sdk.client.mcp.disconnect({ name })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (status?.status === "needs_auth") {
|
||||||
|
await sdk.client.mcp.auth.authenticate({ name })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await sdk.client.mcp.connect({ name })
|
||||||
},
|
},
|
||||||
onSuccess: () => queryClient.refetchQueries({ queryKey: mcpQueryKey(sync.directory) }),
|
onSuccess: () => queryClient.refetchQueries(queryOptions.mcp(pathKey(sync.directory))),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const enabledCount = createMemo(() => items().filter((i) => i.status === "connected").length)
|
const enabledCount = createMemo(() => items().filter((i) => i.status === "connected").length)
|
||||||
@@ -65,7 +76,7 @@ export const DialogSelectMcp: Component = () => {
|
|||||||
}
|
}
|
||||||
const error = () => {
|
const error = () => {
|
||||||
const s = mcpStatus()
|
const s = mcpStatus()
|
||||||
return s?.status === "failed" ? s.error : undefined
|
if (s?.status === "failed" || s?.status === "needs_client_registration") return s.error
|
||||||
}
|
}
|
||||||
const enabled = () => status() === "connected"
|
const enabled = () => status() === "connected"
|
||||||
return (
|
return (
|
||||||
@@ -76,9 +87,6 @@ export const DialogSelectMcp: Component = () => {
|
|||||||
<Show when={statusLabel()}>
|
<Show when={statusLabel()}>
|
||||||
<span class="text-11-regular text-text-weaker">{statusLabel()}</span>
|
<span class="text-11-regular text-text-weaker">{statusLabel()}</span>
|
||||||
</Show>
|
</Show>
|
||||||
<Show when={toggle.isPending && toggle.variables === i.name}>
|
|
||||||
<span class="text-11-regular text-text-weak">{language.t("common.loading.ellipsis")}</span>
|
|
||||||
</Show>
|
|
||||||
</div>
|
</div>
|
||||||
<Show when={error()}>
|
<Show when={error()}>
|
||||||
<span class="text-11-regular text-text-weaker truncate">{error()}</span>
|
<span class="text-11-regular text-text-weaker truncate">{error()}</span>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ import {
|
|||||||
} from "@/context/prompt"
|
} from "@/context/prompt"
|
||||||
import { useLayout } from "@/context/layout"
|
import { useLayout } from "@/context/layout"
|
||||||
import { useSDK } from "@/context/sdk"
|
import { useSDK } from "@/context/sdk"
|
||||||
import { useGlobalSDK } from "@/context/global-sdk"
|
|
||||||
import { useSync } from "@/context/sync"
|
import { useSync } from "@/context/sync"
|
||||||
import { useComments } from "@/context/comments"
|
import { useComments } from "@/context/comments"
|
||||||
import { Button } from "@opencode-ai/ui/button"
|
import { Button } from "@opencode-ai/ui/button"
|
||||||
@@ -56,7 +55,8 @@ import { PromptDragOverlay } from "./prompt-input/drag-overlay"
|
|||||||
import { promptPlaceholder } from "./prompt-input/placeholder"
|
import { promptPlaceholder } from "./prompt-input/placeholder"
|
||||||
import { ImagePreview } from "@opencode-ai/ui/image-preview"
|
import { ImagePreview } from "@opencode-ai/ui/image-preview"
|
||||||
import { useQueries } from "@tanstack/solid-query"
|
import { useQueries } from "@tanstack/solid-query"
|
||||||
import { loadAgentsQuery, loadProvidersQuery } from "@/context/global-sync/bootstrap"
|
import { useQueryOptions } from "@/context/global-sync"
|
||||||
|
import { pathKey } from "@/utils/path-key"
|
||||||
|
|
||||||
interface PromptInputProps {
|
interface PromptInputProps {
|
||||||
class?: string
|
class?: string
|
||||||
@@ -103,7 +103,7 @@ const NON_EMPTY_TEXT = /[^\s\u200B]/
|
|||||||
|
|
||||||
export const PromptInput: Component<PromptInputProps> = (props) => {
|
export const PromptInput: Component<PromptInputProps> = (props) => {
|
||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const globalSDK = useGlobalSDK()
|
const queryOptions = useQueryOptions()
|
||||||
|
|
||||||
const sync = useSync()
|
const sync = useSync()
|
||||||
const local = useLocal()
|
const local = useLocal()
|
||||||
@@ -240,13 +240,7 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
return paths
|
return paths
|
||||||
})
|
})
|
||||||
const info = createMemo(() => (params.id ? sync.session.get(params.id) : undefined))
|
const info = createMemo(() => (params.id ? sync.session.get(params.id) : undefined))
|
||||||
const status = createMemo(
|
const working = createMemo(() => sync.data.session_working(params.id ?? ""))
|
||||||
() =>
|
|
||||||
sync.data.session_status[params.id ?? ""] ?? {
|
|
||||||
type: "idle",
|
|
||||||
},
|
|
||||||
)
|
|
||||||
const working = createMemo(() => status()?.type !== "idle")
|
|
||||||
const imageAttachments = createMemo(() =>
|
const imageAttachments = createMemo(() =>
|
||||||
prompt.current().filter((part): part is ImageAttachmentPart => part.type === "image"),
|
prompt.current().filter((part): part is ImageAttachmentPart => part.type === "image"),
|
||||||
)
|
)
|
||||||
@@ -1256,9 +1250,9 @@ export const PromptInput: Component<PromptInputProps> = (props) => {
|
|||||||
|
|
||||||
const [agentsQuery, globalProvidersQuery, providersQuery] = useQueries(() => ({
|
const [agentsQuery, globalProvidersQuery, providersQuery] = useQueries(() => ({
|
||||||
queries: [
|
queries: [
|
||||||
loadAgentsQuery(sdk.directory, sdk.client),
|
queryOptions.agents(pathKey(sdk.directory)),
|
||||||
loadProvidersQuery(null, globalSDK.client),
|
queryOptions.providers(null),
|
||||||
loadProvidersQuery(sdk.directory, sdk.client),
|
queryOptions.providers(pathKey(sdk.directory)),
|
||||||
],
|
],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|||||||
@@ -123,11 +123,13 @@ function listFor(command: CommandContext, map: KeybindMap, palette: string) {
|
|||||||
|
|
||||||
for (const opt of command.catalog) {
|
for (const opt of command.catalog) {
|
||||||
if (opt.id.startsWith("suggested.")) continue
|
if (opt.id.startsWith("suggested.")) continue
|
||||||
|
if (opt.hidden) continue
|
||||||
out.set(opt.id, { title: opt.title, group: groupFor(opt.id) })
|
out.set(opt.id, { title: opt.title, group: groupFor(opt.id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const opt of command.options) {
|
for (const opt of command.options) {
|
||||||
if (opt.id.startsWith("suggested.")) continue
|
if (opt.id.startsWith("suggested.")) continue
|
||||||
|
if (opt.hidden) continue
|
||||||
out.set(opt.id, { title: opt.title, group: groupFor(opt.id) })
|
out.set(opt.id, { title: opt.title, group: groupFor(opt.id) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ import { useSDK } from "@/context/sdk"
|
|||||||
import { normalizeServerUrl, ServerConnection, useServer } from "@/context/server"
|
import { normalizeServerUrl, ServerConnection, useServer } from "@/context/server"
|
||||||
import { useSync } from "@/context/sync"
|
import { useSync } from "@/context/sync"
|
||||||
import { useCheckServerHealth, type ServerHealth } from "@/utils/server-health"
|
import { useCheckServerHealth, type ServerHealth } from "@/utils/server-health"
|
||||||
import { mcpQueryKey } from "@/context/global-sync"
|
import { useQueryOptions } from "@/context/global-sync"
|
||||||
|
import { pathKey } from "@/utils/path-key"
|
||||||
|
|
||||||
const pollMs = 10_000
|
const pollMs = 10_000
|
||||||
|
|
||||||
@@ -139,13 +140,22 @@ const useMcpToggleMutation = () => {
|
|||||||
const sdk = useSDK()
|
const sdk = useSDK()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
|
const queryOptions = useQueryOptions()
|
||||||
|
|
||||||
return useMutation(() => ({
|
return useMutation(() => ({
|
||||||
mutationFn: async (name: string) => {
|
mutationFn: async (name: string) => {
|
||||||
const status = sync.data.mcp[name]
|
const status = sync.data.mcp[name]
|
||||||
await (status?.status === "connected" ? sdk.client.mcp.disconnect({ name }) : sdk.client.mcp.connect({ name }))
|
if (status?.status === "connected") {
|
||||||
|
await sdk.client.mcp.disconnect({ name })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (status?.status === "needs_auth") {
|
||||||
|
await sdk.client.mcp.auth.authenticate({ name })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await sdk.client.mcp.connect({ name })
|
||||||
},
|
},
|
||||||
onSuccess: () => queryClient.refetchQueries({ queryKey: mcpQueryKey(sync.directory) }),
|
onSuccess: () => queryClient.refetchQueries(queryOptions.mcp(pathKey(sync.directory))),
|
||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
showToast({
|
showToast({
|
||||||
variant: "error",
|
variant: "error",
|
||||||
@@ -314,7 +324,7 @@ export function StatusPopoverBody(props: { shown: Accessor<boolean> }) {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="flex items-center gap-2 w-full h-8 pl-3 pr-2 py-1 rounded-md hover:bg-surface-raised-base-hover transition-colors text-left"
|
class="flex items-center gap-2 w-full min-h-8 pl-3 pr-2 py-1 rounded-md hover:bg-surface-raised-base-hover transition-colors text-left"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (toggleMcp.isPending) return
|
if (toggleMcp.isPending) return
|
||||||
toggleMcp.mutate(name)
|
toggleMcp.mutate(name)
|
||||||
@@ -331,7 +341,16 @@ export function StatusPopoverBody(props: { shown: Accessor<boolean> }) {
|
|||||||
status() === "needs_auth" || status() === "needs_client_registration",
|
status() === "needs_auth" || status() === "needs_client_registration",
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<span class="text-14-regular text-text-base truncate flex-1">{name}</span>
|
<span class="flex flex-col min-w-0 flex-1">
|
||||||
|
<span class="flex items-center gap-2 min-w-0">
|
||||||
|
<span class="text-14-regular text-text-base truncate">{name}</span>
|
||||||
|
</span>
|
||||||
|
<Show when={status() === "needs_auth"}>
|
||||||
|
<span class="text-11-regular text-text-weaker truncate">
|
||||||
|
{language.t("mcp.auth.clickToAuthenticate")}
|
||||||
|
</span>
|
||||||
|
</Show>
|
||||||
|
</span>
|
||||||
<div onClick={(event) => event.stopPropagation()}>
|
<div onClick={(event) => event.stopPropagation()}>
|
||||||
<Switch
|
<Switch
|
||||||
checked={enabled()}
|
checked={enabled()}
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ export function StatusPopover() {
|
|||||||
const sync = useSync()
|
const sync = useSync()
|
||||||
const [shown, setShown] = createSignal(false)
|
const [shown, setShown] = createSignal(false)
|
||||||
const ready = createMemo(() => server.healthy() === false || sync.data.mcp_ready)
|
const ready = createMemo(() => server.healthy() === false || sync.data.mcp_ready)
|
||||||
const healthy = createMemo(() => {
|
const mcpIssue = createMemo(() => {
|
||||||
const serverHealthy = server.healthy() === true
|
|
||||||
const mcp = Object.values(sync.data.mcp ?? {})
|
const mcp = Object.values(sync.data.mcp ?? {})
|
||||||
const issue = mcp.some((item) => item.status !== "connected" && item.status !== "disabled")
|
const failed = mcp.some((item) => item.status === "failed" || item.status === "needs_client_registration")
|
||||||
return serverHealthy && !issue
|
const warn = mcp.some((item) => item.status === "needs_auth")
|
||||||
|
if (failed) return "critical" as const
|
||||||
|
if (warn) return "warning" as const
|
||||||
})
|
})
|
||||||
|
const healthy = createMemo(() => server.healthy() === true && !mcpIssue())
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Popover
|
<Popover
|
||||||
@@ -41,7 +43,9 @@ export function StatusPopover() {
|
|||||||
classList={{
|
classList={{
|
||||||
"absolute -top-px -right-px size-1.5 rounded-full": true,
|
"absolute -top-px -right-px size-1.5 rounded-full": true,
|
||||||
"bg-icon-success-base": ready() && healthy(),
|
"bg-icon-success-base": ready() && healthy(),
|
||||||
"bg-icon-critical-base": server.healthy() === false || (ready() && !healthy()),
|
"bg-icon-warning-base": ready() && server.healthy() === true && mcpIssue() === "warning",
|
||||||
|
"bg-icon-critical-base":
|
||||||
|
server.healthy() === false || (ready() && server.healthy() === true && mcpIssue() === "critical"),
|
||||||
"bg-border-weak-base": server.healthy() === undefined || !ready(),
|
"bg-border-weak-base": server.healthy() === undefined || !ready(),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ export interface CommandOption {
|
|||||||
slash?: string
|
slash?: string
|
||||||
suggested?: boolean
|
suggested?: boolean
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
|
hidden?: boolean
|
||||||
onSelect?: (source?: "palette" | "keybind" | "slash") => void
|
onSelect?: (source?: "palette" | "keybind" | "slash") => void
|
||||||
onHighlight?: () => (() => void) | void
|
onHighlight?: () => (() => void) | void
|
||||||
}
|
}
|
||||||
@@ -93,6 +94,7 @@ export type CommandCatalogItem = {
|
|||||||
category?: string
|
category?: string
|
||||||
keybind?: KeybindConfig
|
keybind?: KeybindConfig
|
||||||
slash?: string
|
slash?: string
|
||||||
|
hidden?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CommandRegistration = {
|
export type CommandRegistration = {
|
||||||
@@ -279,13 +281,14 @@ export const { use: useCommand, provider: CommandProvider } = createSimpleContex
|
|||||||
setCatalog(
|
setCatalog(
|
||||||
registered().reduce((acc, opt) => {
|
registered().reduce((acc, opt) => {
|
||||||
const id = actionId(opt.id)
|
const id = actionId(opt.id)
|
||||||
acc[id] = {
|
if (opt.title)
|
||||||
title: opt.title,
|
acc[id] = {
|
||||||
description: opt.description,
|
title: opt.title,
|
||||||
category: opt.category,
|
description: opt.description,
|
||||||
keybind: opt.keybind,
|
category: opt.category,
|
||||||
slash: opt.slash,
|
keybind: opt.keybind,
|
||||||
}
|
slash: opt.slash,
|
||||||
|
}
|
||||||
return acc
|
return acc
|
||||||
}, {} as CommandCatalog),
|
}, {} as CommandCatalog),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,15 +3,13 @@ import { createSimpleContext } from "@opencode-ai/ui/context"
|
|||||||
import { createGlobalEmitter } from "@solid-primitives/event-bus"
|
import { createGlobalEmitter } from "@solid-primitives/event-bus"
|
||||||
import { makeEventListener } from "@solid-primitives/event-listener"
|
import { makeEventListener } from "@solid-primitives/event-listener"
|
||||||
import { batch, onCleanup, onMount } from "solid-js"
|
import { batch, onCleanup, onMount } from "solid-js"
|
||||||
import z from "zod"
|
|
||||||
import { createSdkForServer } from "@/utils/server"
|
import { createSdkForServer } from "@/utils/server"
|
||||||
import { useLanguage } from "./language"
|
import { useLanguage } from "./language"
|
||||||
import { usePlatform } from "./platform"
|
import { usePlatform } from "./platform"
|
||||||
import { useServer } from "./server"
|
import { useServer } from "./server"
|
||||||
|
|
||||||
const abortError = z.object({
|
const isAbortError = (error: unknown) =>
|
||||||
name: z.literal("AbortError"),
|
error !== null && typeof error === "object" && "name" in error && error.name === "AbortError"
|
||||||
})
|
|
||||||
|
|
||||||
export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleContext({
|
export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleContext({
|
||||||
name: "GlobalSDK",
|
name: "GlobalSDK",
|
||||||
@@ -103,7 +101,7 @@ export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleCo
|
|||||||
|
|
||||||
let streamErrorLogged = false
|
let streamErrorLogged = false
|
||||||
const wait = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))
|
const wait = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))
|
||||||
const aborted = (error: unknown) => abortError.safeParse(error).success
|
const aborted = isAbortError
|
||||||
|
|
||||||
let attempt: AbortController | undefined
|
let attempt: AbortController | undefined
|
||||||
let run: Promise<void> | undefined
|
let run: Promise<void> | undefined
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ import {
|
|||||||
bootstrapDirectory,
|
bootstrapDirectory,
|
||||||
bootstrapGlobal,
|
bootstrapGlobal,
|
||||||
clearProviderRev,
|
clearProviderRev,
|
||||||
|
loadAgentsQuery,
|
||||||
loadGlobalConfigQuery,
|
loadGlobalConfigQuery,
|
||||||
loadPathQuery,
|
loadPathQuery,
|
||||||
|
loadProjectsQuery,
|
||||||
loadProvidersQuery,
|
loadProvidersQuery,
|
||||||
} from "./global-sync/bootstrap"
|
} from "./global-sync/bootstrap"
|
||||||
import { createChildStoreManager } from "./global-sync/child-store"
|
import { createChildStoreManager } from "./global-sync/child-store"
|
||||||
@@ -33,6 +35,7 @@ import { formatServerError } from "@/utils/server-errors"
|
|||||||
import { queryOptions, useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/solid-query"
|
import { queryOptions, useMutation, useQueries, useQuery, useQueryClient } from "@tanstack/solid-query"
|
||||||
import { createRefreshQueue } from "./global-sync/queue"
|
import { createRefreshQueue } from "./global-sync/queue"
|
||||||
import { directoryKey } from "./global-sync/utils"
|
import { directoryKey } from "./global-sync/utils"
|
||||||
|
import { PathKey } from "@/utils/path-key"
|
||||||
|
|
||||||
type GlobalStore = {
|
type GlobalStore = {
|
||||||
ready: boolean
|
ready: boolean
|
||||||
@@ -48,24 +51,33 @@ type GlobalStore = {
|
|||||||
reload: undefined | "pending" | "complete"
|
reload: undefined | "pending" | "complete"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadSessionsQueryKey = (directory: string) => [directory, "loadSessions"] as const
|
|
||||||
|
|
||||||
export const mcpQueryKey = (directory: string) => [directory, "mcp"] as const
|
|
||||||
|
|
||||||
export const loadMcpQuery = (directory: string, sdk: OpencodeClient) =>
|
export const loadMcpQuery = (directory: string, sdk: OpencodeClient) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: mcpQueryKey(directory),
|
queryKey: [directory, "mcp"] as const,
|
||||||
queryFn: () => sdk.mcp.status().then((r) => r.data ?? {}),
|
queryFn: () => sdk.mcp.status().then((r) => r.data ?? {}),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const lspQueryKey = (directory: string) => [directory, "lsp"] as const
|
|
||||||
|
|
||||||
export const loadLspQuery = (directory: string, sdk: OpencodeClient) =>
|
export const loadLspQuery = (directory: string, sdk: OpencodeClient) =>
|
||||||
queryOptions({
|
queryOptions({
|
||||||
queryKey: lspQueryKey(directory),
|
queryKey: [directory, "lsp"] as const,
|
||||||
queryFn: () => sdk.lsp.status().then((r) => r.data ?? []),
|
queryFn: () => sdk.lsp.status().then((r) => r.data ?? []),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function makeQueryOptionsApi(globalSDK: () => OpencodeClient, sdkFor: (dir: PathKey) => OpencodeClient) {
|
||||||
|
return {
|
||||||
|
globalConfig: () => loadGlobalConfigQuery(globalSDK()),
|
||||||
|
projects: () => loadProjectsQuery(globalSDK()),
|
||||||
|
providers: (directory: PathKey | null) =>
|
||||||
|
loadProvidersQuery(directory, directory === null ? globalSDK() : sdkFor(directory)),
|
||||||
|
path: (directory: PathKey | null) => loadPathQuery(directory, directory === null ? globalSDK() : sdkFor(directory)),
|
||||||
|
agents: (directory: PathKey) => loadAgentsQuery(directory, sdkFor(directory)),
|
||||||
|
mcp: (directory: PathKey) => loadMcpQuery(directory, sdkFor(directory)),
|
||||||
|
lsp: (directory: PathKey) => loadLspQuery(directory, sdkFor(directory)),
|
||||||
|
sessions: (directory: PathKey) => ({ queryKey: [directory, "loadSessions"] as const }),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export type QueryOptionsApi = ReturnType<typeof makeQueryOptionsApi>
|
||||||
|
|
||||||
function createGlobalSync() {
|
function createGlobalSync() {
|
||||||
const globalSDK = useGlobalSDK()
|
const globalSDK = useGlobalSDK()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
@@ -77,12 +89,22 @@ function createGlobalSync() {
|
|||||||
const sessionLoads = new Map<string, Promise<void>>()
|
const sessionLoads = new Map<string, Promise<void>>()
|
||||||
const sessionMeta = new Map<string, { limit: number }>()
|
const sessionMeta = new Map<string, { limit: number }>()
|
||||||
|
|
||||||
|
const sdkFor = (directory: string) => {
|
||||||
|
const key = directoryKey(directory)
|
||||||
|
const cached = sdkCache.get(key)
|
||||||
|
if (cached) return cached
|
||||||
|
const sdk = globalSDK.createClient({
|
||||||
|
directory,
|
||||||
|
throwOnError: true,
|
||||||
|
})
|
||||||
|
sdkCache.set(key, sdk)
|
||||||
|
return sdk
|
||||||
|
}
|
||||||
|
|
||||||
|
const queryOptionsApi = makeQueryOptionsApi(() => globalSDK.client, sdkFor)
|
||||||
|
|
||||||
const [configQuery, providerQuery, pathQuery] = useQueries(() => ({
|
const [configQuery, providerQuery, pathQuery] = useQueries(() => ({
|
||||||
queries: [
|
queries: [queryOptionsApi.globalConfig(), queryOptionsApi.providers(null), queryOptionsApi.path(null)],
|
||||||
loadGlobalConfigQuery(globalSDK.client),
|
|
||||||
loadProvidersQuery(null, globalSDK.client),
|
|
||||||
loadPathQuery(null, globalSDK.client),
|
|
||||||
],
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const [globalStore, setGlobalStore] = createStore<GlobalStore>({
|
const [globalStore, setGlobalStore] = createStore<GlobalStore>({
|
||||||
@@ -181,18 +203,6 @@ function createGlobalSync() {
|
|||||||
bootstrapInstance,
|
bootstrapInstance,
|
||||||
})
|
})
|
||||||
|
|
||||||
const sdkFor = (directory: string) => {
|
|
||||||
const key = directoryKey(directory)
|
|
||||||
const cached = sdkCache.get(key)
|
|
||||||
if (cached) return cached
|
|
||||||
const sdk = globalSDK.createClient({
|
|
||||||
directory,
|
|
||||||
throwOnError: true,
|
|
||||||
})
|
|
||||||
sdkCache.set(key, sdk)
|
|
||||||
return sdk
|
|
||||||
}
|
|
||||||
|
|
||||||
const children = createChildStoreManager({
|
const children = createChildStoreManager({
|
||||||
owner,
|
owner,
|
||||||
isBooting: (directory) => booting.has(directory),
|
isBooting: (directory) => booting.has(directory),
|
||||||
@@ -209,7 +219,7 @@ function createGlobalSync() {
|
|||||||
clearSessionPrefetchDirectory(key)
|
clearSessionPrefetchDirectory(key)
|
||||||
},
|
},
|
||||||
translate: language.t,
|
translate: language.t,
|
||||||
getSdk: sdkFor,
|
queryOptions: queryOptionsApi,
|
||||||
global: {
|
global: {
|
||||||
provider: globalStore.provider,
|
provider: globalStore.provider,
|
||||||
},
|
},
|
||||||
@@ -239,7 +249,7 @@ function createGlobalSync() {
|
|||||||
const limit = Math.max(store.limit + SESSION_RECENT_LIMIT, SESSION_RECENT_LIMIT)
|
const limit = Math.max(store.limit + SESSION_RECENT_LIMIT, SESSION_RECENT_LIMIT)
|
||||||
const promise = queryClient
|
const promise = queryClient
|
||||||
.fetchQuery({
|
.fetchQuery({
|
||||||
queryKey: loadSessionsQueryKey(key),
|
...queryOptionsApi.sessions(key),
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
loadRootSessionsWithFallback({
|
loadRootSessionsWithFallback({
|
||||||
directory,
|
directory,
|
||||||
@@ -368,7 +378,7 @@ function createGlobalSync() {
|
|||||||
setSessionTodo,
|
setSessionTodo,
|
||||||
vcsCache: children.vcsCache.get(key),
|
vcsCache: children.vcsCache.get(key),
|
||||||
loadLsp: () => {
|
loadLsp: () => {
|
||||||
void queryClient.fetchQuery(loadLspQuery(key, sdkFor(directory)))
|
void queryClient.fetchQuery(queryOptionsApi.lsp(key))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -426,6 +436,7 @@ function createGlobalSync() {
|
|||||||
},
|
},
|
||||||
child: children.child,
|
child: children.child,
|
||||||
peek: children.peek,
|
peek: children.peek,
|
||||||
|
queryOptions: queryOptionsApi,
|
||||||
// bootstrap,
|
// bootstrap,
|
||||||
updateConfig: updateConfigMutation.mutateAsync,
|
updateConfig: updateConfigMutation.mutateAsync,
|
||||||
project: projectApi,
|
project: projectApi,
|
||||||
@@ -447,3 +458,7 @@ export function useGlobalSync() {
|
|||||||
if (!context) throw new Error("useGlobalSync must be used within GlobalSyncProvider")
|
if (!context) throw new Error("useGlobalSync must be used within GlobalSyncProvider")
|
||||||
return context
|
return context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useQueryOptions() {
|
||||||
|
return useGlobalSync().queryOptions
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ describe("createChildStoreManager", () => {
|
|||||||
onBootstrap() {},
|
onBootstrap() {},
|
||||||
onDispose() {},
|
onDispose() {},
|
||||||
translate: (key) => key,
|
translate: (key) => key,
|
||||||
getSdk: () => null!,
|
queryOptions: {} as any,
|
||||||
global: { provider: null! },
|
global: { provider: null! },
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createRoot, getOwner, onCleanup, runWithOwner, type Owner } from "solid-js"
|
import { createRoot, getOwner, onCleanup, runWithOwner, type Owner } from "solid-js"
|
||||||
import { createStore, type SetStoreFunction, type Store } from "solid-js/store"
|
import { createStore, type SetStoreFunction, type Store } from "solid-js/store"
|
||||||
import { Persist, persisted } from "@/utils/persist"
|
import { Persist, persisted } from "@/utils/persist"
|
||||||
import type { OpencodeClient, ProviderListResponse, VcsInfo } from "@opencode-ai/sdk/v2/client"
|
import type { ProviderListResponse, VcsInfo } from "@opencode-ai/sdk/v2/client"
|
||||||
import {
|
import {
|
||||||
DIR_IDLE_TTL_MS,
|
DIR_IDLE_TTL_MS,
|
||||||
MAX_DIR_STORES,
|
MAX_DIR_STORES,
|
||||||
@@ -15,8 +15,7 @@ import {
|
|||||||
} from "./types"
|
} from "./types"
|
||||||
import { canDisposeDirectory, pickDirectoriesToEvict } from "./eviction"
|
import { canDisposeDirectory, pickDirectoriesToEvict } from "./eviction"
|
||||||
import { useQueries } from "@tanstack/solid-query"
|
import { useQueries } from "@tanstack/solid-query"
|
||||||
import { loadPathQuery, loadProvidersQuery } from "./bootstrap"
|
import { QueryOptionsApi } from "../global-sync"
|
||||||
import { loadLspQuery, loadMcpQuery } from "../global-sync"
|
|
||||||
import { directoryKey, type DirectoryKey } from "./utils"
|
import { directoryKey, type DirectoryKey } from "./utils"
|
||||||
|
|
||||||
export function createChildStoreManager(input: {
|
export function createChildStoreManager(input: {
|
||||||
@@ -26,7 +25,7 @@ export function createChildStoreManager(input: {
|
|||||||
onBootstrap: (directory: string) => void
|
onBootstrap: (directory: string) => void
|
||||||
onDispose: (directory: string) => void
|
onDispose: (directory: string) => void
|
||||||
translate: (key: string, vars?: Record<string, string | number>) => string
|
translate: (key: string, vars?: Record<string, string | number>) => string
|
||||||
getSdk: (directory: string) => OpencodeClient
|
queryOptions: QueryOptionsApi
|
||||||
global: {
|
global: {
|
||||||
provider: ProviderListResponse
|
provider: ProviderListResponse
|
||||||
}
|
}
|
||||||
@@ -171,17 +170,15 @@ export function createChildStoreManager(input: {
|
|||||||
|
|
||||||
const init = () =>
|
const init = () =>
|
||||||
createRoot((dispose) => {
|
createRoot((dispose) => {
|
||||||
const sdk = input.getSdk(directory)
|
|
||||||
|
|
||||||
const initialMeta = meta[0].value
|
const initialMeta = meta[0].value
|
||||||
const initialIcon = icon[0].value
|
const initialIcon = icon[0].value
|
||||||
|
|
||||||
const [pathQuery, mcpQuery, lspQuery, providerQuery] = useQueries(() => ({
|
const [pathQuery, mcpQuery, lspQuery, providerQuery] = useQueries(() => ({
|
||||||
queries: [
|
queries: [
|
||||||
loadPathQuery(key, sdk),
|
input.queryOptions.path(key),
|
||||||
loadMcpQuery(key, sdk),
|
input.queryOptions.mcp(key),
|
||||||
loadLspQuery(key, sdk),
|
input.queryOptions.lsp(key),
|
||||||
loadProvidersQuery(key, sdk),
|
input.queryOptions.providers(key),
|
||||||
],
|
],
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@@ -211,6 +208,10 @@ export function createChildStoreManager(input: {
|
|||||||
session: [],
|
session: [],
|
||||||
sessionTotal: 0,
|
sessionTotal: 0,
|
||||||
session_status: {},
|
session_status: {},
|
||||||
|
session_working(id: string) {
|
||||||
|
const type = this.session_status[id]?.type
|
||||||
|
return (type ?? "idle") !== "idle"
|
||||||
|
},
|
||||||
session_diff: {},
|
session_diff: {},
|
||||||
todo: {},
|
todo: {},
|
||||||
permission: {},
|
permission: {},
|
||||||
@@ -231,6 +232,7 @@ export function createChildStoreManager(input: {
|
|||||||
limit: 5,
|
limit: 5,
|
||||||
message: {},
|
message: {},
|
||||||
part: {},
|
part: {},
|
||||||
|
part_text_accum_delta: {},
|
||||||
})
|
})
|
||||||
children[key] = child
|
children[key] = child
|
||||||
disposers.set(key, dispose)
|
disposers.set(key, dispose)
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ const baseState = (input: Partial<State> = {}) =>
|
|||||||
limit: 10,
|
limit: 10,
|
||||||
message: {},
|
message: {},
|
||||||
part: {},
|
part: {},
|
||||||
|
part_text_accum_delta: {},
|
||||||
...input,
|
...input,
|
||||||
}) as State
|
}) as State
|
||||||
|
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ export function applyDirectoryEvent(input: {
|
|||||||
const info = (event.properties as { info: Session }).info
|
const info = (event.properties as { info: Session }).info
|
||||||
const result = Binary.search(input.store.session, info.id, (s) => s.id)
|
const result = Binary.search(input.store.session, info.id, (s) => s.id)
|
||||||
if (info.time.archived) {
|
if (info.time.archived) {
|
||||||
|
if (input.store.session[result.index]!.time.archived === info.time.archived) break
|
||||||
if (result.found) {
|
if (result.found) {
|
||||||
input.setStore(
|
input.setStore(
|
||||||
"session",
|
"session",
|
||||||
@@ -211,6 +212,12 @@ export function applyDirectoryEvent(input: {
|
|||||||
const result = Binary.search(messages, props.messageID, (m) => m.id)
|
const result = Binary.search(messages, props.messageID, (m) => m.id)
|
||||||
if (result.found) messages.splice(result.index, 1)
|
if (result.found) messages.splice(result.index, 1)
|
||||||
}
|
}
|
||||||
|
const parts = draft.part[props.messageID]
|
||||||
|
if (parts) {
|
||||||
|
for (const part of parts) {
|
||||||
|
delete draft.part_text_accum_delta[part.id]
|
||||||
|
}
|
||||||
|
}
|
||||||
delete draft.part[props.messageID]
|
delete draft.part[props.messageID]
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
@@ -219,6 +226,11 @@ export function applyDirectoryEvent(input: {
|
|||||||
case "message.part.updated": {
|
case "message.part.updated": {
|
||||||
const part = (event.properties as { part: Part }).part
|
const part = (event.properties as { part: Part }).part
|
||||||
if (SKIP_PARTS.has(part.type)) break
|
if (SKIP_PARTS.has(part.type)) break
|
||||||
|
input.setStore(
|
||||||
|
produce((draft) => {
|
||||||
|
delete draft.part_text_accum_delta[part.id]
|
||||||
|
}),
|
||||||
|
)
|
||||||
const parts = input.store.part[part.messageID]
|
const parts = input.store.part[part.messageID]
|
||||||
if (!parts) {
|
if (!parts) {
|
||||||
input.setStore("part", part.messageID, [part])
|
input.setStore("part", part.messageID, [part])
|
||||||
@@ -240,6 +252,11 @@ export function applyDirectoryEvent(input: {
|
|||||||
}
|
}
|
||||||
case "message.part.removed": {
|
case "message.part.removed": {
|
||||||
const props = event.properties as { messageID: string; partID: string }
|
const props = event.properties as { messageID: string; partID: string }
|
||||||
|
input.setStore(
|
||||||
|
produce((draft) => {
|
||||||
|
delete draft.part_text_accum_delta[props.partID]
|
||||||
|
}),
|
||||||
|
)
|
||||||
const parts = input.store.part[props.messageID]
|
const parts = input.store.part[props.messageID]
|
||||||
if (!parts) break
|
if (!parts) break
|
||||||
const result = Binary.search(parts, props.partID, (p) => p.id)
|
const result = Binary.search(parts, props.partID, (p) => p.id)
|
||||||
@@ -263,6 +280,7 @@ export function applyDirectoryEvent(input: {
|
|||||||
if (!parts) break
|
if (!parts) break
|
||||||
const result = Binary.search(parts, props.partID, (p) => p.id)
|
const result = Binary.search(parts, props.partID, (p) => p.id)
|
||||||
if (!result.found) break
|
if (!result.found) break
|
||||||
|
input.setStore("part_text_accum_delta", props.partID, (existing) => (existing ?? "") + props.delta)
|
||||||
input.setStore(
|
input.setStore(
|
||||||
"part",
|
"part",
|
||||||
props.messageID,
|
props.messageID,
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ describe("app session cache", () => {
|
|||||||
part: Record<string, Part[] | undefined>
|
part: Record<string, Part[] | undefined>
|
||||||
permission: Record<string, PermissionRequest[] | undefined>
|
permission: Record<string, PermissionRequest[] | undefined>
|
||||||
question: Record<string, QuestionRequest[] | undefined>
|
question: Record<string, QuestionRequest[] | undefined>
|
||||||
|
part_text_accum_delta: Record<string, string | undefined>
|
||||||
} = {
|
} = {
|
||||||
session_status: { ses_1: { type: "busy" } as SessionStatus },
|
session_status: { ses_1: { type: "busy" } as SessionStatus },
|
||||||
session_diff: { ses_1: [] },
|
session_diff: { ses_1: [] },
|
||||||
@@ -47,12 +48,14 @@ describe("app session cache", () => {
|
|||||||
part: { msg_1: [part("prt_1", "ses_1", "msg_1")] },
|
part: { msg_1: [part("prt_1", "ses_1", "msg_1")] },
|
||||||
permission: { ses_1: [] as PermissionRequest[] },
|
permission: { ses_1: [] as PermissionRequest[] },
|
||||||
question: { ses_1: [] as QuestionRequest[] },
|
question: { ses_1: [] as QuestionRequest[] },
|
||||||
|
part_text_accum_delta: { prt_1: "streamed text" },
|
||||||
}
|
}
|
||||||
|
|
||||||
dropSessionCaches(store, ["ses_1"])
|
dropSessionCaches(store, ["ses_1"])
|
||||||
|
|
||||||
expect(store.message.ses_1).toBeUndefined()
|
expect(store.message.ses_1).toBeUndefined()
|
||||||
expect(store.part.msg_1).toBeUndefined()
|
expect(store.part.msg_1).toBeUndefined()
|
||||||
|
expect(store.part_text_accum_delta.prt_1).toBeUndefined()
|
||||||
expect(store.todo.ses_1).toBeUndefined()
|
expect(store.todo.ses_1).toBeUndefined()
|
||||||
expect(store.session_diff.ses_1).toBeUndefined()
|
expect(store.session_diff.ses_1).toBeUndefined()
|
||||||
expect(store.session_status.ses_1).toBeUndefined()
|
expect(store.session_status.ses_1).toBeUndefined()
|
||||||
@@ -70,6 +73,7 @@ describe("app session cache", () => {
|
|||||||
part: Record<string, Part[] | undefined>
|
part: Record<string, Part[] | undefined>
|
||||||
permission: Record<string, PermissionRequest[] | undefined>
|
permission: Record<string, PermissionRequest[] | undefined>
|
||||||
question: Record<string, QuestionRequest[] | undefined>
|
question: Record<string, QuestionRequest[] | undefined>
|
||||||
|
part_text_accum_delta: Record<string, string | undefined>
|
||||||
} = {
|
} = {
|
||||||
session_status: {},
|
session_status: {},
|
||||||
session_diff: {},
|
session_diff: {},
|
||||||
@@ -78,6 +82,7 @@ describe("app session cache", () => {
|
|||||||
part: { [m.id]: [part("prt_1", "ses_1", m.id)] },
|
part: { [m.id]: [part("prt_1", "ses_1", m.id)] },
|
||||||
permission: {},
|
permission: {},
|
||||||
question: {},
|
question: {},
|
||||||
|
part_text_accum_delta: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
dropSessionCaches(store, ["ses_1"])
|
dropSessionCaches(store, ["ses_1"])
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type SessionCache = {
|
|||||||
part: Record<string, Part[] | undefined>
|
part: Record<string, Part[] | undefined>
|
||||||
permission: Record<string, PermissionRequest[] | undefined>
|
permission: Record<string, PermissionRequest[] | undefined>
|
||||||
question: Record<string, QuestionRequest[] | undefined>
|
question: Record<string, QuestionRequest[] | undefined>
|
||||||
|
part_text_accum_delta: Record<string, string | undefined>
|
||||||
}
|
}
|
||||||
|
|
||||||
export function dropSessionCaches(store: SessionCache, sessionIDs: Iterable<string>) {
|
export function dropSessionCaches(store: SessionCache, sessionIDs: Iterable<string>) {
|
||||||
@@ -27,6 +28,9 @@ export function dropSessionCaches(store: SessionCache, sessionIDs: Iterable<stri
|
|||||||
for (const key of Object.keys(store.part)) {
|
for (const key of Object.keys(store.part)) {
|
||||||
const parts = store.part[key]
|
const parts = store.part[key]
|
||||||
if (!parts?.some((part) => stale.has(part?.sessionID ?? ""))) continue
|
if (!parts?.some((part) => stale.has(part?.sessionID ?? ""))) continue
|
||||||
|
for (const part of parts) {
|
||||||
|
delete store.part_text_accum_delta[part.id]
|
||||||
|
}
|
||||||
delete store.part[key]
|
delete store.part[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ export type State = {
|
|||||||
session_status: {
|
session_status: {
|
||||||
[sessionID: string]: SessionStatus
|
[sessionID: string]: SessionStatus
|
||||||
}
|
}
|
||||||
|
session_working(id: string): boolean
|
||||||
session_diff: {
|
session_diff: {
|
||||||
[sessionID: string]: SnapshotFileDiff[]
|
[sessionID: string]: SnapshotFileDiff[]
|
||||||
}
|
}
|
||||||
@@ -72,6 +73,9 @@ export type State = {
|
|||||||
part: {
|
part: {
|
||||||
[messageID: string]: Part[]
|
[messageID: string]: Part[]
|
||||||
}
|
}
|
||||||
|
part_text_accum_delta: {
|
||||||
|
[partID: string]: string
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type VcsCache = {
|
export type VcsCache = {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ type SessionView = {
|
|||||||
reviewOpen?: string[]
|
reviewOpen?: string[]
|
||||||
pendingMessage?: string
|
pendingMessage?: string
|
||||||
pendingMessageAt?: number
|
pendingMessageAt?: number
|
||||||
|
todoCollapsed?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type TabHandoff = {
|
type TabHandoff = {
|
||||||
@@ -759,6 +760,18 @@ export const { use: useLayout, provider: LayoutProvider } = createSimpleContext(
|
|||||||
setScroll(tab: string, pos: SessionScroll) {
|
setScroll(tab: string, pos: SessionScroll) {
|
||||||
scroll.setScroll(key(), tab, pos)
|
scroll.setScroll(key(), tab, pos)
|
||||||
},
|
},
|
||||||
|
todoCollapsed: {
|
||||||
|
get: () => s().todoCollapsed ?? false,
|
||||||
|
set(collapsed: boolean) {
|
||||||
|
const session = key()
|
||||||
|
const current = store.sessionView[session]
|
||||||
|
if (!current) {
|
||||||
|
setStore("sessionView", session, { scroll: {}, todoCollapsed: collapsed })
|
||||||
|
} else {
|
||||||
|
setStore("sessionView", session, "todoCollapsed", collapsed)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
terminal: {
|
terminal: {
|
||||||
opened: terminalOpened,
|
opened: terminalOpened,
|
||||||
open() {
|
open() {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ const migrate = (value: unknown) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const clone = (value: State | undefined) => {
|
const clone = (value: State | undefined) => {
|
||||||
if (!value) return undefined
|
if (!value) return
|
||||||
return {
|
return {
|
||||||
...value,
|
...value,
|
||||||
model: value.model ? { ...value.model } : undefined,
|
model: value.model ? { ...value.model } : undefined,
|
||||||
@@ -104,7 +104,7 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
|
|
||||||
const pickAgent = (name: string | undefined) => {
|
const pickAgent = (name: string | undefined) => {
|
||||||
const items = list()
|
const items = list()
|
||||||
if (items.length === 0) return undefined
|
if (items.length === 0) return
|
||||||
return items.find((item) => item.name === name) ?? items[0]
|
return items.find((item) => item.name === name) ?? items[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,14 +227,14 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
() => agent.current()?.model,
|
() => agent.current()?.model,
|
||||||
fallback,
|
fallback,
|
||||||
)
|
)
|
||||||
if (!item) return undefined
|
if (!item) return
|
||||||
return models.find(item)
|
return models.find(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
const configured = () => {
|
const configured = () => {
|
||||||
const item = agent.current()
|
const item = agent.current()
|
||||||
const model = current()
|
const model = current()
|
||||||
if (!item || !model) return undefined
|
if (!item || !model) return
|
||||||
return getConfiguredAgentVariant({
|
return getConfiguredAgentVariant({
|
||||||
agent: { model: item.model, variant: item.variant },
|
agent: { model: item.model, variant: item.variant },
|
||||||
model: { providerID: model.provider.id, modelID: model.id, variants: model.variants },
|
model: { providerID: model.provider.id, modelID: model.id, variants: model.variants },
|
||||||
@@ -314,11 +314,16 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
configured,
|
configured,
|
||||||
selected,
|
selected,
|
||||||
current() {
|
current() {
|
||||||
return resolveModelVariant({
|
const resolved = resolveModelVariant({
|
||||||
variants: this.list(),
|
variants: this.list(),
|
||||||
selected: this.selected(),
|
selected: this.selected(),
|
||||||
configured: this.configured(),
|
configured: this.configured(),
|
||||||
})
|
})
|
||||||
|
if (resolved) return resolved
|
||||||
|
const model = current()
|
||||||
|
if (!model) return
|
||||||
|
const saved = models.variant.get({ providerID: model.provider.id, modelID: model.id })
|
||||||
|
if (saved && this.list().includes(saved)) return saved
|
||||||
},
|
},
|
||||||
list() {
|
list() {
|
||||||
const item = current()
|
const item = current()
|
||||||
@@ -335,6 +340,9 @@ export const { use: useLocal, provider: LocalProvider } = createSimpleContext({
|
|||||||
variant: value ?? null,
|
variant: value ?? null,
|
||||||
})
|
})
|
||||||
write({ variant: value ?? null })
|
write({ variant: value ?? null })
|
||||||
|
if (model) {
|
||||||
|
models.variant.set({ providerID: model.provider.id, modelID: model.id }, value ?? undefined)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
cycle() {
|
cycle() {
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "متصل",
|
"mcp.status.connected": "متصل",
|
||||||
"mcp.status.failed": "فشل",
|
"mcp.status.failed": "فشل",
|
||||||
"mcp.status.needs_auth": "يحتاج إلى مصادقة",
|
"mcp.status.needs_auth": "يحتاج إلى مصادقة",
|
||||||
|
"mcp.auth.clickToAuthenticate": "انقر للمصادقة",
|
||||||
"mcp.status.disabled": "معطل",
|
"mcp.status.disabled": "معطل",
|
||||||
"dialog.fork.empty": "لا توجد رسائل للتفرع منها",
|
"dialog.fork.empty": "لا توجد رسائل للتفرع منها",
|
||||||
"dialog.directory.search.placeholder": "البحث في المجلدات",
|
"dialog.directory.search.placeholder": "البحث في المجلدات",
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "conectado",
|
"mcp.status.connected": "conectado",
|
||||||
"mcp.status.failed": "falhou",
|
"mcp.status.failed": "falhou",
|
||||||
"mcp.status.needs_auth": "precisa de autenticação",
|
"mcp.status.needs_auth": "precisa de autenticação",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Clique para autenticar",
|
||||||
"mcp.status.disabled": "desabilitado",
|
"mcp.status.disabled": "desabilitado",
|
||||||
"dialog.fork.empty": "Nenhuma mensagem para bifurcar",
|
"dialog.fork.empty": "Nenhuma mensagem para bifurcar",
|
||||||
"dialog.directory.search.placeholder": "Buscar pastas",
|
"dialog.directory.search.placeholder": "Buscar pastas",
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "povezano",
|
"mcp.status.connected": "povezano",
|
||||||
"mcp.status.failed": "neuspjelo",
|
"mcp.status.failed": "neuspjelo",
|
||||||
"mcp.status.needs_auth": "potrebna autentifikacija",
|
"mcp.status.needs_auth": "potrebna autentifikacija",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Kliknite za autentifikaciju",
|
||||||
"mcp.status.disabled": "onemogućeno",
|
"mcp.status.disabled": "onemogućeno",
|
||||||
|
|
||||||
"dialog.fork.empty": "Nema poruka za fork",
|
"dialog.fork.empty": "Nema poruka za fork",
|
||||||
|
|||||||
@@ -298,6 +298,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "forbundet",
|
"mcp.status.connected": "forbundet",
|
||||||
"mcp.status.failed": "mislykkedes",
|
"mcp.status.failed": "mislykkedes",
|
||||||
"mcp.status.needs_auth": "kræver godkendelse",
|
"mcp.status.needs_auth": "kræver godkendelse",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Klik for at godkende",
|
||||||
"mcp.status.disabled": "deaktiveret",
|
"mcp.status.disabled": "deaktiveret",
|
||||||
|
|
||||||
"dialog.fork.empty": "Ingen beskeder at forgrene fra",
|
"dialog.fork.empty": "Ingen beskeder at forgrene fra",
|
||||||
|
|||||||
@@ -282,6 +282,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "verbunden",
|
"mcp.status.connected": "verbunden",
|
||||||
"mcp.status.failed": "fehlgeschlagen",
|
"mcp.status.failed": "fehlgeschlagen",
|
||||||
"mcp.status.needs_auth": "benötigt Authentifizierung",
|
"mcp.status.needs_auth": "benötigt Authentifizierung",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Zum Authentifizieren klicken",
|
||||||
"mcp.status.disabled": "deaktiviert",
|
"mcp.status.disabled": "deaktiviert",
|
||||||
"dialog.fork.empty": "Keine Nachrichten zum Abzweigen vorhanden",
|
"dialog.fork.empty": "Keine Nachrichten zum Abzweigen vorhanden",
|
||||||
"dialog.directory.search.placeholder": "Ordner durchsuchen",
|
"dialog.directory.search.placeholder": "Ordner durchsuchen",
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export const dict = {
|
|||||||
"command.project.open": "Open project",
|
"command.project.open": "Open project",
|
||||||
"command.project.previous": "Previous project",
|
"command.project.previous": "Previous project",
|
||||||
"command.project.next": "Next project",
|
"command.project.next": "Next project",
|
||||||
|
"command.project.index": "Switch to project {{index}}",
|
||||||
"command.provider.connect": "Connect provider",
|
"command.provider.connect": "Connect provider",
|
||||||
"command.server.switch": "Switch server",
|
"command.server.switch": "Switch server",
|
||||||
"command.settings.open": "Open settings",
|
"command.settings.open": "Open settings",
|
||||||
@@ -305,6 +306,7 @@ export const dict = {
|
|||||||
"mcp.status.failed": "failed",
|
"mcp.status.failed": "failed",
|
||||||
"mcp.status.needs_auth": "needs auth",
|
"mcp.status.needs_auth": "needs auth",
|
||||||
"mcp.status.disabled": "disabled",
|
"mcp.status.disabled": "disabled",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Click to authenticate",
|
||||||
|
|
||||||
"dialog.fork.empty": "No messages to fork from",
|
"dialog.fork.empty": "No messages to fork from",
|
||||||
|
|
||||||
@@ -901,7 +903,7 @@ export const dict = {
|
|||||||
"settings.permissions.tool.read.title": "Read",
|
"settings.permissions.tool.read.title": "Read",
|
||||||
"settings.permissions.tool.read.description": "Reading a file (matches the file path)",
|
"settings.permissions.tool.read.description": "Reading a file (matches the file path)",
|
||||||
"settings.permissions.tool.edit.title": "Edit",
|
"settings.permissions.tool.edit.title": "Edit",
|
||||||
"settings.permissions.tool.edit.description": "Modify files, including edits, writes, patches, and multi-edits",
|
"settings.permissions.tool.edit.description": "Modify files, including edits, writes, and patches",
|
||||||
"settings.permissions.tool.glob.title": "Glob",
|
"settings.permissions.tool.glob.title": "Glob",
|
||||||
"settings.permissions.tool.glob.description": "Match files using glob patterns",
|
"settings.permissions.tool.glob.description": "Match files using glob patterns",
|
||||||
"settings.permissions.tool.grep.title": "Grep",
|
"settings.permissions.tool.grep.title": "Grep",
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "conectado",
|
"mcp.status.connected": "conectado",
|
||||||
"mcp.status.failed": "fallido",
|
"mcp.status.failed": "fallido",
|
||||||
"mcp.status.needs_auth": "necesita auth",
|
"mcp.status.needs_auth": "necesita auth",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Haz clic para autenticar",
|
||||||
"mcp.status.disabled": "deshabilitado",
|
"mcp.status.disabled": "deshabilitado",
|
||||||
|
|
||||||
"dialog.fork.empty": "No hay mensajes desde donde bifurcar",
|
"dialog.fork.empty": "No hay mensajes desde donde bifurcar",
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "connecté",
|
"mcp.status.connected": "connecté",
|
||||||
"mcp.status.failed": "échoué",
|
"mcp.status.failed": "échoué",
|
||||||
"mcp.status.needs_auth": "nécessite auth",
|
"mcp.status.needs_auth": "nécessite auth",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Cliquez pour vous authentifier",
|
||||||
"mcp.status.disabled": "désactivé",
|
"mcp.status.disabled": "désactivé",
|
||||||
"dialog.fork.empty": "Aucun message à partir duquel bifurquer",
|
"dialog.fork.empty": "Aucun message à partir duquel bifurquer",
|
||||||
"dialog.directory.search.placeholder": "Rechercher des dossiers",
|
"dialog.directory.search.placeholder": "Rechercher des dossiers",
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "接続済み",
|
"mcp.status.connected": "接続済み",
|
||||||
"mcp.status.failed": "失敗",
|
"mcp.status.failed": "失敗",
|
||||||
"mcp.status.needs_auth": "認証が必要",
|
"mcp.status.needs_auth": "認証が必要",
|
||||||
|
"mcp.auth.clickToAuthenticate": "クリックして認証",
|
||||||
"mcp.status.disabled": "無効",
|
"mcp.status.disabled": "無効",
|
||||||
"dialog.fork.empty": "フォーク元のメッセージがありません",
|
"dialog.fork.empty": "フォーク元のメッセージがありません",
|
||||||
"dialog.directory.search.placeholder": "フォルダを検索",
|
"dialog.directory.search.placeholder": "フォルダを検索",
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "연결됨",
|
"mcp.status.connected": "연결됨",
|
||||||
"mcp.status.failed": "실패",
|
"mcp.status.failed": "실패",
|
||||||
"mcp.status.needs_auth": "인증 필요",
|
"mcp.status.needs_auth": "인증 필요",
|
||||||
|
"mcp.auth.clickToAuthenticate": "클릭하여 인증",
|
||||||
"mcp.status.disabled": "비활성화됨",
|
"mcp.status.disabled": "비활성화됨",
|
||||||
"dialog.fork.empty": "분기할 메시지 없음",
|
"dialog.fork.empty": "분기할 메시지 없음",
|
||||||
"dialog.directory.search.placeholder": "폴더 검색",
|
"dialog.directory.search.placeholder": "폴더 검색",
|
||||||
|
|||||||
@@ -302,6 +302,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "tilkoblet",
|
"mcp.status.connected": "tilkoblet",
|
||||||
"mcp.status.failed": "mislyktes",
|
"mcp.status.failed": "mislyktes",
|
||||||
"mcp.status.needs_auth": "trenger autentisering",
|
"mcp.status.needs_auth": "trenger autentisering",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Klikk for å autentisere",
|
||||||
"mcp.status.disabled": "deaktivert",
|
"mcp.status.disabled": "deaktivert",
|
||||||
|
|
||||||
"dialog.fork.empty": "Ingen meldinger å forgrene fra",
|
"dialog.fork.empty": "Ingen meldinger å forgrene fra",
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "połączono",
|
"mcp.status.connected": "połączono",
|
||||||
"mcp.status.failed": "niepowodzenie",
|
"mcp.status.failed": "niepowodzenie",
|
||||||
"mcp.status.needs_auth": "wymaga autoryzacji",
|
"mcp.status.needs_auth": "wymaga autoryzacji",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Kliknij, aby się uwierzytelnić",
|
||||||
"mcp.status.disabled": "wyłączone",
|
"mcp.status.disabled": "wyłączone",
|
||||||
"dialog.fork.empty": "Brak wiadomości do rozwidlenia",
|
"dialog.fork.empty": "Brak wiadomości do rozwidlenia",
|
||||||
"dialog.directory.search.placeholder": "Szukaj folderów",
|
"dialog.directory.search.placeholder": "Szukaj folderów",
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "подключено",
|
"mcp.status.connected": "подключено",
|
||||||
"mcp.status.failed": "ошибка",
|
"mcp.status.failed": "ошибка",
|
||||||
"mcp.status.needs_auth": "требуется авторизация",
|
"mcp.status.needs_auth": "требуется авторизация",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Нажмите, чтобы авторизоваться",
|
||||||
"mcp.status.disabled": "отключено",
|
"mcp.status.disabled": "отключено",
|
||||||
|
|
||||||
"dialog.fork.empty": "Нет сообщений для ответвления",
|
"dialog.fork.empty": "Нет сообщений для ответвления",
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "เชื่อมต่อแล้ว",
|
"mcp.status.connected": "เชื่อมต่อแล้ว",
|
||||||
"mcp.status.failed": "ล้มเหลว",
|
"mcp.status.failed": "ล้มเหลว",
|
||||||
"mcp.status.needs_auth": "ต้องการการตรวจสอบสิทธิ์",
|
"mcp.status.needs_auth": "ต้องการการตรวจสอบสิทธิ์",
|
||||||
|
"mcp.auth.clickToAuthenticate": "คลิกเพื่อยืนยันตัวตน",
|
||||||
"mcp.status.disabled": "ปิดใช้งาน",
|
"mcp.status.disabled": "ปิดใช้งาน",
|
||||||
|
|
||||||
"dialog.fork.empty": "ไม่มีข้อความให้แตกแขนง",
|
"dialog.fork.empty": "ไม่มีข้อความให้แตกแขนง",
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "bağlı",
|
"mcp.status.connected": "bağlı",
|
||||||
"mcp.status.failed": "başarısız",
|
"mcp.status.failed": "başarısız",
|
||||||
"mcp.status.needs_auth": "kimlik doğrulama gerekli",
|
"mcp.status.needs_auth": "kimlik doğrulama gerekli",
|
||||||
|
"mcp.auth.clickToAuthenticate": "Kimlik doğrulamak için tıklayın",
|
||||||
"mcp.status.disabled": "devre dışı",
|
"mcp.status.disabled": "devre dışı",
|
||||||
|
|
||||||
"dialog.fork.empty": "Dallandırılacak mesaj yok",
|
"dialog.fork.empty": "Dallandırılacak mesaj yok",
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "已连接",
|
"mcp.status.connected": "已连接",
|
||||||
"mcp.status.failed": "失败",
|
"mcp.status.failed": "失败",
|
||||||
"mcp.status.needs_auth": "需要授权",
|
"mcp.status.needs_auth": "需要授权",
|
||||||
|
"mcp.auth.clickToAuthenticate": "点击进行授权",
|
||||||
"mcp.status.disabled": "已禁用",
|
"mcp.status.disabled": "已禁用",
|
||||||
|
|
||||||
"dialog.fork.empty": "没有可用于分叉的消息",
|
"dialog.fork.empty": "没有可用于分叉的消息",
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ export const dict = {
|
|||||||
"mcp.status.connected": "已連線",
|
"mcp.status.connected": "已連線",
|
||||||
"mcp.status.failed": "失敗",
|
"mcp.status.failed": "失敗",
|
||||||
"mcp.status.needs_auth": "需要授權",
|
"mcp.status.needs_auth": "需要授權",
|
||||||
|
"mcp.auth.clickToAuthenticate": "點擊以進行授權",
|
||||||
"mcp.status.disabled": "已停用",
|
"mcp.status.disabled": "已停用",
|
||||||
|
|
||||||
"dialog.fork.empty": "沒有可用於分支的訊息",
|
"dialog.fork.empty": "沒有可用於分支的訊息",
|
||||||
|
|||||||
@@ -960,6 +960,15 @@ export default function Layout(props: ParentProps) {
|
|||||||
void openProject(target.worktree)
|
void openProject(target.worktree)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function navigateToProjectIndex(index: number) {
|
||||||
|
const projects = layout.projects.list()
|
||||||
|
const target = projects[index]
|
||||||
|
if (!target) return
|
||||||
|
|
||||||
|
globalSync.child(target.worktree)
|
||||||
|
void openProject(target.worktree)
|
||||||
|
}
|
||||||
|
|
||||||
function navigateSessionByUnseen(offset: number) {
|
function navigateSessionByUnseen(offset: number) {
|
||||||
const sessions = currentSessions()
|
const sessions = currentSessions()
|
||||||
if (sessions.length === 0) return
|
if (sessions.length === 0) return
|
||||||
@@ -1040,6 +1049,19 @@ export default function Layout(props: ParentProps) {
|
|||||||
keybind: "mod+alt+arrowdown",
|
keybind: "mod+alt+arrowdown",
|
||||||
onSelect: () => navigateProjectByOffset(1),
|
onSelect: () => navigateProjectByOffset(1),
|
||||||
},
|
},
|
||||||
|
...Array.from({ length: 9 }, (_, i) => {
|
||||||
|
const index = i
|
||||||
|
const number = index + 1
|
||||||
|
return {
|
||||||
|
id: `project.${number}`,
|
||||||
|
category: language.t("command.category.project"),
|
||||||
|
title: `Open Project {number}`,
|
||||||
|
keybind: `mod+${number}`,
|
||||||
|
disabled: layout.projects.list().length <= index,
|
||||||
|
hidden: true,
|
||||||
|
onSelect: () => navigateToProjectIndex(index),
|
||||||
|
}
|
||||||
|
}),
|
||||||
{
|
{
|
||||||
id: "provider.connect",
|
id: "provider.connect",
|
||||||
title: language.t("command.provider.connect"),
|
title: language.t("command.provider.connect"),
|
||||||
@@ -1409,19 +1431,20 @@ export default function Layout(props: ParentProps) {
|
|||||||
const index = list.findIndex((x) => pathKey(x.worktree) === key)
|
const index = list.findIndex((x) => pathKey(x.worktree) === key)
|
||||||
const active = pathKey(currentProject()?.worktree ?? "") === key
|
const active = pathKey(currentProject()?.worktree ?? "") === key
|
||||||
if (index === -1) return
|
if (index === -1) return
|
||||||
const next = list[index + 1]
|
|
||||||
|
|
||||||
if (!active) {
|
if (!active) {
|
||||||
layout.projects.close(directory)
|
layout.projects.close(directory)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!next) {
|
if (list.length === 1) {
|
||||||
layout.projects.close(directory)
|
layout.projects.close(directory)
|
||||||
navigate("/")
|
navigate("/")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const next = list[index + 1] ?? list[index - 1]
|
||||||
|
|
||||||
navigateWithSidebarReset(`/${base64Encode(next.worktree)}/session`)
|
navigateWithSidebarReset(`/${base64Encode(next.worktree)}/session`)
|
||||||
layout.projects.close(directory)
|
layout.projects.close(directory)
|
||||||
queueMicrotask(() => {
|
queueMicrotask(() => {
|
||||||
@@ -1934,7 +1957,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
|
|
||||||
if (!created?.directory) return
|
if (!created?.directory) return
|
||||||
|
|
||||||
setWorkspaceName(created.directory, created.branch, project.id, created.branch)
|
setWorkspaceName(created.directory, created.branch ?? getFilename(created.directory), project.id, created.branch)
|
||||||
|
|
||||||
const local = project.worktree
|
const local = project.worktree
|
||||||
const key = pathKey(created.directory)
|
const key = pathKey(created.directory)
|
||||||
@@ -2096,6 +2119,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
}
|
}
|
||||||
|
keyed
|
||||||
>
|
>
|
||||||
{(project) => (
|
{(project) => (
|
||||||
<>
|
<>
|
||||||
@@ -2106,9 +2130,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
id={`project:${projectId()}`}
|
id={`project:${projectId()}`}
|
||||||
value={projectName}
|
value={projectName}
|
||||||
onSave={(next) => {
|
onSave={(next) => {
|
||||||
const item = project()
|
void renameProject(project, next)
|
||||||
if (!item) return
|
|
||||||
void renameProject(item, next)
|
|
||||||
}}
|
}}
|
||||||
class="text-14-medium text-text-strong truncate"
|
class="text-14-medium text-text-strong truncate"
|
||||||
displayClass="text-14-medium text-text-strong truncate"
|
displayClass="text-14-medium text-text-strong truncate"
|
||||||
@@ -2150,9 +2172,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
<DropdownMenu.Content class="mt-1">
|
<DropdownMenu.Content class="mt-1">
|
||||||
<DropdownMenu.Item
|
<DropdownMenu.Item
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
const item = project()
|
showEditProjectDialog(project)
|
||||||
if (!item) return
|
|
||||||
showEditProjectDialog(item)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DropdownMenu.ItemLabel>{language.t("common.edit")}</DropdownMenu.ItemLabel>
|
<DropdownMenu.ItemLabel>{language.t("common.edit")}</DropdownMenu.ItemLabel>
|
||||||
@@ -2162,9 +2182,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
data-project={slug()}
|
data-project={slug()}
|
||||||
disabled={!canToggle()}
|
disabled={!canToggle()}
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
const item = project()
|
toggleProjectWorkspaces(project)
|
||||||
if (!item) return
|
|
||||||
toggleProjectWorkspaces(item)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DropdownMenu.ItemLabel>
|
<DropdownMenu.ItemLabel>
|
||||||
@@ -2223,7 +2241,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
<div class="flex-1 min-h-0">
|
<div class="flex-1 min-h-0">
|
||||||
<LocalWorkspace
|
<LocalWorkspace
|
||||||
ctx={workspaceSidebarCtx}
|
ctx={workspaceSidebarCtx}
|
||||||
project={project()}
|
project={project}
|
||||||
sortNow={sortNow}
|
sortNow={sortNow}
|
||||||
mobile={panelProps.mobile}
|
mobile={panelProps.mobile}
|
||||||
/>
|
/>
|
||||||
@@ -2238,9 +2256,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
icon="plus-small"
|
icon="plus-small"
|
||||||
class="w-full"
|
class="w-full"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const item = project()
|
void createWorkspace(project)
|
||||||
if (!item) return
|
|
||||||
void createWorkspace(item)
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{language.t("workspace.new")}
|
{language.t("workspace.new")}
|
||||||
@@ -2267,7 +2283,7 @@ export default function Layout(props: ParentProps) {
|
|||||||
<SortableWorkspace
|
<SortableWorkspace
|
||||||
ctx={workspaceSidebarCtx}
|
ctx={workspaceSidebarCtx}
|
||||||
directory={directory}
|
directory={directory}
|
||||||
project={project()}
|
project={project}
|
||||||
sortNow={sortNow}
|
sortNow={sortNow}
|
||||||
mobile={panelProps.mobile}
|
mobile={panelProps.mobile}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -166,18 +166,7 @@ export const SessionItem = (props: SessionItemProps): JSX.Element => {
|
|||||||
})
|
})
|
||||||
const isWorking = createMemo(() => {
|
const isWorking = createMemo(() => {
|
||||||
if (hasPermissions()) return false
|
if (hasPermissions()) return false
|
||||||
const pending = (sessionStore.message[props.session.id] ?? []).findLast(
|
return sessionStore.session_working(props.session.id)
|
||||||
(message) =>
|
|
||||||
message.role === "assistant" &&
|
|
||||||
typeof (message as { time?: { completed?: unknown } }).time?.completed !== "number",
|
|
||||||
)
|
|
||||||
const status = sessionStore.session_status[props.session.id]
|
|
||||||
return (
|
|
||||||
pending !== undefined ||
|
|
||||||
status?.type === "busy" ||
|
|
||||||
status?.type === "retry" ||
|
|
||||||
(status !== undefined && status.type !== "idle")
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const tint = createMemo(() => messageAgentColor(sessionStore.message[props.session.id], sessionStore.agent))
|
const tint = createMemo(() => messageAgentColor(sessionStore.message[props.session.id], sessionStore.agent))
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ export const SortableProject = (props: {
|
|||||||
const isWorking = createMemo(() =>
|
const isWorking = createMemo(() =>
|
||||||
dirs().some((directory) => {
|
dirs().some((directory) => {
|
||||||
const [store] = globalSync.child(directory, { bootstrap: false })
|
const [store] = globalSync.child(directory, { bootstrap: false })
|
||||||
return Object.values(store.session_status).some((status) => status?.type === "busy" || status?.type === "retry")
|
return Object.keys(store.session_status).some((id) => store.session_working(id))
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const projectSessions = createMemo(() => sortedRootSessions(projectStore(), props.sortNow()))
|
const projectSessions = createMemo(() => sortedRootSessions(projectStore(), props.sortNow()))
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { Spinner } from "@opencode-ai/ui/spinner"
|
|||||||
import { Tooltip } from "@opencode-ai/ui/tooltip"
|
import { Tooltip } from "@opencode-ai/ui/tooltip"
|
||||||
import { type Session } from "@opencode-ai/sdk/v2/client"
|
import { type Session } from "@opencode-ai/sdk/v2/client"
|
||||||
import { type LocalProject } from "@/context/layout"
|
import { type LocalProject } from "@/context/layout"
|
||||||
import { loadSessionsQueryKey, useGlobalSync } from "@/context/global-sync"
|
import { useGlobalSync, useQueryOptions } from "@/context/global-sync"
|
||||||
import { useLanguage } from "@/context/language"
|
import { useLanguage } from "@/context/language"
|
||||||
import { pathKey } from "@/utils/path-key"
|
import { pathKey } from "@/utils/path-key"
|
||||||
import { NewSessionItem, SessionItem, SessionSkeleton } from "./sidebar-items"
|
import { NewSessionItem, SessionItem, SessionSkeleton } from "./sidebar-items"
|
||||||
@@ -300,6 +300,7 @@ export const SortableWorkspace = (props: {
|
|||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const params = useParams()
|
const params = useParams()
|
||||||
const globalSync = useGlobalSync()
|
const globalSync = useGlobalSync()
|
||||||
|
const queryOptions = useQueryOptions()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const sortable = createSortable(props.directory)
|
const sortable = createSortable(props.directory)
|
||||||
const [workspaceStore, setWorkspaceStore] = globalSync.child(props.directory, { bootstrap: false })
|
const [workspaceStore, setWorkspaceStore] = globalSync.child(props.directory, { bootstrap: false })
|
||||||
@@ -320,7 +321,7 @@ export const SortableWorkspace = (props: {
|
|||||||
const boot = createMemo(() => open() || active())
|
const boot = createMemo(() => open() || active())
|
||||||
const count = createMemo(() => sessions()?.length ?? 0)
|
const count = createMemo(() => sessions()?.length ?? 0)
|
||||||
const hasMore = createMemo(() => workspaceStore.sessionTotal > count())
|
const hasMore = createMemo(() => workspaceStore.sessionTotal > count())
|
||||||
const fetching = useIsFetching(() => ({ queryKey: loadSessionsQueryKey(props.directory) }))
|
const fetching = useIsFetching(() => queryOptions.sessions(pathKey(props.directory)))
|
||||||
const busy = createMemo(() => props.ctx.isBusy(props.directory))
|
const busy = createMemo(() => props.ctx.isBusy(props.directory))
|
||||||
const loading = () => fetching() > 0 && count() === 0
|
const loading = () => fetching() > 0 && count() === 0
|
||||||
const touch = createMediaQuery("(hover: none)")
|
const touch = createMediaQuery("(hover: none)")
|
||||||
@@ -446,6 +447,7 @@ export const LocalWorkspace = (props: {
|
|||||||
mobile?: boolean
|
mobile?: boolean
|
||||||
}): JSX.Element => {
|
}): JSX.Element => {
|
||||||
const globalSync = useGlobalSync()
|
const globalSync = useGlobalSync()
|
||||||
|
const queryOptions = useQueryOptions()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const workspace = createMemo(() => {
|
const workspace = createMemo(() => {
|
||||||
const [store, setStore] = globalSync.child(props.project.worktree)
|
const [store, setStore] = globalSync.child(props.project.worktree)
|
||||||
@@ -454,7 +456,7 @@ export const LocalWorkspace = (props: {
|
|||||||
const slug = createMemo(() => base64Encode(props.project.worktree))
|
const slug = createMemo(() => base64Encode(props.project.worktree))
|
||||||
const sessions = createMemo(() => sortedRootSessions(workspace().store, props.sortNow()))
|
const sessions = createMemo(() => sortedRootSessions(workspace().store, props.sortNow()))
|
||||||
const count = createMemo(() => sessions()?.length ?? 0)
|
const count = createMemo(() => sessions()?.length ?? 0)
|
||||||
const fetching = useIsFetching(() => ({ queryKey: loadSessionsQueryKey(props.project.worktree) }))
|
const fetching = useIsFetching(() => queryOptions.sessions(pathKey(props.project.worktree)))
|
||||||
const hasMore = createMemo(() => workspace().store.sessionTotal > count())
|
const hasMore = createMemo(() => workspace().store.sessionTotal > count())
|
||||||
const loading = () => fetching() > 0 && count() === 0
|
const loading = () => fetching() > 0 && count() === 0
|
||||||
const loadMore = async () => {
|
const loadMore = async () => {
|
||||||
|
|||||||
@@ -1496,12 +1496,7 @@ export default function Page() {
|
|||||||
return out
|
return out
|
||||||
})
|
})
|
||||||
|
|
||||||
const busy = (sessionID: string) => {
|
const busy = (sessionID: string) => sync.data.session_working(sessionID)
|
||||||
if ((sync.data.session_status[sessionID] ?? { type: "idle" as const }).type !== "idle") return true
|
|
||||||
return (sync.data.message[sessionID] ?? []).some(
|
|
||||||
(item) => item.role === "assistant" && typeof item.time.completed !== "number",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const queuedFollowups = createMemo(() => {
|
const queuedFollowups = createMemo(() => {
|
||||||
const id = params.id
|
const id = params.id
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { Show, createEffect, createMemo, onCleanup } from "solid-js"
|
|||||||
import { createStore } from "solid-js/store"
|
import { createStore } from "solid-js/store"
|
||||||
import { useNavigate } from "@solidjs/router"
|
import { useNavigate } from "@solidjs/router"
|
||||||
import { useSpring } from "@opencode-ai/ui/motion-spring"
|
import { useSpring } from "@opencode-ai/ui/motion-spring"
|
||||||
|
import { useLayout } from "@/context/layout"
|
||||||
import { PromptInput } from "@/components/prompt-input"
|
import { PromptInput } from "@/components/prompt-input"
|
||||||
import { useLanguage } from "@/context/language"
|
import { useLanguage } from "@/context/language"
|
||||||
import { usePrompt } from "@/context/prompt"
|
import { usePrompt } from "@/context/prompt"
|
||||||
@@ -46,10 +47,12 @@ export function SessionComposerRegion(props: {
|
|||||||
setPromptDockRef: (el: HTMLDivElement) => void
|
setPromptDockRef: (el: HTMLDivElement) => void
|
||||||
}) {
|
}) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const layout = useLayout()
|
||||||
const prompt = usePrompt()
|
const prompt = usePrompt()
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const route = useSessionKey()
|
const route = useSessionKey()
|
||||||
const sync = useSync()
|
const sync = useSync()
|
||||||
|
const view = layout.view(route.sessionKey)
|
||||||
|
|
||||||
const handoffPrompt = createMemo(() => getSessionHandoff(route.sessionKey())?.prompt)
|
const handoffPrompt = createMemo(() => getSessionHandoff(route.sessionKey())?.prompt)
|
||||||
const info = createMemo(() => (route.params.id ? sync.session.get(route.params.id) : undefined))
|
const info = createMemo(() => (route.params.id ? sync.session.get(route.params.id) : undefined))
|
||||||
@@ -207,6 +210,8 @@ export function SessionComposerRegion(props: {
|
|||||||
<SessionTodoDock
|
<SessionTodoDock
|
||||||
sessionID={route.params.id}
|
sessionID={route.params.id}
|
||||||
todos={props.state.todos()}
|
todos={props.state.todos()}
|
||||||
|
collapsed={view.todoCollapsed.get()}
|
||||||
|
onToggle={() => view.todoCollapsed.set(!view.todoCollapsed.get())}
|
||||||
collapseLabel={language.t("session.todo.collapse")}
|
collapseLabel={language.t("session.todo.collapse")}
|
||||||
expandLabel={language.t("session.todo.expand")}
|
expandLabel={language.t("session.todo.expand")}
|
||||||
dockProgress={value()}
|
dockProgress={value()}
|
||||||
|
|||||||
@@ -57,14 +57,7 @@ export function createSessionComposerState(options?: { closeMs?: number | (() =>
|
|||||||
() => todos().length > 0 && todos().every((todo) => todo.status === "completed" || todo.status === "cancelled"),
|
() => todos().length > 0 && todos().every((todo) => todo.status === "completed" || todo.status === "cancelled"),
|
||||||
)
|
)
|
||||||
|
|
||||||
const status = createMemo(() => {
|
const live = createMemo(() => sync.data.session_working(params.id ?? "") || blocked())
|
||||||
const id = params.id
|
|
||||||
if (!id) return idle
|
|
||||||
return sync.data.session_status[id] ?? idle
|
|
||||||
})
|
|
||||||
|
|
||||||
const busy = createMemo(() => status().type !== "idle")
|
|
||||||
const live = createMemo(() => busy() || blocked())
|
|
||||||
|
|
||||||
const [store, setStore] = createStore({
|
const [store, setStore] = createStore({
|
||||||
responding: undefined as string | undefined,
|
responding: undefined as string | undefined,
|
||||||
|
|||||||
@@ -42,18 +42,17 @@ function dot(status: Todo["status"]) {
|
|||||||
export function SessionTodoDock(props: {
|
export function SessionTodoDock(props: {
|
||||||
sessionID?: string
|
sessionID?: string
|
||||||
todos: Todo[]
|
todos: Todo[]
|
||||||
|
collapsed: boolean
|
||||||
|
onToggle: () => void
|
||||||
collapseLabel: string
|
collapseLabel: string
|
||||||
expandLabel: string
|
expandLabel: string
|
||||||
dockProgress: number
|
dockProgress: number
|
||||||
}) {
|
}) {
|
||||||
const language = useLanguage()
|
const language = useLanguage()
|
||||||
const [store, setStore] = createStore({
|
const [store, setStore] = createStore({
|
||||||
collapsed: false,
|
|
||||||
height: 320,
|
height: 320,
|
||||||
})
|
})
|
||||||
|
|
||||||
const toggle = () => setStore("collapsed", (value) => !value)
|
|
||||||
|
|
||||||
const total = createMemo(() => props.todos.length)
|
const total = createMemo(() => props.todos.length)
|
||||||
const done = createMemo(() => props.todos.filter((todo) => todo.status === "completed").length)
|
const done = createMemo(() => props.todos.filter((todo) => todo.status === "completed").length)
|
||||||
const label = createMemo(() => language.t("session.todo.progress", { done: done(), total: total() }))
|
const label = createMemo(() => language.t("session.todo.progress", { done: done(), total: total() }))
|
||||||
@@ -72,7 +71,7 @@ export function SessionTodoDock(props: {
|
|||||||
)
|
)
|
||||||
|
|
||||||
const preview = createMemo(() => active()?.content ?? "")
|
const preview = createMemo(() => active()?.content ?? "")
|
||||||
const collapse = useSpring(() => (store.collapsed ? 1 : 0), { visualDuration: 0.3, bounce: 0 })
|
const collapse = useSpring(() => (props.collapsed ? 1 : 0), { visualDuration: 0.3, bounce: 0 })
|
||||||
const dock = createMemo(() => Math.max(0, Math.min(1, props.dockProgress)))
|
const dock = createMemo(() => Math.max(0, Math.min(1, props.dockProgress)))
|
||||||
const shut = createMemo(() => 1 - dock())
|
const shut = createMemo(() => 1 - dock())
|
||||||
const value = createMemo(() => Math.max(0, Math.min(1, collapse())))
|
const value = createMemo(() => Math.max(0, Math.min(1, collapse())))
|
||||||
@@ -107,11 +106,11 @@ export function SessionTodoDock(props: {
|
|||||||
class="pl-3 pr-2 py-2 flex items-center gap-2 overflow-visible"
|
class="pl-3 pr-2 py-2 flex items-center gap-2 overflow-visible"
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
onClick={toggle}
|
onClick={props.onToggle}
|
||||||
onKeyDown={(event) => {
|
onKeyDown={(event) => {
|
||||||
if (event.key !== "Enter" && event.key !== " ") return
|
if (event.key !== "Enter" && event.key !== " ") return
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
toggle()
|
props.onToggle()
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@@ -148,7 +147,7 @@ export function SessionTodoDock(props: {
|
|||||||
>
|
>
|
||||||
<TextReveal
|
<TextReveal
|
||||||
class="text-14-regular text-text-base cursor-default"
|
class="text-14-regular text-text-base cursor-default"
|
||||||
text={store.collapsed ? preview() : undefined}
|
text={props.collapsed ? preview() : undefined}
|
||||||
duration={600}
|
duration={600}
|
||||||
travel={25}
|
travel={25}
|
||||||
edge={17}
|
edge={17}
|
||||||
@@ -161,7 +160,7 @@ export function SessionTodoDock(props: {
|
|||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
<IconButton
|
<IconButton
|
||||||
data-action="session-todo-toggle-button"
|
data-action="session-todo-toggle-button"
|
||||||
data-collapsed={store.collapsed ? "true" : "false"}
|
data-collapsed={props.collapsed ? "true" : "false"}
|
||||||
icon="chevron-down"
|
icon="chevron-down"
|
||||||
size="normal"
|
size="normal"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
@@ -172,16 +171,16 @@ export function SessionTodoDock(props: {
|
|||||||
}}
|
}}
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
toggle()
|
props.onToggle()
|
||||||
}}
|
}}
|
||||||
aria-label={store.collapsed ? props.expandLabel : props.collapseLabel}
|
aria-label={props.collapsed ? props.expandLabel : props.collapseLabel}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-slot="session-todo-list"
|
data-slot="session-todo-list"
|
||||||
aria-hidden={store.collapsed || off()}
|
aria-hidden={props.collapsed || off()}
|
||||||
classList={{
|
classList={{
|
||||||
"pointer-events-none": hide() > 0.1,
|
"pointer-events-none": hide() > 0.1,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ export interface SessionReviewTabProps {
|
|||||||
focusedComment?: { file: string; id: string } | null
|
focusedComment?: { file: string; id: string } | null
|
||||||
onFocusedCommentChange?: (focus: { file: string; id: string } | null) => void
|
onFocusedCommentChange?: (focus: { file: string; id: string } | null) => void
|
||||||
focusedFile?: string
|
focusedFile?: string
|
||||||
onScrollRef?: (el: HTMLDivElement) => void
|
onScrollRef?: (el: HTMLDivElement | undefined) => void
|
||||||
commentMentions?: {
|
commentMentions?: {
|
||||||
items: (query: string) => string[] | Promise<string[]>
|
items: (query: string) => string[] | Promise<string[]>
|
||||||
}
|
}
|
||||||
@@ -126,6 +126,7 @@ export function SessionReviewTab(props: SessionReviewTabProps) {
|
|||||||
|
|
||||||
onCleanup(() => {
|
onCleanup(() => {
|
||||||
if (restoreFrame !== undefined) cancelAnimationFrame(restoreFrame)
|
if (restoreFrame !== undefined) cancelAnimationFrame(restoreFrame)
|
||||||
|
props.onScrollRef?.(undefined)
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -221,239 +221,241 @@ export function SessionSidePanel(props: {
|
|||||||
}}
|
}}
|
||||||
style={{ width: panelWidth() }}
|
style={{ width: panelWidth() }}
|
||||||
>
|
>
|
||||||
<div class="size-full flex border-l border-border-weaker-base">
|
<Show when={open()}>
|
||||||
<div
|
<div class="size-full flex border-l border-border-weaker-base">
|
||||||
aria-hidden={!reviewOpen()}
|
|
||||||
inert={!reviewOpen()}
|
|
||||||
class="relative min-w-0 h-full flex-1 overflow-hidden bg-background-base"
|
|
||||||
classList={{
|
|
||||||
"pointer-events-none": !reviewOpen(),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<div class="size-full min-w-0 h-full bg-background-base">
|
|
||||||
<DragDropProvider
|
|
||||||
onDragStart={handleDragStart}
|
|
||||||
onDragEnd={handleDragEnd}
|
|
||||||
onDragOver={handleDragOver}
|
|
||||||
collisionDetector={closestCenter}
|
|
||||||
>
|
|
||||||
<DragDropSensors />
|
|
||||||
<ConstrainDragYAxis />
|
|
||||||
<Tabs value={activeTab()} onChange={openTab}>
|
|
||||||
<div class="sticky top-0 shrink-0 flex">
|
|
||||||
<Tabs.List
|
|
||||||
ref={(el: HTMLDivElement) => {
|
|
||||||
const stop = createFileTabListSync({ el, contextOpen })
|
|
||||||
onCleanup(stop)
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Show when={reviewTab() && props.canReview()}>
|
|
||||||
<Tabs.Trigger value="review">
|
|
||||||
<div class="flex items-center gap-1.5">
|
|
||||||
<div>{language.t("session.tab.review")}</div>
|
|
||||||
<Show when={props.hasReview()}>
|
|
||||||
<div>{props.reviewCount()}</div>
|
|
||||||
</Show>
|
|
||||||
</div>
|
|
||||||
</Tabs.Trigger>
|
|
||||||
</Show>
|
|
||||||
<Show when={contextOpen()}>
|
|
||||||
<Tabs.Trigger
|
|
||||||
value="context"
|
|
||||||
closeButton={
|
|
||||||
<TooltipKeybind
|
|
||||||
title={language.t("common.closeTab")}
|
|
||||||
keybind={command.keybind("tab.close")}
|
|
||||||
placement="bottom"
|
|
||||||
gutter={10}
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
icon="close-small"
|
|
||||||
variant="ghost"
|
|
||||||
class="h-5 w-5"
|
|
||||||
onClick={() => tabs().close("context")}
|
|
||||||
aria-label={language.t("common.closeTab")}
|
|
||||||
/>
|
|
||||||
</TooltipKeybind>
|
|
||||||
}
|
|
||||||
hideCloseButton
|
|
||||||
onMiddleClick={() => tabs().close("context")}
|
|
||||||
>
|
|
||||||
<div class="flex items-center gap-2">
|
|
||||||
<SessionContextUsage variant="indicator" />
|
|
||||||
<div>{language.t("session.tab.context")}</div>
|
|
||||||
</div>
|
|
||||||
</Tabs.Trigger>
|
|
||||||
</Show>
|
|
||||||
<SortableProvider ids={openedTabs()}>
|
|
||||||
<For each={openedTabs()}>{(tab) => <SortableTab tab={tab} onTabClose={tabs().close} />}</For>
|
|
||||||
</SortableProvider>
|
|
||||||
<div class="bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3">
|
|
||||||
<TooltipKeybind
|
|
||||||
title={language.t("command.file.open")}
|
|
||||||
keybind={command.keybind("file.open")}
|
|
||||||
class="flex items-center"
|
|
||||||
>
|
|
||||||
<IconButton
|
|
||||||
icon="plus-small"
|
|
||||||
variant="ghost"
|
|
||||||
iconSize="large"
|
|
||||||
class="!rounded-md"
|
|
||||||
onClick={() => {
|
|
||||||
void import("@/components/dialog-select-file").then((x) => {
|
|
||||||
dialog.show(() => <x.DialogSelectFile mode="files" onOpenFile={showAllFiles} />)
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
aria-label={language.t("command.file.open")}
|
|
||||||
/>
|
|
||||||
</TooltipKeybind>
|
|
||||||
</div>
|
|
||||||
</Tabs.List>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Show when={reviewTab() && props.canReview()}>
|
|
||||||
<Tabs.Content value="review" class="flex flex-col h-full overflow-hidden contain-strict">
|
|
||||||
<Show when={activeTab() === "review"}>{props.reviewPanel()}</Show>
|
|
||||||
</Tabs.Content>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<Tabs.Content value="empty" class="flex flex-col h-full overflow-hidden contain-strict">
|
|
||||||
<Show when={activeTab() === "empty"}>
|
|
||||||
<div class="relative pt-2 flex-1 min-h-0 overflow-hidden">
|
|
||||||
<div class="h-full px-6 pb-42 -mt-4 flex flex-col items-center justify-center text-center gap-6">
|
|
||||||
<Mark class="w-14 opacity-10" />
|
|
||||||
<div class="text-14-regular text-text-weak max-w-56">
|
|
||||||
{language.t("session.files.selectToOpen")}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
</Tabs.Content>
|
|
||||||
|
|
||||||
<Show when={contextOpen()}>
|
|
||||||
<Tabs.Content value="context" class="flex flex-col h-full overflow-hidden contain-strict">
|
|
||||||
<Show when={activeTab() === "context"}>
|
|
||||||
<div class="relative pt-2 flex-1 min-h-0 overflow-hidden">
|
|
||||||
<SessionContextTab />
|
|
||||||
</div>
|
|
||||||
</Show>
|
|
||||||
</Tabs.Content>
|
|
||||||
</Show>
|
|
||||||
|
|
||||||
<Show when={activeFileTab()} keyed>
|
|
||||||
{(tab) => <FileTabContent tab={tab} />}
|
|
||||||
</Show>
|
|
||||||
</Tabs>
|
|
||||||
<DragOverlay>
|
|
||||||
<Show when={store.activeDraggable} keyed>
|
|
||||||
{(tab) => {
|
|
||||||
const path = file.pathFromTab(tab)
|
|
||||||
return (
|
|
||||||
<div data-component="tabs-drag-preview">
|
|
||||||
<Show when={path}>{(p) => <FileVisual active path={p()} />}</Show>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
</Show>
|
|
||||||
</DragOverlay>
|
|
||||||
</DragDropProvider>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Show when={shown()}>
|
|
||||||
<div
|
<div
|
||||||
id="file-tree-panel"
|
aria-hidden={!reviewOpen()}
|
||||||
aria-hidden={!fileOpen()}
|
inert={!reviewOpen()}
|
||||||
inert={!fileOpen()}
|
class="relative min-w-0 h-full flex-1 overflow-hidden bg-background-base"
|
||||||
class="relative min-w-0 h-full shrink-0 overflow-hidden"
|
|
||||||
classList={{
|
classList={{
|
||||||
"pointer-events-none": !fileOpen(),
|
"pointer-events-none": !reviewOpen(),
|
||||||
"transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":
|
|
||||||
!props.size.active(),
|
|
||||||
}}
|
}}
|
||||||
style={{ width: treeWidth() }}
|
|
||||||
>
|
>
|
||||||
<div
|
<div class="size-full min-w-0 h-full bg-background-base">
|
||||||
class="h-full flex flex-col overflow-hidden group/filetree"
|
<DragDropProvider
|
||||||
classList={{ "border-l border-border-weaker-base": reviewOpen() }}
|
onDragStart={handleDragStart}
|
||||||
>
|
onDragEnd={handleDragEnd}
|
||||||
<Tabs
|
onDragOver={handleDragOver}
|
||||||
variant="pill"
|
collisionDetector={closestCenter}
|
||||||
value={fileTreeTab()}
|
|
||||||
onChange={setFileTreeTabValue}
|
|
||||||
class="h-full"
|
|
||||||
data-scope="filetree"
|
|
||||||
>
|
>
|
||||||
<Tabs.List>
|
<DragDropSensors />
|
||||||
<Tabs.Trigger value="changes" class="flex-1" classes={{ button: "w-full" }}>
|
<ConstrainDragYAxis />
|
||||||
{props.reviewCount()}{" "}
|
<Tabs value={activeTab()} onChange={openTab}>
|
||||||
{language.t(
|
<div class="sticky top-0 shrink-0 flex">
|
||||||
props.reviewCount() === 1 ? "session.review.change.one" : "session.review.change.other",
|
<Tabs.List
|
||||||
)}
|
ref={(el: HTMLDivElement) => {
|
||||||
</Tabs.Trigger>
|
const stop = createFileTabListSync({ el, contextOpen })
|
||||||
<Tabs.Trigger value="all" class="flex-1" classes={{ button: "w-full" }}>
|
onCleanup(stop)
|
||||||
{language.t("session.files.all")}
|
}}
|
||||||
</Tabs.Trigger>
|
>
|
||||||
</Tabs.List>
|
<Show when={reviewTab() && props.canReview()}>
|
||||||
<Tabs.Content value="changes" class="bg-background-stronger px-3 py-0">
|
<Tabs.Trigger value="review">
|
||||||
<Switch>
|
<div class="flex items-center gap-1.5">
|
||||||
<Match when={props.hasReview() || !props.diffsReady()}>
|
<div>{language.t("session.tab.review")}</div>
|
||||||
<Show
|
<Show when={props.hasReview()}>
|
||||||
when={props.diffsReady()}
|
<div>{props.reviewCount()}</div>
|
||||||
fallback={
|
</Show>
|
||||||
<div class="px-2 py-2 text-12-regular text-text-weak">
|
|
||||||
{language.t("common.loading")}
|
|
||||||
{language.t("common.loading.ellipsis")}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
</Tabs.Trigger>
|
||||||
>
|
</Show>
|
||||||
|
<Show when={contextOpen()}>
|
||||||
|
<Tabs.Trigger
|
||||||
|
value="context"
|
||||||
|
closeButton={
|
||||||
|
<TooltipKeybind
|
||||||
|
title={language.t("common.closeTab")}
|
||||||
|
keybind={command.keybind("tab.close")}
|
||||||
|
placement="bottom"
|
||||||
|
gutter={10}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
icon="close-small"
|
||||||
|
variant="ghost"
|
||||||
|
class="h-5 w-5"
|
||||||
|
onClick={() => tabs().close("context")}
|
||||||
|
aria-label={language.t("common.closeTab")}
|
||||||
|
/>
|
||||||
|
</TooltipKeybind>
|
||||||
|
}
|
||||||
|
hideCloseButton
|
||||||
|
onMiddleClick={() => tabs().close("context")}
|
||||||
|
>
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
<SessionContextUsage variant="indicator" />
|
||||||
|
<div>{language.t("session.tab.context")}</div>
|
||||||
|
</div>
|
||||||
|
</Tabs.Trigger>
|
||||||
|
</Show>
|
||||||
|
<SortableProvider ids={openedTabs()}>
|
||||||
|
<For each={openedTabs()}>{(tab) => <SortableTab tab={tab} onTabClose={tabs().close} />}</For>
|
||||||
|
</SortableProvider>
|
||||||
|
<div class="bg-background-stronger h-full shrink-0 sticky right-0 z-10 flex items-center justify-center pr-3">
|
||||||
|
<TooltipKeybind
|
||||||
|
title={language.t("command.file.open")}
|
||||||
|
keybind={command.keybind("file.open")}
|
||||||
|
class="flex items-center"
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
icon="plus-small"
|
||||||
|
variant="ghost"
|
||||||
|
iconSize="large"
|
||||||
|
class="!rounded-md"
|
||||||
|
onClick={() => {
|
||||||
|
void import("@/components/dialog-select-file").then((x) => {
|
||||||
|
dialog.show(() => <x.DialogSelectFile mode="files" onOpenFile={showAllFiles} />)
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
aria-label={language.t("command.file.open")}
|
||||||
|
/>
|
||||||
|
</TooltipKeybind>
|
||||||
|
</div>
|
||||||
|
</Tabs.List>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Show when={reviewTab() && props.canReview()}>
|
||||||
|
<Tabs.Content value="review" class="flex flex-col h-full overflow-hidden contain-strict">
|
||||||
|
<Show when={reviewOpen() && activeTab() === "review"}>{props.reviewPanel()}</Show>
|
||||||
|
</Tabs.Content>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
<Tabs.Content value="empty" class="flex flex-col h-full overflow-hidden contain-strict">
|
||||||
|
<Show when={activeTab() === "empty"}>
|
||||||
|
<div class="relative pt-2 flex-1 min-h-0 overflow-hidden">
|
||||||
|
<div class="h-full px-6 pb-42 -mt-4 flex flex-col items-center justify-center text-center gap-6">
|
||||||
|
<Mark class="w-14 opacity-10" />
|
||||||
|
<div class="text-14-regular text-text-weak max-w-56">
|
||||||
|
{language.t("session.files.selectToOpen")}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
</Tabs.Content>
|
||||||
|
|
||||||
|
<Show when={contextOpen()}>
|
||||||
|
<Tabs.Content value="context" class="flex flex-col h-full overflow-hidden contain-strict">
|
||||||
|
<Show when={activeTab() === "context"}>
|
||||||
|
<div class="relative pt-2 flex-1 min-h-0 overflow-hidden">
|
||||||
|
<SessionContextTab />
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
</Tabs.Content>
|
||||||
|
</Show>
|
||||||
|
|
||||||
|
<Show when={activeFileTab()} keyed>
|
||||||
|
{(tab) => <FileTabContent tab={tab} />}
|
||||||
|
</Show>
|
||||||
|
</Tabs>
|
||||||
|
<DragOverlay>
|
||||||
|
<Show when={store.activeDraggable} keyed>
|
||||||
|
{(tab) => {
|
||||||
|
const path = file.pathFromTab(tab)
|
||||||
|
return (
|
||||||
|
<div data-component="tabs-drag-preview">
|
||||||
|
<Show when={path}>{(p) => <FileVisual active path={p()} />}</Show>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}}
|
||||||
|
</Show>
|
||||||
|
</DragOverlay>
|
||||||
|
</DragDropProvider>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Show when={shown()}>
|
||||||
|
<div
|
||||||
|
id="file-tree-panel"
|
||||||
|
aria-hidden={!fileOpen()}
|
||||||
|
inert={!fileOpen()}
|
||||||
|
class="relative min-w-0 h-full shrink-0 overflow-hidden"
|
||||||
|
classList={{
|
||||||
|
"pointer-events-none": !fileOpen(),
|
||||||
|
"transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-[width] motion-reduce:transition-none":
|
||||||
|
!props.size.active(),
|
||||||
|
}}
|
||||||
|
style={{ width: treeWidth() }}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="h-full flex flex-col overflow-hidden group/filetree"
|
||||||
|
classList={{ "border-l border-border-weaker-base": reviewOpen() }}
|
||||||
|
>
|
||||||
|
<Tabs
|
||||||
|
variant="pill"
|
||||||
|
value={fileTreeTab()}
|
||||||
|
onChange={setFileTreeTabValue}
|
||||||
|
class="h-full"
|
||||||
|
data-scope="filetree"
|
||||||
|
>
|
||||||
|
<Tabs.List>
|
||||||
|
<Tabs.Trigger value="changes" class="flex-1" classes={{ button: "w-full" }}>
|
||||||
|
{props.reviewCount()}{" "}
|
||||||
|
{language.t(
|
||||||
|
props.reviewCount() === 1 ? "session.review.change.one" : "session.review.change.other",
|
||||||
|
)}
|
||||||
|
</Tabs.Trigger>
|
||||||
|
<Tabs.Trigger value="all" class="flex-1" classes={{ button: "w-full" }}>
|
||||||
|
{language.t("session.files.all")}
|
||||||
|
</Tabs.Trigger>
|
||||||
|
</Tabs.List>
|
||||||
|
<Tabs.Content value="changes" class="bg-background-stronger px-3 py-0">
|
||||||
|
<Switch>
|
||||||
|
<Match when={props.hasReview() || !props.diffsReady()}>
|
||||||
|
<Show
|
||||||
|
when={props.diffsReady()}
|
||||||
|
fallback={
|
||||||
|
<div class="px-2 py-2 text-12-regular text-text-weak">
|
||||||
|
{language.t("common.loading")}
|
||||||
|
{language.t("common.loading.ellipsis")}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<FileTree
|
||||||
|
path=""
|
||||||
|
class="pt-3"
|
||||||
|
allowed={diffFiles()}
|
||||||
|
kinds={kinds()}
|
||||||
|
draggable={false}
|
||||||
|
active={props.activeDiff}
|
||||||
|
onFileClick={(node) => props.focusReviewDiff(node.path)}
|
||||||
|
/>
|
||||||
|
</Show>
|
||||||
|
</Match>
|
||||||
|
</Switch>
|
||||||
|
</Tabs.Content>
|
||||||
|
<Tabs.Content value="all" class="bg-background-stronger px-3 py-0">
|
||||||
|
<Switch>
|
||||||
|
<Match when={nofiles()}>{empty(language.t("session.files.empty"))}</Match>
|
||||||
|
<Match when={true}>
|
||||||
<FileTree
|
<FileTree
|
||||||
path=""
|
path=""
|
||||||
class="pt-3"
|
class="pt-3"
|
||||||
allowed={diffFiles()}
|
modified={diffFiles()}
|
||||||
kinds={kinds()}
|
kinds={kinds()}
|
||||||
draggable={false}
|
onFileClick={(node) => openTab(file.tab(node.path))}
|
||||||
active={props.activeDiff}
|
|
||||||
onFileClick={(node) => props.focusReviewDiff(node.path)}
|
|
||||||
/>
|
/>
|
||||||
</Show>
|
</Match>
|
||||||
</Match>
|
</Switch>
|
||||||
</Switch>
|
</Tabs.Content>
|
||||||
</Tabs.Content>
|
</Tabs>
|
||||||
<Tabs.Content value="all" class="bg-background-stronger px-3 py-0">
|
|
||||||
<Switch>
|
|
||||||
<Match when={nofiles()}>{empty(language.t("session.files.empty"))}</Match>
|
|
||||||
<Match when={true}>
|
|
||||||
<FileTree
|
|
||||||
path=""
|
|
||||||
class="pt-3"
|
|
||||||
modified={diffFiles()}
|
|
||||||
kinds={kinds()}
|
|
||||||
onFileClick={(node) => openTab(file.tab(node.path))}
|
|
||||||
/>
|
|
||||||
</Match>
|
|
||||||
</Switch>
|
|
||||||
</Tabs.Content>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
|
||||||
<Show when={fileOpen()}>
|
|
||||||
<div onPointerDown={() => props.size.start()}>
|
|
||||||
<ResizeHandle
|
|
||||||
direction="horizontal"
|
|
||||||
edge="start"
|
|
||||||
size={layout.fileTree.width()}
|
|
||||||
min={200}
|
|
||||||
max={480}
|
|
||||||
onResize={(width) => {
|
|
||||||
props.size.touch()
|
|
||||||
layout.fileTree.resize(width)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
<Show when={fileOpen()}>
|
||||||
</div>
|
<div onPointerDown={() => props.size.start()}>
|
||||||
</Show>
|
<ResizeHandle
|
||||||
</div>
|
direction="horizontal"
|
||||||
|
edge="start"
|
||||||
|
size={layout.fileTree.width()}
|
||||||
|
min={200}
|
||||||
|
max={480}
|
||||||
|
onResize={(width) => {
|
||||||
|
props.size.touch()
|
||||||
|
layout.fileTree.resize(width)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
</Show>
|
||||||
</aside>
|
</aside>
|
||||||
</Show>
|
</Show>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -75,8 +75,6 @@ export const useSessionCommands = (actions: SessionCommandContext) => {
|
|||||||
import.meta.env.VITE_OPENCODE_CHANNEL !== "beta" ||
|
import.meta.env.VITE_OPENCODE_CHANNEL !== "beta" ||
|
||||||
settings.general.showFileTree()
|
settings.general.showFileTree()
|
||||||
|
|
||||||
const idle = { type: "idle" as const }
|
|
||||||
const status = () => sync.data.session_status[params.id ?? ""] ?? idle
|
|
||||||
const messages = () => {
|
const messages = () => {
|
||||||
const id = params.id
|
const id = params.id
|
||||||
if (!id) return []
|
if (!id) return []
|
||||||
@@ -290,7 +288,7 @@ export const useSessionCommands = (actions: SessionCommandContext) => {
|
|||||||
const sessionID = params.id
|
const sessionID = params.id
|
||||||
if (!sessionID) return
|
if (!sessionID) return
|
||||||
|
|
||||||
if (status().type !== "idle") {
|
if (sync.data.session_working(params.id ?? "")) {
|
||||||
await sdk.client.session.abort({ sessionID }).catch(() => {})
|
await sdk.client.session.abort({ sessionID }).catch(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
import z from "zod"
|
|
||||||
|
|
||||||
const prefixes = {
|
const prefixes = {
|
||||||
session: "ses",
|
session: "ses",
|
||||||
message: "msg",
|
message: "msg",
|
||||||
@@ -15,10 +13,6 @@ let counter = 0
|
|||||||
|
|
||||||
type Prefix = keyof typeof prefixes
|
type Prefix = keyof typeof prefixes
|
||||||
export namespace Identifier {
|
export namespace Identifier {
|
||||||
export function schema(prefix: Prefix) {
|
|
||||||
return z.string().startsWith(prefixes[prefix])
|
|
||||||
}
|
|
||||||
|
|
||||||
export function ascending(prefix: Prefix, given?: string) {
|
export function ascending(prefix: Prefix, given?: string) {
|
||||||
return generateID(prefix, false, given)
|
return generateID(prefix, false, given)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,4 +128,17 @@ describe("formatServerError", () => {
|
|||||||
["Modelo nao encontrado: x/y", "Voce quis dizer: x/y2, x/y3", "Revise provider/model no config"].join("\n"),
|
["Modelo nao encontrado: x/y", "Voce quis dizer: x/y2, x/y3", "Revise provider/model no config"].join("\n"),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("unwraps SDK-wrapped errors from cause.body", () => {
|
||||||
|
const body = {
|
||||||
|
name: "ConfigInvalidError",
|
||||||
|
data: {
|
||||||
|
message: "Missing host",
|
||||||
|
},
|
||||||
|
} satisfies ConfigInvalidError
|
||||||
|
|
||||||
|
const wrapped = new Error("ConfigInvalidError", { cause: { body, status: 400 } })
|
||||||
|
|
||||||
|
expect(formatServerError(wrapped, language.t)).toBe("Arquivo de config em config invalido: Missing host")
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -26,14 +26,22 @@ function tr(translator: Translator | undefined, key: string, text: string, vars?
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function formatServerError(error: unknown, translate?: Translator, fallback?: string) {
|
export function formatServerError(error: unknown, translate?: Translator, fallback?: string) {
|
||||||
if (isConfigInvalidErrorLike(error)) return parseReadableConfigInvalidError(error, translate)
|
const unwrapped = unwrapNamedError(error)
|
||||||
if (isProviderModelNotFoundErrorLike(error)) return parseReadableProviderModelNotFoundError(error, translate)
|
if (isConfigInvalidErrorLike(unwrapped)) return parseReadableConfigInvalidError(unwrapped, translate)
|
||||||
|
if (isProviderModelNotFoundErrorLike(unwrapped)) return parseReadableProviderModelNotFoundError(unwrapped, translate)
|
||||||
if (error instanceof Error && error.message) return error.message
|
if (error instanceof Error && error.message) return error.message
|
||||||
if (typeof error === "string" && error) return error
|
if (typeof error === "string" && error) return error
|
||||||
if (fallback) return fallback
|
if (fallback) return fallback
|
||||||
return tr(translate, "error.chain.unknown", "Unknown error")
|
return tr(translate, "error.chain.unknown", "Unknown error")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function unwrapNamedError(error: unknown): unknown {
|
||||||
|
if (error instanceof Error && error.cause && typeof error.cause === "object" && "body" in error.cause) {
|
||||||
|
return (error.cause as Record<string, unknown>).body
|
||||||
|
}
|
||||||
|
return error
|
||||||
|
}
|
||||||
|
|
||||||
function isConfigInvalidErrorLike(error: unknown): error is ConfigInvalidError {
|
function isConfigInvalidErrorLike(error: unknown): error is ConfigInvalidError {
|
||||||
if (typeof error !== "object" || error === null) return false
|
if (typeof error !== "object" || error === null) return false
|
||||||
const o = error as Record<string, unknown>
|
const o = error as Record<string, unknown>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@opencode-ai/console-app",
|
"name": "@opencode-ai/console-app",
|
||||||
"version": "1.14.44",
|
"version": "1.15.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ export const config = {
|
|||||||
github: {
|
github: {
|
||||||
repoUrl: "https://github.com/anomalyco/opencode",
|
repoUrl: "https://github.com/anomalyco/opencode",
|
||||||
starsFormatted: {
|
starsFormatted: {
|
||||||
compact: "150K",
|
compact: "160K",
|
||||||
full: "150,000",
|
full: "160,000",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -22,8 +22,8 @@ export const config = {
|
|||||||
|
|
||||||
// Static stats (used on landing page)
|
// Static stats (used on landing page)
|
||||||
stats: {
|
stats: {
|
||||||
contributors: "850",
|
contributors: "900",
|
||||||
commits: "11,000",
|
commits: "13,000",
|
||||||
monthlyUsers: "6.5M",
|
monthlyUsers: "7.5M",
|
||||||
},
|
},
|
||||||
} as const
|
} as const
|
||||||
|
|||||||
@@ -12,13 +12,22 @@ const basePayload = z.object({
|
|||||||
url: z.string(),
|
url: z.string(),
|
||||||
})
|
})
|
||||||
|
|
||||||
const groups = z.object({ group: z.object({ key: z.string(), value: z.string() }).array() }).array()
|
const groups = z
|
||||||
|
.object({
|
||||||
|
result: z.union([z.number(), z.string()]).nullish(),
|
||||||
|
group: z.object({ key: z.string(), value: z.string() }).array(),
|
||||||
|
})
|
||||||
|
.array()
|
||||||
|
|
||||||
const honeycombWebhookPayload = z.discriminatedUnion("type", [
|
const honeycombWebhookPayload = z.discriminatedUnion("type", [
|
||||||
basePayload.extend({
|
basePayload.extend({
|
||||||
type: z.literal("model_http_errors"),
|
type: z.literal("model_http_errors"),
|
||||||
groups,
|
groups,
|
||||||
}),
|
}),
|
||||||
|
basePayload.extend({
|
||||||
|
type: z.literal("model_low_tps"),
|
||||||
|
groups,
|
||||||
|
}),
|
||||||
basePayload.extend({
|
basePayload.extend({
|
||||||
type: z.literal("provider_http_errors"),
|
type: z.literal("provider_http_errors"),
|
||||||
groups,
|
groups,
|
||||||
@@ -29,14 +38,25 @@ const honeycombWebhookPayload = z.discriminatedUnion("type", [
|
|||||||
])
|
])
|
||||||
|
|
||||||
const postDiscordMessage = async (payload: z.infer<typeof honeycombWebhookPayload>) => {
|
const postDiscordMessage = async (payload: z.infer<typeof honeycombWebhookPayload>) => {
|
||||||
const group =
|
const names =
|
||||||
payload.type === "model_http_errors" ? "model" : payload.type === "provider_http_errors" ? "provider" : undefined
|
payload.type === "custom"
|
||||||
const names = payload.type === "custom" ? [] : payload.groups.flatMap((item) => item.group.map((g) => g.value))
|
? []
|
||||||
|
: payload.groups.flatMap((item) =>
|
||||||
|
item.group.map((g) => {
|
||||||
|
const result = item.result == null ? undefined : Number(item.result)
|
||||||
|
return `- ${g.value}${
|
||||||
|
result !== undefined && Number.isFinite(result)
|
||||||
|
? payload.type === "model_low_tps"
|
||||||
|
? ` (${Math.round(result)} TPS)`
|
||||||
|
: ` (${Math.round(result * 100)}% errors)`
|
||||||
|
: ""
|
||||||
|
}`
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
const content = [
|
const content = [
|
||||||
`[**${payload.isTest ? "[TEST] " : ""}${payload.name ?? "Honeycomb alert"}**](${payload.url})`,
|
`[**${payload.isTest ? "[TEST] " : ""}${payload.name ?? "Honeycomb alert"}**](${payload.url})`,
|
||||||
group && names.length > 0 ? `Affected ${group}s:` : undefined,
|
...names,
|
||||||
...names.map((name) => `- ${name}`),
|
|
||||||
"",
|
"",
|
||||||
`<@&${DISCORD_ALERT_ROLE_ID}>`,
|
`<@&${DISCORD_ALERT_ROLE_ID}>`,
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
flex-shrink: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border: none;
|
border: none;
|
||||||
@@ -79,6 +80,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
|
flex-shrink: 0;
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export function UsageSection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const calculateTotalOutputTokens = (u: Awaited<ReturnType<typeof getUsageInfo>>[0]) => {
|
const calculateTotalOutputTokens = (u: Awaited<ReturnType<typeof getUsageInfo>>[0]) => {
|
||||||
return u.outputTokens + (u.reasoningTokens ?? 0)
|
return u.outputTokens
|
||||||
}
|
}
|
||||||
|
|
||||||
const goPrev = async () => {
|
const goPrev = async () => {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import { Resource } from "@opencode-ai/console-resource"
|
|||||||
import { i18n, type Key } from "~/i18n"
|
import { i18n, type Key } from "~/i18n"
|
||||||
import { localeFromRequest } from "~/lib/language"
|
import { localeFromRequest } from "~/lib/language"
|
||||||
import { createModelTpmLimiter } from "./modelTpmLimiter"
|
import { createModelTpmLimiter } from "./modelTpmLimiter"
|
||||||
|
import { createModelTpsLimiter } from "./modelTpsLimiter"
|
||||||
|
|
||||||
type ZenData = Awaited<ReturnType<typeof ZenData.list>>
|
type ZenData = Awaited<ReturnType<typeof ZenData.list>>
|
||||||
type RetryOptions = {
|
type RetryOptions = {
|
||||||
@@ -122,13 +123,15 @@ export async function handler(
|
|||||||
? createIpRateLimiter(modelInfo.id, modelInfo.rateLimit, ip, input.request)
|
? createIpRateLimiter(modelInfo.id, modelInfo.rateLimit, ip, input.request)
|
||||||
: createKeyRateLimiter(modelInfo.id, modelInfo.rateLimit, zenApiKey, input.request)
|
: createKeyRateLimiter(modelInfo.id, modelInfo.rateLimit, zenApiKey, input.request)
|
||||||
await rateLimiter?.check()
|
await rateLimiter?.check()
|
||||||
const stickyTracker = createStickyTracker(modelInfo.stickyProvider, sessionId)
|
const stickyTracker = createStickyTracker(modelInfo.id, modelInfo.stickyProvider, sessionId)
|
||||||
const stickyProvider = await stickyTracker?.get()
|
const stickyProvider = await stickyTracker?.get()
|
||||||
const authInfo = await authenticate(modelInfo, zenApiKey)
|
const authInfo = await authenticate(modelInfo, zenApiKey)
|
||||||
const billingSource = validateBilling(authInfo, modelInfo)
|
const billingSource = validateBilling(authInfo, modelInfo)
|
||||||
logger.metric({ source: billingSource })
|
logger.metric({ source: billingSource })
|
||||||
const modelTpmLimiter = createModelTpmLimiter(modelInfo.providers)
|
const modelTpmLimiter = createModelTpmLimiter(modelInfo.providers)
|
||||||
const modelTpmLimits = await modelTpmLimiter?.check()
|
const modelTpmLimits = await modelTpmLimiter?.check()
|
||||||
|
const modelTpsLimiter = createModelTpsLimiter(modelInfo.providers)
|
||||||
|
const modelTpsLimits = await modelTpsLimiter?.check()
|
||||||
|
|
||||||
const retriableRequest = async (retry: RetryOptions = { excludeProviders: [], retryCount: 0 }) => {
|
const retriableRequest = async (retry: RetryOptions = { excludeProviders: [], retryCount: 0 }) => {
|
||||||
const providerInfo = selectProvider(
|
const providerInfo = selectProvider(
|
||||||
@@ -142,6 +145,7 @@ export async function handler(
|
|||||||
retry,
|
retry,
|
||||||
stickyProvider,
|
stickyProvider,
|
||||||
modelTpmLimits,
|
modelTpmLimits,
|
||||||
|
modelTpsLimits,
|
||||||
)
|
)
|
||||||
validateModelSettings(billingSource, authInfo)
|
validateModelSettings(billingSource, authInfo)
|
||||||
updateProviderKey(authInfo, providerInfo)
|
updateProviderKey(authInfo, providerInfo)
|
||||||
@@ -212,7 +216,7 @@ export async function handler(
|
|||||||
// ie. 400 error is usually provider error like malformed request
|
// ie. 400 error is usually provider error like malformed request
|
||||||
res.status !== 400 &&
|
res.status !== 400 &&
|
||||||
// ie. openai 404 error: Item with id 'msg_0ead8b004a3b165d0069436a6b6834819896da85b63b196a3f' not found.
|
// ie. openai 404 error: Item with id 'msg_0ead8b004a3b165d0069436a6b6834819896da85b63b196a3f' not found.
|
||||||
res.status !== 404 &&
|
!(modelInfo.id.startsWith("gpt-") && res.status === 404) &&
|
||||||
// ie. cannot change codex model providers mid-session
|
// ie. cannot change codex model providers mid-session
|
||||||
modelInfo.stickyProvider !== "strict" &&
|
modelInfo.stickyProvider !== "strict" &&
|
||||||
modelInfo.fallbackProvider &&
|
modelInfo.fallbackProvider &&
|
||||||
@@ -234,7 +238,7 @@ export async function handler(
|
|||||||
dataDumper?.provideRequest(reqBody)
|
dataDumper?.provideRequest(reqBody)
|
||||||
|
|
||||||
// Store sticky provider
|
// Store sticky provider
|
||||||
await stickyTracker?.set(providerInfo.id)
|
if (res.status === 200) await stickyTracker?.set(providerInfo.id)
|
||||||
|
|
||||||
// Temporarily change 404 to 400 status code b/c solid start automatically override 404 response
|
// Temporarily change 404 to 400 status code b/c solid start automatically override 404 response
|
||||||
const resStatus = res.status === 404 ? 400 : res.status
|
const resStatus = res.status === 404 ? 400 : res.status
|
||||||
@@ -294,14 +298,16 @@ export async function handler(
|
|||||||
|
|
||||||
let buffer = ""
|
let buffer = ""
|
||||||
let responseLength = 0
|
let responseLength = 0
|
||||||
|
let timestampFirstByte = 0
|
||||||
|
|
||||||
function pump(): Promise<void> {
|
function pump(): Promise<void> {
|
||||||
return (
|
return (
|
||||||
reader?.read().then(async ({ done, value: rawValue }) => {
|
reader?.read().then(async ({ done, value: rawValue }) => {
|
||||||
if (done) {
|
if (done) {
|
||||||
|
const timestampLastByte = Date.now()
|
||||||
logger.metric({
|
logger.metric({
|
||||||
response_length: responseLength,
|
response_length: responseLength,
|
||||||
"timestamp.last_byte": Date.now(),
|
"timestamp.last_byte": timestampLastByte,
|
||||||
})
|
})
|
||||||
dataDumper?.flush()
|
dataDumper?.flush()
|
||||||
await rateLimiter?.track()
|
await rateLimiter?.track()
|
||||||
@@ -311,6 +317,14 @@ export async function handler(
|
|||||||
const costInfo = calculateCost(modelInfo, usageInfo)
|
const costInfo = calculateCost(modelInfo, usageInfo)
|
||||||
await trialLimiter?.track(usageInfo)
|
await trialLimiter?.track(usageInfo)
|
||||||
await modelTpmLimiter?.track(providerInfo.id, providerInfo.model, usageInfo)
|
await modelTpmLimiter?.track(providerInfo.id, providerInfo.model, usageInfo)
|
||||||
|
await modelTpsLimiter?.track(
|
||||||
|
providerInfo.id,
|
||||||
|
providerInfo.model,
|
||||||
|
providerInfo.tpsGoal,
|
||||||
|
timestampFirstByte,
|
||||||
|
timestampLastByte,
|
||||||
|
usageInfo,
|
||||||
|
)
|
||||||
await trackUsage(sessionId, billingSource, authInfo, modelInfo, providerInfo, usageInfo, costInfo)
|
await trackUsage(sessionId, billingSource, authInfo, modelInfo, providerInfo, usageInfo, costInfo)
|
||||||
await reload(billingSource, authInfo, costInfo)
|
await reload(billingSource, authInfo, costInfo)
|
||||||
const cost = calculateOccurredCost(billingSource, costInfo)
|
const cost = calculateOccurredCost(billingSource, costInfo)
|
||||||
@@ -321,10 +335,10 @@ export async function handler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (responseLength === 0) {
|
if (responseLength === 0) {
|
||||||
const now = Date.now()
|
timestampFirstByte = Date.now()
|
||||||
logger.metric({
|
logger.metric({
|
||||||
time_to_first_byte: now - startTimestamp,
|
time_to_first_byte: timestampFirstByte - startTimestamp,
|
||||||
"timestamp.first_byte": now,
|
"timestamp.first_byte": timestampFirstByte,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -478,6 +492,7 @@ export async function handler(
|
|||||||
retry: RetryOptions,
|
retry: RetryOptions,
|
||||||
stickyProvider: string | undefined,
|
stickyProvider: string | undefined,
|
||||||
modelTpmLimits: Record<string, number> | undefined,
|
modelTpmLimits: Record<string, number> | undefined,
|
||||||
|
modelTpsLimits: Record<string, boolean> | undefined,
|
||||||
) {
|
) {
|
||||||
const modelProvider = (() => {
|
const modelProvider = (() => {
|
||||||
// Byok is top priority b/c if user set their own API key, we should use it
|
// Byok is top priority b/c if user set their own API key, we should use it
|
||||||
@@ -509,6 +524,11 @@ export async function handler(
|
|||||||
const usage = modelTpmLimits?.[`${provider.id}/${provider.model}`] ?? 0
|
const usage = modelTpmLimits?.[`${provider.id}/${provider.model}`] ?? 0
|
||||||
return usage < provider.tpmLimit * 1_000_000
|
return usage < provider.tpmLimit * 1_000_000
|
||||||
})
|
})
|
||||||
|
.filter((provider) => {
|
||||||
|
if (!provider.tpsGoal) return true
|
||||||
|
const isLowTps = modelTpsLimits?.[`${provider.id}/${provider.model}/${provider.tpsGoal}`] ?? false
|
||||||
|
return !isLowTps
|
||||||
|
})
|
||||||
.map((provider) => {
|
.map((provider) => {
|
||||||
topPriority = Math.min(topPriority, provider.priority)
|
topPriority = Math.min(topPriority, provider.priority)
|
||||||
return provider
|
return provider
|
||||||
@@ -889,10 +909,6 @@ export async function handler(
|
|||||||
|
|
||||||
const inputCost = modelCost.input * inputTokens * 100
|
const inputCost = modelCost.input * inputTokens * 100
|
||||||
const outputCost = modelCost.output * outputTokens * 100
|
const outputCost = modelCost.output * outputTokens * 100
|
||||||
const reasoningCost = (() => {
|
|
||||||
if (!reasoningTokens) return undefined
|
|
||||||
return modelCost.output * reasoningTokens * 100
|
|
||||||
})()
|
|
||||||
const cacheReadCost = (() => {
|
const cacheReadCost = (() => {
|
||||||
if (!cacheReadTokens) return undefined
|
if (!cacheReadTokens) return undefined
|
||||||
if (!modelCost.cacheRead) return undefined
|
if (!modelCost.cacheRead) return undefined
|
||||||
@@ -909,17 +925,11 @@ export async function handler(
|
|||||||
return modelCost.cacheWrite1h * cacheWrite1hTokens * 100
|
return modelCost.cacheWrite1h * cacheWrite1hTokens * 100
|
||||||
})()
|
})()
|
||||||
const totalCostInCent =
|
const totalCostInCent =
|
||||||
inputCost +
|
inputCost + outputCost + (cacheReadCost ?? 0) + (cacheWrite5mCost ?? 0) + (cacheWrite1hCost ?? 0)
|
||||||
outputCost +
|
|
||||||
(reasoningCost ?? 0) +
|
|
||||||
(cacheReadCost ?? 0) +
|
|
||||||
(cacheWrite5mCost ?? 0) +
|
|
||||||
(cacheWrite1hCost ?? 0)
|
|
||||||
return {
|
return {
|
||||||
totalCostInCent,
|
totalCostInCent,
|
||||||
inputCost,
|
inputCost,
|
||||||
outputCost,
|
outputCost,
|
||||||
reasoningCost,
|
|
||||||
cacheReadCost,
|
cacheReadCost,
|
||||||
cacheWrite5mCost,
|
cacheWrite5mCost,
|
||||||
cacheWrite1hCost,
|
cacheWrite1hCost,
|
||||||
@@ -941,8 +951,7 @@ export async function handler(
|
|||||||
) {
|
) {
|
||||||
const { inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWrite5mTokens, cacheWrite1hTokens } =
|
const { inputTokens, outputTokens, reasoningTokens, cacheReadTokens, cacheWrite5mTokens, cacheWrite1hTokens } =
|
||||||
usageInfo
|
usageInfo
|
||||||
const { totalCostInCent, inputCost, outputCost, reasoningCost, cacheReadCost, cacheWrite5mCost, cacheWrite1hCost } =
|
const { totalCostInCent, inputCost, outputCost, cacheReadCost, cacheWrite5mCost, cacheWrite1hCost } = costInfo
|
||||||
costInfo
|
|
||||||
|
|
||||||
logger.metric({
|
logger.metric({
|
||||||
"tokens.input": inputTokens,
|
"tokens.input": inputTokens,
|
||||||
@@ -953,14 +962,12 @@ export async function handler(
|
|||||||
"tokens.cache_write_1h": cacheWrite1hTokens,
|
"tokens.cache_write_1h": cacheWrite1hTokens,
|
||||||
"cost.input.microcents": centsToMicroCents(inputCost),
|
"cost.input.microcents": centsToMicroCents(inputCost),
|
||||||
"cost.output.microcents": centsToMicroCents(outputCost),
|
"cost.output.microcents": centsToMicroCents(outputCost),
|
||||||
"cost.reasoning.microcents": reasoningCost ? centsToMicroCents(reasoningCost) : undefined,
|
|
||||||
"cost.cache_read.microcents": cacheReadCost ? centsToMicroCents(cacheReadCost) : undefined,
|
"cost.cache_read.microcents": cacheReadCost ? centsToMicroCents(cacheReadCost) : undefined,
|
||||||
"cost.cache_write.microcents": cacheWrite5mCost ? centsToMicroCents(cacheWrite5mCost) : undefined,
|
"cost.cache_write.microcents": cacheWrite5mCost ? centsToMicroCents(cacheWrite5mCost) : undefined,
|
||||||
"cost.total.microcents": centsToMicroCents(totalCostInCent),
|
"cost.total.microcents": centsToMicroCents(totalCostInCent),
|
||||||
// deprecated - remove after May 20, 2026
|
// deprecated - remove after May 20, 2026
|
||||||
"cost.input": Math.round(inputCost),
|
"cost.input": Math.round(inputCost),
|
||||||
"cost.output": Math.round(outputCost),
|
"cost.output": Math.round(outputCost),
|
||||||
"cost.reasoning": reasoningCost ? Math.round(reasoningCost) : undefined,
|
|
||||||
"cost.cache_read": cacheReadCost ? Math.round(cacheReadCost) : undefined,
|
"cost.cache_read": cacheReadCost ? Math.round(cacheReadCost) : undefined,
|
||||||
"cost.cache_write_5m": cacheWrite5mCost ? Math.round(cacheWrite5mCost) : undefined,
|
"cost.cache_write_5m": cacheWrite5mCost ? Math.round(cacheWrite5mCost) : undefined,
|
||||||
"cost.cache_write_1h": cacheWrite1hCost ? Math.round(cacheWrite1hCost) : undefined,
|
"cost.cache_write_1h": cacheWrite1hCost ? Math.round(cacheWrite1hCost) : undefined,
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
import { and, Database, inArray, sql } from "@opencode-ai/console-core/drizzle/index.js"
|
||||||
|
import { ModelTpsRateLimitTable } from "@opencode-ai/console-core/schema/ip.sql.js"
|
||||||
|
import { UsageInfo } from "./provider/provider"
|
||||||
|
|
||||||
|
export function createModelTpsLimiter(providers: { id: string; model: string; tpsGoal?: number }[]) {
|
||||||
|
const tpsGoals = Object.fromEntries(
|
||||||
|
providers.flatMap((p) => {
|
||||||
|
return p.tpsGoal ? [[`${p.id}/${p.model}/${p.tpsGoal}`, p.tpsGoal]] : []
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
const ids = Object.keys(tpsGoals)
|
||||||
|
if (ids.length === 0) return
|
||||||
|
|
||||||
|
const toInterval = (date: Date) =>
|
||||||
|
parseInt(
|
||||||
|
date
|
||||||
|
.toISOString()
|
||||||
|
.replace(/[^0-9]/g, "")
|
||||||
|
.substring(0, 12),
|
||||||
|
)
|
||||||
|
const now = Date.now()
|
||||||
|
const currInterval = toInterval(new Date(now))
|
||||||
|
const prevInterval = toInterval(new Date(now - 60 * 1000))
|
||||||
|
|
||||||
|
return {
|
||||||
|
check: async () => {
|
||||||
|
const data = await Database.use((tx) =>
|
||||||
|
tx
|
||||||
|
.select()
|
||||||
|
.from(ModelTpsRateLimitTable)
|
||||||
|
.where(
|
||||||
|
and(
|
||||||
|
inArray(ModelTpsRateLimitTable.id, ids),
|
||||||
|
inArray(ModelTpsRateLimitTable.interval, [currInterval, prevInterval]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// convert to map of model to summed count across current and previous intervals
|
||||||
|
const result = data.reduce(
|
||||||
|
(acc, curr) => {
|
||||||
|
const existing = acc[curr.id] ?? { qualify: 0, unqualify: 0 }
|
||||||
|
acc[curr.id] = {
|
||||||
|
qualify: existing.qualify + curr.qualify,
|
||||||
|
unqualify: existing.unqualify + curr.unqualify,
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
},
|
||||||
|
{} as Record<string, { qualify: number; unqualify: number }>,
|
||||||
|
)
|
||||||
|
|
||||||
|
return Object.fromEntries(
|
||||||
|
Object.entries(result).map(([id, { qualify, unqualify }]) => {
|
||||||
|
const isLowTps = qualify + unqualify > 10 && qualify < unqualify
|
||||||
|
return [id, isLowTps]
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
track: async (
|
||||||
|
provider: string,
|
||||||
|
model: string,
|
||||||
|
tpsGoal: number | undefined,
|
||||||
|
tsFirstByte: number,
|
||||||
|
tsLastByte: number,
|
||||||
|
usageInfo: UsageInfo,
|
||||||
|
) => {
|
||||||
|
if (!tpsGoal) return
|
||||||
|
const id = `${provider}/${model}/${tpsGoal}`
|
||||||
|
if (!ids.includes(id)) return
|
||||||
|
if (tsFirstByte <= 0 || tsLastByte <= 0) return
|
||||||
|
const tokens = usageInfo.outputTokens
|
||||||
|
if (tokens <= 10) return
|
||||||
|
|
||||||
|
const tps = (tokens / (tsLastByte - tsFirstByte)) * 1000
|
||||||
|
const qualify = tps >= tpsGoal ? 1 : 0
|
||||||
|
const unqualify = tps < tpsGoal ? 1 : 0
|
||||||
|
await Database.use((tx) =>
|
||||||
|
tx
|
||||||
|
.insert(ModelTpsRateLimitTable)
|
||||||
|
.values({
|
||||||
|
id,
|
||||||
|
interval: currInterval,
|
||||||
|
qualify,
|
||||||
|
unqualify,
|
||||||
|
})
|
||||||
|
.onDuplicateKeyUpdate({
|
||||||
|
set: {
|
||||||
|
qualify: sql`${ModelTpsRateLimitTable.qualify} + ${qualify}`,
|
||||||
|
unqualify: sql`${ModelTpsRateLimitTable.unqualify} + ${unqualify}`,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -50,7 +50,7 @@ export const openaiHelper: ProviderHelper = ({ workspaceID }) => ({
|
|||||||
const cacheReadTokens = usage.input_tokens_details?.cached_tokens ?? undefined
|
const cacheReadTokens = usage.input_tokens_details?.cached_tokens ?? undefined
|
||||||
return {
|
return {
|
||||||
inputTokens: inputTokens - (cacheReadTokens ?? 0),
|
inputTokens: inputTokens - (cacheReadTokens ?? 0),
|
||||||
outputTokens: outputTokens - (reasoningTokens ?? 0),
|
outputTokens,
|
||||||
reasoningTokens,
|
reasoningTokens,
|
||||||
cacheReadTokens,
|
cacheReadTokens,
|
||||||
cacheWrite5mTokens: undefined,
|
cacheWrite5mTokens: undefined,
|
||||||
|
|||||||
@@ -1,16 +1,42 @@
|
|||||||
import { Resource } from "@opencode-ai/console-resource"
|
import { Database, eq } from "@opencode-ai/console-core/drizzle/index.js"
|
||||||
|
import { ModelStickyProviderTable } from "@opencode-ai/console-core/schema/ip.sql.js"
|
||||||
|
|
||||||
export function createStickyTracker(stickyProvider: "strict" | "prefer" | undefined, session: string) {
|
export function createStickyTracker(modelId: string, stickyProvider: "strict" | "prefer" | undefined, session: string) {
|
||||||
if (!stickyProvider) return
|
if (!stickyProvider) return
|
||||||
if (!session) return
|
if (!session) return
|
||||||
const key = `sticky:${session}`
|
const id = `${modelId}/${session}`
|
||||||
|
let _providerId: string | undefined
|
||||||
|
|
||||||
return {
|
return {
|
||||||
get: async () => {
|
get: async () => {
|
||||||
return await Resource.GatewayKv.get(key)
|
const data = await Database.use((tx) =>
|
||||||
|
tx
|
||||||
|
.select({
|
||||||
|
providerId: ModelStickyProviderTable.providerId,
|
||||||
|
})
|
||||||
|
.from(ModelStickyProviderTable)
|
||||||
|
.where(eq(ModelStickyProviderTable.id, id))
|
||||||
|
.limit(1),
|
||||||
|
)
|
||||||
|
_providerId = data[0]?.providerId
|
||||||
|
return _providerId
|
||||||
},
|
},
|
||||||
set: async (providerId: string) => {
|
set: async (providerId: string) => {
|
||||||
await Resource.GatewayKv.put(key, providerId, { expirationTtl: 86400 })
|
if (_providerId === providerId) return
|
||||||
|
|
||||||
|
await Database.use((tx) =>
|
||||||
|
tx
|
||||||
|
.insert(ModelStickyProviderTable)
|
||||||
|
.values({
|
||||||
|
id,
|
||||||
|
providerId,
|
||||||
|
})
|
||||||
|
.onDuplicateKeyUpdate({
|
||||||
|
set: {
|
||||||
|
providerId,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user